Page 1 of 1

Nagios XI mssql query wizard

Posted: Thu Jan 05, 2017 4:38 pm
by Naveed
Nagios Team,

I want to monitor mssql queries with nagios xi mssql query wizard.

I have executed query on server which return the value in interger, I have set querywarning and querycritical thresholds as well but query result on nagios board is showing in terms of execution time.

On server, query return 4325 something value, I have set 50 and 200 as warning and critical etc but it did not work according to set thresholds.

Can you please see the guide me what if I am missing something.

all screenshots are attached for verification.

Thanks

Re: Nagios XI mssql query wizard

Posted: Thu Jan 05, 2017 5:06 pm
by rkennedy
Please show us the service definition for 'System info query'. It looks like you have a duration query running and not a custom query.

Re: Nagios XI mssql query wizard

Posted: Thu Jan 05, 2017 5:13 pm
by lmiltchev
Can you show us the actual check run from the command line along with the output of it? What happens when you include "--warning" & "--critical" thresholds?

Example:
[root@main-nagios-xi libexec]# ./check_mssql -H x.x.x.x --username <username> --password "<password>" --database master --instance <instance> --query "SELECT+COUNT%28%2A%29+FROM+sys.sysperfinfo" --decode --querywarning 50 --querycritical 200
OK: Query duration=0.001232 seconds.|query_duration=0.001232s;; 'computed'=1008;50;200
But notice the change in the output below:
[root@main-nagios-xi libexec]# ./check_mssql -H x.x.x.x --username <username> --password "<password>" --database master --instance <instance> --query "SELECT+COUNT%28%2A%29+FROM+sys.sysperfinfo" --decode --warning 1 --critical 2 --querywarning 50 --querycritical 200
CRITICAL: Query result 1008 was higher than query critcal threshold.|query_duration=0.000657s;1;2 'computed'=1008;50;200

Re: Nagios XI mssql query wizard

Posted: Thu Jan 05, 2017 5:26 pm
by Naveed
Thank you for your support.

My query is as follows:

check_xi_mssql_query!--username abcd --password "123456" --database master --port 1433 --query "SELECT+COUNT%28%2A%29+FROM+sys.sysperfinfo" --result "" --decode --querywarning 50 --querycritical 200

Your suggested query execution from command line

./check_mssql -H 1.2.3.4 --username abcd --password "123456" --database master --query "SELECT+COUNT%28%2A%29+FROM+sys.sysperfinfo" --decode --warning 1 --critical 2 --querywarning 50 --querycritical 200
CRITICAL: Query result 4362 was higher than query critcal threshold.|query_duration=0.063458s;1;2 'computed'=4362;50;200

I have modified accordingly, its been working fine...

My questions are as follows:

1- Few queries return result in tabular form? How we can monitor them in terms of expected result?

2-Can I monitor the query time execution, if my query takes more than 15 minutes, it should generate alerts?

Kindly answer these.

Thank you!

Re: Nagios XI mssql query wizard

Posted: Thu Jan 05, 2017 5:29 pm
by Naveed
@rkennedy

Service definition screenshot is attached.

Re: Nagios XI mssql query wizard

Posted: Fri Jan 06, 2017 2:39 pm
by Naveed
Support team

Please help!
Its an urgent work need to done.

Re: Nagios XI mssql query wizard

Posted: Fri Jan 06, 2017 3:04 pm
by mcapra
Naveed wrote: Few queries return result in tabular form? How we can monitor them in terms of expected result?
You could use the -r parameter:

Code: Select all

 -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.
Naveed wrote: Can I monitor the query time execution, if my query takes more than 15 minutes, it should generate alerts?
You should be able to use -w and -c for this:

Code: Select all

 -w, --warning
    Warning threshold in seconds on duration of check
    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
    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.
But if the query is taking longer than the scheduled check, you could get overlapping results. There are also explicit timeouts for checks configured in Nagios itself (I believe 1 minute by default). This is explained in this document:
https://assets.nagios.com/downloads/nag ... gmain.html

Refer to the "Service Check Timeout" section.

Re: Nagios XI mssql query wizard

Posted: Fri Jan 06, 2017 3:09 pm
by ssax
In addition to mcapra's post, if the query takes longer than a few minutes I would probably look at setting it up as a passive check, that is a very long time for it to be consuming resources and would likely hit the default timeouts in your nagios.cfg unless you bump them up as well.

lmiltchev's post above shows you how to check the duration as well.


Thank you

Re: Nagios XI mssql query wizard

Posted: Fri Jan 06, 2017 3:13 pm
by Naveed
Ok, I will implement these now and update you about the progress...

Can you please tell me that how to change duration query running and not a custom query?

Please show us the service definition for 'System info query'. It looks like you have a duration query running and not a custom query.

Thanks

Re: Nagios XI mssql query wizard

Posted: Mon Jan 09, 2017 10:00 am
by avandemore
Continuing in ticket, locking thread.