Page 1 of 1

check_pgsql run through check_nrpe fails

Posted: Fri Jun 14, 2019 3:14 pm
by seatonc
I am new to Nagios and am attempting to set up monitoring of a postgres database. I'm taking over from someone else and working on a fairly complicated system. I'm working through the details by setting up monitoring on a new VM (the database system).

I have nrpe installed and running on the database system, and nagios server set up and running on another system. I have a .cfg file in /etc/nrpe.d/ on the database system that contains the command to run check_pgsql:

Code: Select all

command[check_pgsql-os]=usr/lib64/nagios/plugins/check_pgsql -l postgres
If I run that command locally as root, it successfully returns an "OK - database template1" status line.

If I run that command remotely from the nagios server system using check_nrpe

Code: Select all

check_nrpe -H dbsystem -t 60 -c check_pgsql-os 
It returns:

Code: Select all

CRITICAL - no connection to 'template1' (could not connect to server: Permission denied
        Is the server running locally and accepting 
        connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
)
I have another check on the database system that uses check_disk, which is also run remotely using check_nrpe, and that check runs successfully and returns an "OK" status line.

Nagios server system is Centos 6, database system is Centos 7, database is Postgres 11.3

Any advice on why check_pgsql would run successfully when run locally and fail when run through check_nrpe would be greatly appreciated.

Re: check_pgsql run through check_nrpe fails

Posted: Sat Jun 15, 2019 1:03 am
by seatonc
To answer my own question, SELinux was enabled on the database system. Disabling SELinux on the database system fixed the problem and check_pgsql works remotely now.

Re: check_pgsql run through check_nrpe fails

Posted: Mon Jun 17, 2019 6:35 am
by scottwilkerson
seatonc wrote:To answer my own question, SELinux was enabled on the database system. Disabling SELinux on the database system fixed the problem and check_pgsql works remotely now.
Good to hear it is resolved!

Locking thread