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

@ -9,6 +9,11 @@ eth0_ip: 10.5.126.109
vmhost: virthost14.phx2.fedoraproject.org
datacenter: phx2
# This is a generic list, monitored by collectd
databases:
- datanommer
# This is a more strict list, to be made publicly available
dbs_to_backup:
- datanommer

View file

@ -38,8 +38,9 @@
- denyhosts
- nagios_client
- fas_client
- collectd/base
- postgresql_server
- collectd/base
- collectd/postgres # This requires a 'databases' var to be set in host_vars
tasks:
- include: "{{ tasks }}/hosts.yml"

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>