Issues with MS SQL checks

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
dbsaust
Posts: 76
Joined: Mon Dec 06, 2010 12:41 am

Issues with MS SQL checks

Post by dbsaust »

Hi,

I'm having a strange problem with the results of an SQL service check which does not seem to be consistent with the rest of the SQL checks in the system.
I have checked 2 different service checks from the command line to troubleshoot but no issue:

[root@aunagiosxi libexec]# ./check_mssql -H X --port 1433 --username X --password "X" --database X --query "EXECUTE usp_Alert_ConsignmentDataNotPopulating" --result 0
OK: Query results matched, query duration=1.943026 seconds.

[root@aunagiosxi libexec]# ./check_mssql -H X --port X --username X --password "X" --database LDW_Staging --query "EXECUTE usp_Alert_JobEventDataNotPopulating" --result 0
OK: Query results matched, query duration=0.000855 seconds.

Yet when I run from Nagios console I get 2 different results:

MSSQL Query - Check TMS to AUVIS Sync
This service is flapping
Warning 5m 45s 5/5 15/10/2013 16:50:13
WARNING: Query results matched, query duration=2.007195 seconds.

MSSQL Query - Check TMS to LDW Sync
Ok 10d 16h 3m 52s 1/5 15/10/2013 16:50:29
OK: Query results matched, query duration=0.000984 seconds.

Some time ago I updated the code within the script which caused a bug in the results translation to OK/Warning/Alert. But I now only get an issue with this one particular result. See below forum post:
http://support.nagios.com/forum/viewtop ... 16&t=10266

Do you have any idea what I can do to rectify/further analyse this please?
dbsaust
Posts: 76
Joined: Mon Dec 06, 2010 12:41 am

Re: Issues with MS SQL checks

Post by dbsaust »

Just an update, I have just ran the same query 4 times from the command line and got differing results:

WARNING: Query results matched, query duration=2.010876 seconds.
WARNING: Query results matched, query duration=2.027159 seconds.
OK: Query results matched, query duration=1.987831 seconds.
WARNING: Query results matched, query duration=2.010377 seconds.

I have also checked the script: /usr/local/nagios/libexec/check_mssql and the changes that I was advised to make are still saved within the syntax.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Issues with MS SQL checks

Post by scottwilkerson »

If you do not specify a warning threshold a default of 2 seconds is used

Code: Select all

/usr/local/nagios/libexec/check_mssql -h
check_mssql, 0.6.9
Copyright (c) 2008 Gary Danko ([email protected])
              2012 Nicholas Scott ([email protected])
This plugin checks various aspect of an MSSQL server. It will also
execute queries or stored procedures and return results based on
query execution times and expected query results.

Options:
 -h, --help
    Print detailed help screen.
 -V, --version
    Print version information.
 -H, --hostname
    Hostname of the MSSQL server.
 -U, --username
    Username to use when logging into the MSSQL server.
 -P, --password
    Password to use when logging into the MSSQL server.
 -p, --port
    Optional MSSQL server port. (Default is 1433).
 -I, --instance
    Optional MSSQL Instance
 -d, --database
    Optional DB name to connect to.
 -q, --query
    Optional query or SQL file to execute against the MSSQL server.
 -s, --storedproc
    Optional stored procedure to execute against the MSSQL server.
 -r, --result
    Expected result from the specified query, requires -q. The query
    pulls only the first row for comparison, so you should limit
    yourself to small, simple queries.
 -w, --warning
    Warning threshold in seconds on duration of check (Default is 2).
    Accepts decimal values, note however that there must be at least a
    leading 0. Example, .0023 is not a valid entry, but 0.0023 is.
 -c, --critical
    Critical threshold in seconds on duration of check (Default is 5).
    Accepts decimal values, note however that there must be at least a
    leading 0. Example, .0023 is not a valid entry, but 0.0023 is.
 -W, --querywarning
    Warning threshold for the query IF IT IS NUMERIC, otherwise, this
    will be ignored.
 -C, --querycritical
    Critical threshold for the query IF IT IS NUMERIC, otherwise, this
    will be ignored.

Example: check_mssql -H myserver -U myuser -P mypass -q /tmp/query.sql -w 2 -c 5
Example: check_mssql -H myserver -U myuser -P mypass -q "select count(*) from mytable" -r "632" -w 2 -c 5
Send any questions regarding this utility to [email protected] or [email protected].
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
dbsaust
Posts: 76
Joined: Mon Dec 06, 2010 12:41 am

Re: Issues with MS SQL checks

Post by dbsaust »

Sorry, my bad for not working this out. I've updated and now working OK.

A warning alert with a return of "Query results matched" made me think it was something else. Maybe a return of "Warning - Query time-out occurred" would be more specific!
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: Issues with MS SQL checks

Post by slansing »

Ah! Okay, we will close this for now.
Locked