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.m.guerrero@usit.uio.no>
Center for Information Technology Services
University of Oslo, Norway
PGP Public Key: http://folk.uio.no/rafael/