Postgres module help

Hi,

I’ve followed the instructions here:

https://docs.librenms.org/Extensions/Applications/#postgres

but am not getting the desired results.

When I configure /root/.pgpass as defined here:

https://www.postgresql.org/docs/9.2/static/libpq-pgpass.html

ie:

hostname:port:database:username:password

I also make sure I set the DBuser and the path:

cpg='/usr/bin/env /usr/local/nagios/libexec/check_postgres'

correctly in the /etc/snmp/postgres file.

When I then run the /etc/snmp/postgres script, I get:

/etc/snmp/postgres
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
ERROR: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

the reason is, we have the postgres running on port 5598, so technically, the check_postgres perl script needs the port information (for some reason it isn’t picking it up from .pgpass).

So when I change the line in /etc/snmp/postgres to:

$cpg -u $DBuser -p 5598 --action dbstats | awk -F ' ' '

and then re-run the script, I then get output.

I then go to the web GUI, turn on unix_agent, go to Apps, turn on Postgres, go to the Apps tab and check the output, and basically still see -nan and 0’s.

Is there a “right way” to do this monitoring?

Note 1: we also have another DB running on port 5599 on the same host, so am wondering how this script detects multiple databases on the one host when it seems to require the port to be defined in the /etc/snmp/postgres script.

Note 2: We get the check_postgres.pl script v2.22 from here:

https://bucardo.org/Check_postgres/

Thanks.

Michael.

You have to use our postgresql script: https://docs.librenms.org/#Extensions/Applications/#postgres

Hi Laf. I’m not sure I understand your reply.

I’ve completed the steps as provided on that link ie:

/etc/snmp/postgres

is your script.

Step 5 says:

Install the Nagios check check_postgres.pl on your system.

Where is the check_postgres.pl Nagios script located but on the authors website?

Please advise.

Michael.

Hi. As an update, as per the other “osupdates” help forum I went through and added the various rules / policies into SELinux.

Graphs are also now showing for PosgreSQL but on only the one database running on 5598, not the other database running on 5599.

The /root/.pgpass has two lines, one for port 5598, the other for port 5599.

As we determined previously though, without specifying the port within the /etc/snmp/postgres script, the script doesn’t run complaining about:

ERROR: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

Adding the port in the script produces the output.

So I have created two scripts, one for port 5598, the other for port 5599:

  1. /etc/snmp/postgres_port5598
  2. /etc/snmp/postgres_port5599

Both scripts run and produce output with the respective DB names.

I referenced these script in snmpd.conf as:

extend postgres /etc/snmp/postgres_port5598
extend postgres /etc/snmp/postgres_port5599

But when I look in the Web GUI, only the first one (port 5598) shows in the “Total” DBs listed (that and template1, template0, postgres).

Is there something I’m doing wrong or should I be doing something better/more correct ?

Michael.

Hi,

I’m just wondering if anyone knows anything about this?

I did a search in the docs section and I do see this:

but this doesn’t seem related to adding another port to look for more DB’s ?

Please advise.

Michael.

Hi,

To help anyone else reading such a thread, this has been solved and is provided in another case:

with explanation.

Thanks.

Michael.

Hi,

i want ask where can i get the script for check_postgres.pl? i check your link there is no script for that.

Thanks

check here -> https://docs.librenms.org/#Extensions/Applications/#postgres

Hi kevin,

Yes the link is show me the step by step but there is no link for check_postgres.pl script, the link is only provide for snmp postgre, cmiiw

Thanks

Hi. Read the top of this thread, on my first post I posted the URL to the bucardo website which supports and provides this postgres check Nagios plugin.

Hi micoots,

thanks for the reply… i dont know that the link is solved the problem.

hi michael,

should i compile the tar gz or just copy the script only?

Thanks

I used the perl script as is.

I renamed it by removing the .pl extension, only because I didn’t want to modify the LibreNMS script.