MSSQL Query Error since plugin updated

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
spurrellian
Posts: 43
Joined: Tue Jan 06, 2015 6:26 am
Location: Bath, UK

MSSQL Query Error since plugin updated

Post by spurrellian »

Hi,

I've had a mssql query check running for the last two years without any issue. I updated the plugin this week (version 0.8.0) and since then it stopped working.

Here is the check

Code: Select all

./check_mssql -H somehost --username someusername --password "somepassword" --database Ctrack6 --port 1433 --query "IF+%28select+count%28distinct%28NodePropertyValue%29%29+FROM+LastMobilePositions+WITH+%28nolock%29+LEFT+OUTER+JOIN+NodePropertyValues+ON+LastMobilePositions.MobileNodeId+%3D+NodePropertyValues.NodeId+where+nodepropertyvalues.NodePropertyId%3D2+and+ReceivedTime+%3C+dateadd%28hh%2C-1%2Cgetdate%28%29%29+and+NodePropertyValue+not+like+%27%25old%25%27+and+NodePropertyValue+not+like+%27%25deinstalled%25%27+and+NodePropertyValue+not+like+%27%25de+installed%25%27%29+%3E+200+select+%27good%27%3B+ELSE+SELECT+%27bad%27%3B" --result "good" --decode --result good
Here is the raw sql

Code: Select all

IF (select count(distinct(NodePropertyValue)) FROM LastMobilePositions WITH (nolock) 
LEFT OUTER JOIN NodePropertyValues ON LastMobilePositions.MobileNodeId = NodePropertyValues.NodeId 
where nodepropertyvalues.NodePropertyId=2 and ReceivedTime < dateadd(hh,-1,getdate()) 
and NodePropertyValue not like '%old%' and NodePropertyValue not like '%deinstalled%' and NodePropertyValue
not like '%de installed%') > 200 select 'good'; ELSE SELECT 'bad';
From the Nagios XI web interface you get

Code: Select all

CRITICAL: Query expected "good" but got ""

But if you run it from the commandline you get

Code: Select all

PHP Notice:  Undefined variable: column_name in /usr/local/nagios/libexec/check_mssqlbackup on line 475
PHP Notice:  Undefined variable: query_result in /usr/local/nagios/libexec/check_mssqlbackup on line 475
PHP Notice:  Undefined variable: query_result in /usr/local/nagios/libexec/check_mssqlbackup on line 511
PHP Notice:  Undefined variable: query_result in /usr/local/nagios/libexec/check_mssqlbackup on line 516
CRITICAL: Query expected "good" but got "".|query_duration=0.012408s;; ''=;
With an older version (0.7.8) it gives the correct result

Code: Select all

OK: Query results matched "good", query duration=0.017745 seconds.|query_duration=0.017745s;;
I've reverted back to the old version from the time being
Paul S - Using Nagios XI, Network Analyzer, Log Server
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: MSSQL Query Error since plugin updated

Post by mcapra »

This is a major change between 0.7.8 and 0.8.0:

Code: Select all

#   Version 0.7.9 - 2016/05/26
#   - Changed from deprecated mssql functions to PDO
Try a yum install php-pdo php-mssql and see if that gets 0.8.0 running. If it doesn't, can you share the output of the previously executed yum command?
Former Nagios employee
https://www.mcapra.com/
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: MSSQL Query Error since plugin updated

Post by tgriep »

Thanks @mcapra for the help on this.
If those packages are not installed on the system, it would cause the error you are seeing so it should work after they are installed.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked