summaryrefslogtreecommitdiffstats
path: root/roles/collectd/postgres/templates/collectd-postgres.sh
blob: 4ac08e4256e4d8db9142130917159c3055dd5ecb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/bash

# These defaults are commented out because selinux doesn't like us running that
# hostname on rhel7 for some reason.  Anyways, we always pass in the arguments
# via the collectd configuration information so wth.  -- threebean
#pause=10
#host=$( /usr/bin/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 {{ ' '.join(databases) }}
   do
      echo "PUTVAL $host/pg_conns/current_connections-$db $time:$(ps auxwww | grep -c $db)"
   done
   sleep $pause
 done