You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Current »


Nagios exchange:

Postgres Plugin:



The Postgres database server must be up and running.

In /var/lib/pgsql/data/pg_hba.conf, the authentication method for "local" should be "ident":

# "local" is for Unix domain socket connections only
local all all ident

CentOS and Perl packages

Perl must be installed (this is the default).

To install additional Perl modules, CPAN should be installed, too:

Perl Setup
yum -y install cpan
install YAML
install Time::HiRes
install Net::SMPP


Download and install the Postgres Plugin


Check for the latest version at, scroll down to "Download".



Download and install
cd /tmp
tar -xzf check_postgres*.tar.gz
cd check_postgres-*
cp /usr/local/nagios/libexec/

Set up the Postgres user "nagios"

Create Postgres User
su - postgres
CREATE USER nagios WITH PASSWORD 'some_password';
exit # back to root

Set up OS user "nagios"

To keep the Postgres password from preying eyes, a password file is is required in the home directory of OS user "nagios":

Password file
vi ~nagios/.pgpass
# insert:
# insert end (EOF)
# save and exit vi
chown nagios:nagios ~nagios/.pgpass
chmod 600 ~nagios/.pgpass

Test locally

su - nagios
cd /usr/local/nagios/libexec/
./ -H localhost -db template1 -u nagios --action connection
./ -H localhost -db template1 -u nagios --action dbstats
./ -H localhost -db template1 -u nagios --action bloat
# in the next statement, you should set the limits as appropriate
./ -H localhost -db template1 -u nagios --action=database_size --warning='30 GB' --critical='35 GB'
exit # back to root

Amend nrpe.cfg

Add the following lines to /usr/local/nagios/etc/nrpe.cfg


vi /usr/local/nagios/etc/nrpe.cfg
command[check_pg_connection]=/usr/local/nagios/libexec/ -H localhost -db template1 -u nagios --action connection
command[check_pg_dbstats]=/usr/local/nagios/libexec/ -H localhost -db template1 -u nagios --action dbstats
command[check_pg_bloat]=/usr/local/nagios/libexec/ -H localhost -db template1 -u nagios --action bloat
# in the next line, you should set the limits as appropriate
command[check_pg_database_size]=/usr/local/nagios/libexec/ -H localhost -db template1 -u nagios  --action database_size --warning='30 GB' --critical='35 GB'

Test on Nagios server

Replace the "yourserver.yourdomain.tld" with the IP address or IP name of your MySQL server:

/usr/local/nagios/libexec/check_nrpe -H yourserver.yourdomain.tld -c check_pg_connection
  • No labels