There's more...

Wait a minute! We never added a check for PostgreSQL itself! As we can't allow PostgreSQL to remain unmonitored, create a user on our PostgreSQL server with the following command:

CREATE USER nagios;

Then, make an entry in the pg_hba.conf file to allow trusted checks from the monitoring server with this line:

host    template1    nagios    192.168.56.5/32    trust 

Then, reload the PostgreSQL configuration with this command:

pg_ctl -D $PGDATA reload

Next, add a service entry to our db_conf.cfg file like this:

define service { 
       use                     generic-service 
       hostgroup_name          pg-servers 
       service_description     PostgreSQL Status 
       check_command           check_pgsql 
} 

After reloading our Nagios configuration files, click on the Services link in the web interface. ...

Get PostgreSQL High Availability Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.