Page 2 of 3
Re: Error using check_mssql
Posted: Wed Sep 04, 2019 10:13 am
by scottwilkerson
So all along the plugin has been working as you are getting this line
Code: Select all
OK: Query duration=0.002294 seconds.|query_duration=0.002294s;50;60 ''=;1;2
, but it is also outputting the notices.
what is this setting in the php.ini on the new server?
Code: Select all
grep display_errors /etc/php/7.2/cli/php.ini
We want this to be
Off
Re: Error using check_mssql
Posted: Wed Sep 04, 2019 10:26 am
by nelsonw
Hi Scott,
If the plugin is working correctly, should it not return a "computed" number? See below from successful SQL script. I do not get this value with my unsuccessful SQL script. The unsuccessful SQL script, test_sql, should return "Critical" state as the count returned is 253
/usr/local/nagios/sql# /usr/local/nagios/libexec/check_mssql -H <HOST> --username <USERNAME> --password <PWD> --database <DATABASE> --port 1433 --query /usr/local/nagios/sql/successful_test_sql --result 0 --decode --warning 50 --critical 60 --querywarning 1 --querycritical 2 --result 0
CRITICAL: Query result 253 was higher than Query critical threshold 2.|query_duration=0.002628s;50;60 'computed'=253;1;2
Please see below from config file
grep display_errors /etc/php/7.2/cli/php.ini
; display_errors
display_errors = Off
; separately from display_errors. PHP's default behavior is to suppress those
Thanks,
Nelson
Re: Error using check_mssql
Posted: Wed Sep 04, 2019 11:38 am
by scottwilkerson
True, good point.
I started debugging this and get the same behavior on a CentOS system if I use
Code: Select all
if (datepart(day, getdate()) >= 2)
select (CASE count(*)
when 0 then 3
else 0
end) 'Total'
from dataitemtype
else
select (CASE count(*)
when 0 then 3
else 0
end) 'Total'
from dataitemtype
However, If I just use the CASE statement it works as expected
Code: Select all
select (CASE count(*)
when 0 then 3
else 0
end) 'Total'
from dataitemtype
Re: Error using check_mssql
Posted: Wed Sep 04, 2019 12:02 pm
by nelsonw
Yes, if I remove the if/else statement and just have the case statement, it is working on my Ubuntu server.
I am wondering if there are packages missing on my Ubuntu and your CentOS environment that would support if/else statements
Thanks,
Nelson
Re: Error using check_mssql
Posted: Wed Sep 04, 2019 12:52 pm
by scottwilkerson
I think I know what is going on but I don't have a solution at present.
I confirmed with
@cdienger that this did work on his older CentOS system with the old plugin version 0.7.3 because CentOS6 & 7 with php 5.x still had support for the php
mssql_connect functionality.
This was removed in newer versions of PHP and as such the plugin was re-written using the PHP extension
pdo_dblib, however, for some reason, this doesn't like the if/else statements as it makes a prepared statement on the SQL server.
I am going to continue to look for a work around but wanted to touch base on the current findings.
Re: Error using check_mssql
Posted: Fri Sep 06, 2019 4:54 am
by nelsonw
Thanks for the update Scott.
Please let me know how the investigation in to a work-around is going
Thanks,
Nelson
Re: Error using check_mssql
Posted: Fri Sep 06, 2019 6:54 am
by scottwilkerson
nelsonw wrote:Thanks for the update Scott.
Please let me know how the investigation in to a work-around is going
Thanks,
Nelson
Unfortunately we have been unsuccessful using any form of IF statement in PDO, at present I do not see any workaround.
Re: Error using check_mssql
Posted: Fri Sep 06, 2019 8:33 am
by nelsonw
Would uninstalling php7 on my server and reverting back to php5 work?
Re: Error using check_mssql
Posted: Fri Sep 06, 2019 9:57 am
by scottwilkerson
nelsonw wrote:Would uninstalling php7 on my server and reverting back to php5 work?
Depending if 5 is supported on the OS it may work, but you would also need to revert the plugin to the one
@cdienger posted here
https://support.nagios.com/forum/viewto ... 80#p291355
I would definitely do this in a test environment first and reverting PHP to 5 isn't going to be a straight forward thing on all OS's
Re: Error using check_mssql
Posted: Fri Sep 06, 2019 12:35 pm
by nelsonw
Thanks Scott. I will hold off on reverting to version 5. Please let me know how you progress with a possible work-around or if there is any other alternative