diff options
author | mh <mh@immerda.ch> | 2008-10-01 21:06:14 +0000 |
---|---|---|
committer | mh <mh@immerda.ch> | 2008-10-01 21:06:14 +0000 |
commit | 2176f3295148a6cc22bafb54007db972d749dc44 (patch) | |
tree | 5f8c91e1eb920e8872e2c8b01ade6896bb8e9945 /files/munin/puppetresources.postgres | |
parent | 2d85eb59b272f8c8ed5990d58c0b9857b3b068eb (diff) |
Merge commit 'puzzle/development'
Diffstat (limited to 'files/munin/puppetresources.postgres')
-rw-r--r-- | files/munin/puppetresources.postgres | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/files/munin/puppetresources.postgres b/files/munin/puppetresources.postgres new file mode 100644 index 0000000..89fd6ba --- /dev/null +++ b/files/munin/puppetresources.postgres @@ -0,0 +1,37 @@ +#!/bin/sh +# +# Plugin to monitor resource count as managed by puppet +# +# Parameters: +# +# config (required) + +function select_resources() { + psql -c "select count(*) as count, hosts.name from resources join hosts on (host_id = hosts.id) group by hosts.name order by count(*) DESC" -A -F " " -t puppet +} + +if [ "$1" = "config" ]; then + + echo 'graph_title Puppet Resources' + echo 'graph_args -l 0 --base 1000' + echo 'graph_vlabel configured resources' + echo 'graph_category other' + select_resources | while read count hostname; do + graphname="$(echo "$hostname" | tr '.-' _)" + echo "$graphname.label $hostname" + echo "$graphname.type GAUGE" + done + exit 0 +fi + +select_resources | while read count hostname; do + graphname="$(echo "$hostname" | tr '.-' _)" + echo "$graphname.value $count" +done + +if [ -f /proc/vmstat ]; then + awk '/pswpin/ { print "swap_in.value " $2 } /pswpout/ { print "swap_out.value " $2 }' < /proc/vmstat +else + awk '/swap/ { print "swap_in.value " $2 "\nswap_out.value " $3 }' < /proc/stat +fi + |