Page 1 of 1

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

Posted: Wed Apr 21, 2021 2:04 am
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

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

Posted: Wed Apr 21, 2021 10:50 am
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)

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

Posted: Wed Apr 21, 2021 11:02 pm
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

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

Posted: Thu Apr 22, 2021 9:45 am
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.

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

Posted: Thu Apr 22, 2021 11:39 pm
by mindspring
Ah fantastic thanks, that is working now!

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

Posted: Fri Apr 23, 2021 7:26 am
by scottwilkerson
mindspring wrote:Ah fantastic thanks, that is working now!
Locking thread