Postgres Database Size ERROR

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
coco163
Posts: 7
Joined: Tue Feb 06, 2018 8:11 am

Postgres Database Size ERROR

Post by coco163 »

Hi,

I have two Postgres engines version 9.3 and 9.4 for both and same configuration.
pg_hba.conf is configured for my nagios to have access and it works.

But for one engine, when i have all information when i check the database size mentioning only one dabatase, the script actually check all databases as you can see on the following output.

Command:

Code: Select all

check_postgres.pl -H XXXXXXX--port=5432 --dbuser=xxx--dbname=xxx--dbpass="xxx" --action=database_size --warning=50GB --critical=60GB
Result:

Code: Select all

POSTGRES_DATABASE_SIZE OK: DB "XXXXX" (host:XXXXXXX) mydatabase: 50831362232 (47 GB) postgres: 6793400 (6634 kB) template0: 6793400 (6634 kB) template1: 6793400 (6634 kB)
On another hand, on another server, i can check all postgres element, such as Table size, connections...etc, but the access of template0 is not op0en (because not in use on production) and returns the following error:

Code: Select all

ERROR: permission denied for database template0
Why does the script checks all the databases where we specify only one?
You do not have the required permissions to view the files attached to this post.
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: Postgres Database Size ERROR

Post by cdienger »

The check has this to say regarding the check_database_size function:

## Check the size of one or more databases
## Supports: Nagios, MRTG
## mrtg reports the largest two databases
## By default, checks all databases
## Can check specific one(s) with include
## Can ignore some with exclude
## Warning and critical are bytes
## Valid units: b, k, m, g, t, e
## All above may be written as plural or with a trailing 'b'
## Limit to a specific user (db owner) with the includeuser option
## Exclude users with the excludeuser option


To run this for a specific database you can use the --include=dbname
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
coco163
Posts: 7
Joined: Tue Feb 06, 2018 8:11 am

Re: Postgres Database Size ERROR

Post by coco163 »

Problem remains:

[[email protected] ~]$ /usr/local/nagios/libexec/check_postgres.pl -H XXXXXXXX --port=5432 --dbuser=XXXX --dbname=mydatabase --dbpass="mypassword" --include=mydatabase --exclude=template0 --action=database_size --warning=500MB --critical=1GB
ERROR: permission denied for database template0

On another hand:

Code: Select all

[[email protected] ~]$ /usr/local/nagios/libexec/check_postgres.pl -H XXXXXXXX --port=5432 --dbuser=XXXX --dbname=mydatabase --dbpass="mypassword" --action=connection
POSTGRES_CONNECTION OK: DB "mydatabase" (host:XXXXXXXX) version 9.4.11 | time=0.01s
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: Postgres Database Size ERROR

Post by cdienger »

I haven't been able to reproduce the issue yet. Please confirm the version by running ./check_postgres.pl --version and also run the command with the --verbose option to get more detailed output.

There are also some alternative postgres plugins available on the exchange including https://exchange.nagios.org/directory/P ... ze/details that may work better for you.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
coco163
Posts: 7
Joined: Tue Feb 06, 2018 8:11 am

Re: Postgres Database Size ERROR

Post by coco163 »

Code: Select all

[root@localhost libexec]# ./check_postgres.pl -H XXXXXXXXXXXX --port=5432 --dbuser=XXXX --dbname=XXXXX --dbpass="XXXXXXXXX" --action=database_size --warning=500MB --critical=1GB --verbose
ERROR: permission denied for database template0

Code: Select all

[root@localhost libexec]# ./check_postgres.pl --version
check_postgres.pl version 2.23.0
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Postgres Database Size ERROR

Post by scottwilkerson »

Where did you get this version? The latest we ship with Nagios XI is 2.21.0

I have a postgres server with both a template0 and template1 database on my nagios server. Running 2.21.0 of the plugin with this command I get this output

Code: Select all

# /usr/local/nagios/libexec/check_postgres.pl -H localhost --port=5432 --dbuser=nagiosxi --dbname=nagiosxi --dbpass="n@gweb" --action=database_size --warning=500MB --critical=1GB --verbose  --exclude=template1 --exclude=template0
POSTGRES_DATABASE_SIZE OK: DB "nagiosxi" (host:localhost) nagiosxi: 17457444 (17 MB) postgres: 5488932 (5360 kB)  | time=0.01s nagiosxi=17457444;524288000;1073741824 postgres=5488932;524288000;1073741824
If I just want the nagiosxi database the include command works for me

Code: Select all

# /usr/local/nagios/libexec/check_postgres.pl -H localhost --port=5432 --dbuser=nagiosxi --dbname=nagiosxi --dbpass="n@gweb" --action=database_size --warning=500MB --critical=1GB --verbose --include=nagiosxi
POSTGRES_DATABASE_SIZE OK: DB "nagiosxi" (host:localhost) nagiosxi: 17457444 (17 MB)  | time=0.01s nagiosxi=17457444;524288000;1073741824
I am going to attach 2.21.0 here if you would like to try to downgrade to this version
check_postgres.zip
unzip and place in /usr/local/nagios/libexec
You do not have the required permissions to view the files attached to this post.
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
coco163
Posts: 7
Joined: Tue Feb 06, 2018 8:11 am

Re: Postgres Database Size ERROR

Post by coco163 »

Thank you but same error.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Postgres Database Size ERROR

Post by scottwilkerson »

This is strange, I've never seen this, nor could I find a single person that has ever experienced it

You clearly have one that works and one that doesn't, can you distinguish any difference between the configuration and access allowed between the 2 servers?
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked