Page 1 of 1

sql query returning critical value, nagios still thinks OK

Posted: Tue Aug 22, 2017 12:01 pm
by Chite
Ok, I'm seriously so close to getting this resolved but I must be doing something wrong. I'm running the following oracle query and the query is returning the value of 0. if I run the same query below in Oracle SQL Developer it returns the value of 0. I'm taking that query value and plugging it into the critical value at the end but yet it still comes back and says it's OK.... and I don't understand what the 'select'=0;1;0 is at the end. is that the 0;1;5 minute values that Nagios does it's checks on?

thanks for your help!

query:
[root@nagios libexec]# ./check_oracle_health --connect 'servername:port#/sid' --username '<username>' --password '<password>' --mode sql --name "SELECT case when end_date is null then 1 else 0 end RETVAL FROM SNP_LPI_RUN a,SNP_LP_INST b WHERE a.i_lp_inst = b.i_lp_inst and load_plan_name like 'Extract eBSO, Transform, Load DW Minimal%' and TO_CHAR(start_date, 'DD-MON-YYYY HH24:MI:SS') in (select max(TO_CHAR(start_date, 'DD-MON-YYYY HH24:MI:SS')) FROM SNP_LPI_RUN a,SNP_LP_INST b where a.i_lp_inst = b.i_lp_inst and load_plan_name like 'Extract eBSO, Transform, Load DW Minimal%')" --critical 0
OK - select case when end_date is null then 1 else 0 end retval from snp_lpi_run a,snp_lp_inst b where a.i_lp_inst = b.i_lp_inst and load_plan_name like 'extract ebso, transform, load dw minimal%' and to_char(start_date, 'dd-mon-yyyy hh24:mi:ss') in (select max(to_char(start_date, 'dd-mon-yyyy hh24:mi:ss')) from snp_lpi_run a,snp_lp_inst b where a.i_lp_inst = b.i_lp_inst and load_plan_name like 'extract ebso, transform, load dw minimal%'): 0 | 'select'=0;1;0

Re: sql query returning critical value, nagios still thinks

Posted: Tue Aug 22, 2017 1:33 pm
by scottwilkerson
This critical threshold will only be critical if result is OVER 0 not == 0, change to

Code: Select all

 --critical 0:
https://nagios-plugins.org/doc/guidelin ... HOLDFORMAT

Also, the following is the automatically generated performance data that will be used to create performance graphs

Code: Select all

 0 | 'select'=0;1;0

Re: sql query returning critical value, nagios still thinks

Posted: Wed Aug 23, 2017 3:17 pm
by Chite
Thank you. yes that makes more sense. the query was coming back with a value of 0 so I had to change the critical value to -1 to actually get the critical status in Nagios.

thanks your your help

Chaden

Re: sql query returning critical value, nagios still thinks

Posted: Wed Aug 23, 2017 3:19 pm
by scottwilkerson
Glad to be of assistance!