Search Postgresql Archives

Re: nagios -- number of postgres connections

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxx>
 Center for Information Technology Services
 University of Oslo, Norway

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

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux