Re: nagios -- number of postgres connections

From: Rafael Martinez <r(dot)m(dot)guerrero(at)usit(dot)uio(dot)no>
To: Whit Armstrong <armstrong(dot)whit(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: nagios -- number of postgres connections
Date: 2009-06-17 06:00:56
Message-ID: 4A388698.80905@usit.uio.no
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Whit Armstrong wrote:
> anyone know a way to get nagios to monitor the number of postgres connections?
>
> Thanks,
> Whit
>

Hello

We use this plugin. Save it under /etc/munin/plugins/pg_connections and
update the file /etc/munin/plugin-conf.d/postgres with:

-------------------
[pg_connection]
user postgres
-------------------

-------------------------------------------------
#!/bin/sh
#
# Plugin to monitor PostgreSQL connections.
#
# Parameters:
#
# config (required)
# autoconf (optional - only used by munin-config)
#
# Magic markers (optional - used by munin-config and some installation
# scripts):
#%# family=auto
#%# capabilities=autoconf

PID_FILE="/var/lib/pgsql/data/postmaster.pid"

if [ "$1" = "autoconf" ]; then
if [ -f $PID_FILE ]; then
echo yes
exit 0
else
echo "no (Service not running)"
exit 1
fi
else
if [ "$1" = "suggest" ]; then
ls -1 /tmp/
exit 0
fi
fi

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

echo "graph_title Number of connections to the database"
echo 'graph_args -l 0 '
echo 'graph_vlabel Number of PostgreSQL connections'
echo 'graph_category PostgreSQL'
echo 'graph_period second'
echo 'graph_info The number of opened connections to 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

printf 'established.value '
/usr/bin/psql template1 -At -c "SELECT count(*) FROM pg_stat_activity"
-------------------------------------------------

PS.- You have to update the PATHS with the values in your system, and
the user postgres needs access to your database, for this plugin to work.

regards,
--
Rafael Martinez, <r(dot)m(dot)guerrero(at)usit(dot)uio(dot)no>
Center for Information Technology Services
University of Oslo, Norway

PGP Public Key: http://folk.uio.no/rafael/

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rafael Martinez 2009-06-17 06:09:41 Re: nagios -- number of postgres connections
Previous Message Scott Mead 2009-06-17 03:45:35 Re: nagios -- number of postgres connections