Collectd+postgres for db-datanommer01

This commit is contained in:
Ralph Bean 2014-05-29 16:36:43 +00:00
parent ad799abed9
commit e258bae727
5 changed files with 46 additions and 1 deletions

View file

@ -0,0 +1,14 @@
---
- name: Copy in /usr/local/bin/collectd-postgres.sh
template: >
src=collectd-postgres.sh
dest=/usr/local/bin/collectd-postgres.sh
mode=0755
notify: restart collectd
- name: Copy in /etc/collectd.d/postgres.conf
template: >
src=postgres.conf
dest=/etc/collectd.d/postgres.conf
notify: restart collectd

View file

@ -0,0 +1,22 @@
#!/bin/bash
pause=10
host=$( hostname -s )
while getopts "h:p:s:" c; do
case $c in
h) host=$OPTARG;;
p) pause=$OPTARG;;
*) echo "Usage: /bin/bash [-h <hostname>] [-p <seconds>]";;
esac
done
while [ $? -eq 0 ] ; do
time="$(date +%s)"
for db in {{ databases.join(' ') }}
do
echo "PUTVAL $host/pg_conns/pg_conns-$db $time:$(ps auxwww | grep -c $db)"
done
sleep $pause
done

View file

@ -0,0 +1,3 @@
<Plugin exec>
Exec "nobody" "/usr/local/bin/collectd_postgres.sh" "-h" "{{ ansible_hostname }}" "-p" "10"
</Plugin>