neuer versuch mit munin für immer1-5
[puppet_munin.git] / files / plugins / pg_conn
1 #!/bin/sh
2 #
3 # Plugin to monitor PostgreSQL connections.
4 #
5 # Parameters:
6 #
7 #       config   (required)
8 #       autoconf (optional - only used by munin-config)
9 # Based on netstat plugin
10 # $Log$
11 #  eric@ohmforce.com
12
13 #
14 # Magic markers (optional - used by munin-config and some installation
15 # scripts):
16 #%# family=auto
17 #%# capabilities=autoconf
18
19
20
21 if [ "$1" = "autoconf" ]; then
22         if ( netstat -s 2>/dev/null >/dev/null ); then
23                 echo yes
24                 exit 0
25         else
26                 if [ $? -eq 127 ]
27                 then
28                         echo "no (netstat program not found)"
29                         exit 1
30                 else
31                         echo no
32                         exit 1
33                 fi
34         fi
35 fi
36
37 if [ "$1" = "config" ]; then
38
39         echo 'graph_title PostgreSQL'
40         echo 'graph_args -l 0 '
41         echo 'graph_vlabel Number of PostgreSQL connections'
42         echo 'graph_category postgresql'
43         echo 'graph_period second'
44         echo 'graph_info This graph shows the number of opened connections on PostgreSQL.' 
45         echo 'established.label established'
46         echo 'established.type GAUGE'
47         echo 'established.max 500'
48         echo 'established.info The number of currently open connections.'
49         exit 0
50 fi
51 netstat -a | awk '{ print $4 }'| grep postgres | wc -l | xargs echo established.value