Collectd+postgres for db-datanommer01
This commit is contained in:
parent
ad799abed9
commit
e258bae727
5 changed files with 46 additions and 1 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
|
14
roles/collectd/postgres/tasks/main.yml
Normal file
14
roles/collectd/postgres/tasks/main.yml
Normal 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
|
22
roles/collectd/postgres/templates/collectd-postgres.sh
Normal file
22
roles/collectd/postgres/templates/collectd-postgres.sh
Normal 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
|
3
roles/collectd/postgres/templates/postgres.conf
Normal file
3
roles/collectd/postgres/templates/postgres.conf
Normal file
|
@ -0,0 +1,3 @@
|
|||
<Plugin exec>
|
||||
Exec "nobody" "/usr/local/bin/collectd_postgres.sh" "-h" "{{ ansible_hostname }}" "-p" "10"
|
||||
</Plugin>
|
Loading…
Add table
Add a link
Reference in a new issue