summaryrefslogtreecommitdiff
path: root/files/plugins/pg_conn
blob: aa2ebb74e7d211e9ef5c6fbd0347d89bc2a2a84a (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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/sh
#
# Plugin to monitor PostgreSQL connections.
#
# Parameters:
#
#       config   (required)
#       autoconf (optional - only used by munin-config)
# Based on netstat plugin
# $Log$
#  eric@ohmforce.com
# 
#
# Magic markers (optional - used by munin-config and some installation
# scripts):
#%# family=auto
#%# capabilities=autoconf



if [ "$1" = "autoconf" ]; then
        if ( netstat -s 2>/dev/null >/dev/null ); then
                echo yes
                exit 0
        else
                if [ $? -eq 127 ]
                then
                        echo "no (netstat program not found)"
                        exit 1
                else
                        echo no
                        exit 1
                fi
        fi
fi

if [ "$1" = "config" ]; then

        echo 'graph_title PostgreSQL'
        echo 'graph_args -l 0 '
        echo 'graph_vlabel Number of PostgreSQL connections'
        echo 'graph_category postgresql'
        echo 'graph_period second'
        echo 'graph_info This graph shows the number of opened connections on PostgreSQL.' 
        echo 'established.label established'
        echo 'established.type GAUGE'
        echo 'established.max 500'
        echo 'established.info The number of currently open connections.'
        exit 0
fi
netstat -a | awk '{ print $4 }'| grep postgres | wc -l | xargs echo established.value