POSTGRES_CUSTOM_QUERY UNKNOWN: DB "db_tools" (host:host) Inv

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
mindspring
Posts: 117
Joined: Thu Jul 19, 2012 10:24 am

POSTGRES_CUSTOM_QUERY UNKNOWN: DB "db_tools" (host:host) Inv

Post by mindspring »

Hi There,

POSTGRES_CUSTOM_QUERY UNKNOWN: DB "db_tools" (host:host) Invalid format returned by custom query | time=0.36s count=422;1

I have a similiar issue referenced in this post but I can't seem to the resolve it.
https://support.nagios.com/forum/viewto ... =7&t=28736


This is my query, it is a count and the returned value is an integer.

Code: Select all


/check_postgres.pl -H host -p 5432 -db user_tools -dbuser db_tools -dbpass xxxxx -w 1 --action custom_query --query="select count(*) from sftp_uploader_queue where write_path like '%FobyRAM' and date_added > now() - interval '1 day'"
POSTGRES_CUSTOM_QUERY UNKNOWN: DB "db_tools" (host:host) Invalid format returned by custom query | time=0.36s count=422;1 

I tried with warning and critical and this one with warning only and tried with neither warning or critical but then it moaned about at least having one.
Any ideas?

Thanks
dchurch
Posts: 858
Joined: Wed Oct 07, 2020 12:46 pm
Location: Yo mama

Re: POSTGRES_CUSTOM_QUERY UNKNOWN: DB "db_tools" (host:host)

Post by dchurch »

The custom query expects at least one column in the output called "result". So if you change the query to this it should work:

Code: Select all

./check_postgres.pl -db root -dbuser root -w 1 --action custom_query --query="select count(*) as result from sftp_uploader_queue where write_path like '%FobyRAM' and date_added > now() - interval '1 day'"
(Added text was as result)
If you didn't get an 8% raise over the course of the pandemic, you took a pay cut.

Discussion of wages is protected speech under the National Labor Relations Act, and no employer can tell you you can't disclose your pay with your fellow employees.
mindspring
Posts: 117
Joined: Thu Jul 19, 2012 10:24 am

Re: POSTGRES_CUSTOM_QUERY UNKNOWN: DB "db_tools" (host:host)

Post by mindspring »

Thanks.

I should have mentioned that I tried that already

Code: Select all


/check_postgres.pl -H host -p 5432 -db user_tools -dbuser db_tools -dbpass xxxxx -w 1 --action custom_query --query="select count(*) from sftp_uploader_queue as result where write_path like '%FobyRAM' and date_added > now() - interval '1 day'"
POSTGRES_CUSTOM_QUERY UNKNOWN: DB "db_tools" (host:host) Invalid format returned by custom query | time=0.33s count=423;1 

Interestingly it does report the count = 423 in the output .

any other ideas? Tx
dchurch
Posts: 858
Joined: Wed Oct 07, 2020 12:46 pm
Location: Yo mama

Re: POSTGRES_CUSTOM_QUERY UNKNOWN: DB "db_tools" (host:host)

Post by dchurch »

mindspring wrote:select count(*) from sftp_uploader_queue as result
dchurch wrote:select count(*) as result from sftp_uploader_queue
These two are not the same thing, SQL syntax-wise. You have to put "as result" after "count(*)", not after the table name.
If you didn't get an 8% raise over the course of the pandemic, you took a pay cut.

Discussion of wages is protected speech under the National Labor Relations Act, and no employer can tell you you can't disclose your pay with your fellow employees.
mindspring
Posts: 117
Joined: Thu Jul 19, 2012 10:24 am

Re: POSTGRES_CUSTOM_QUERY UNKNOWN: DB "db_tools" (host:host)

Post by mindspring »

Ah fantastic thanks, that is working now!
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: POSTGRES_CUSTOM_QUERY UNKNOWN: DB "db_tools" (host:host)

Post by scottwilkerson »

mindspring wrote:Ah fantastic thanks, that is working now!
Locking thread
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked