How to set Invert Warning and Critical values

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
dlukinski
Posts: 1130
Joined: Tue Oct 06, 2015 9:42 am

How to set Invert Warning and Critical values

Post by dlukinski »

Hello Nagios Support team

Please advise how to set the invert Warning and Critical Values?

In this case, for SQL Query to interpret integer results as follows:

SELECT
[cntr_value] as 'Page life expectancy' FROM sys.dm_os_performance_counters
WHERE [object_name] LIKE '%Manager%'
AND [counter_name] = 'Page life expectancy'

BELOW 100 - produce CRITICAL

In between 300 and 100 - Produce WARNING

ABOVE 300 - OK
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: How to set Invert Warning and Critical values

Post by lmiltchev »

I would assume you are using the check_mssql plugin. You could set your thresholds as such:

Code: Select all

-W 300: -C 100
From the plugin's usage:

Code: Select all

Note: Warning and critical threshold values should be formatted via the
Nagios Plugin guidelines. See guidelines here:
https://nagios-plugins.org/doc/guidelines.html#THRESHOLDFORMAT

Examples:   10          Alerts if value is > 10
            30:         Alerts if value < 30
            ~:30        Alerts if value > 30
            30:100      Alerts if 30 > value > 100
            @10:200     Alerts if 30 >= value <= 100
            @10         Alerts if value = 10
Hope this helps.
Be sure to check out our Knowledgebase for helpful articles and solutions!
dlukinski
Posts: 1130
Joined: Tue Oct 06, 2015 9:42 am

Re: How to set Invert Warning and Critical values

Post by dlukinski »

lmiltchev wrote:I would assume you are using the check_mssql plugin. You could set your thresholds as such:

Code: Select all

-W 300: -C 100
From the plugin's usage:

Code: Select all

Note: Warning and critical threshold values should be formatted via the
Nagios Plugin guidelines. See guidelines here:
https://nagios-plugins.org/doc/guidelines.html#THRESHOLDFORMAT

Examples:   10          Alerts if value is > 10
            30:         Alerts if value < 30
            ~:30        Alerts if value > 30
            30:100      Alerts if 30 > value > 100
            @10:200     Alerts if 30 >= value <= 100
            @10         Alerts if value = 10
Hope this helps.
Hi

The builtin Wizard creates this Query command:

--username "secret" --password "shadow" --database Mydb --port 1435 --query "SELECT+%0D%0A%5Bcntr_value%5D+as+%27Page+life+expectancy%27+FROM+sys.dm_os_performance_counters%0D%0AWHERE+%5Bobject_name%5D+LIKE+%27%25Manager%25%27%0D%0AAND+%5Bcounter_name%5D+%3D+%27Page+life+expectancy%27%0D%0A" --decode --warning 50 --critical 200 --querywarning 300 --querycritical :100 --result "Expected result"

CRITICAL: Query result 13404 was higher than Query critical threshold 100:

this approach have worked
Last edited by dlukinski on Fri Mar 22, 2019 2:16 pm, edited 1 time in total.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: How to set Invert Warning and Critical values

Post by ssax »

Please try this one:

Code: Select all

--username "secret" --password "shadow" --database Mydb --port 1435 --query "SELECT+%0D%0A%5Bcntr_value%5D+as+%27Page+life+expectancy%27+FROM+sys.dm_os_performance_counters%0D%0AWHERE+%5Bobject_name%5D+LIKE+%27%25Manager%25%27%0D%0AAND+%5Bcounter_name%5D+%3D+%27Page+life+expectancy%27%0D%0A" --decode --warning 50 --critical 200 --querywarning 100:300 --querycritical 100: --result "Expected result"
Let us know the results.
dlukinski
Posts: 1130
Joined: Tue Oct 06, 2015 9:42 am

Re: How to set Invert Warning and Critical values

Post by dlukinski »

ssax wrote:Please try this one:

Code: Select all

--username "secret" --password "shadow" --database Mydb --port 1435 --query "SELECT+%0D%0A%5Bcntr_value%5D+as+%27Page+life+expectancy%27+FROM+sys.dm_os_performance_counters%0D%0AWHERE+%5Bobject_name%5D+LIKE+%27%25Manager%25%27%0D%0AAND+%5Bcounter_name%5D+%3D+%27Page+life+expectancy%27%0D%0A" --decode --warning 50 --critical 200 --querywarning 100:300 --querycritical 100: --result "Expected result"
Let us know the results.
WARNING: Query result 2751 was higher than Query warning threshold 100:300.
WARNING portion does to work.. had to be OK
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: How to set Invert Warning and Critical values

Post by scottwilkerson »

Actually, there was a mistake, should have been

Code: Select all

--username "secret" --password "shadow" --database Mydb --port 1435 --query "SELECT+%0D%0A%5Bcntr_value%5D+as+%27Page+life+expectancy%27+FROM+sys.dm_os_performance_counters%0D%0AWHERE+%5Bobject_name%5D+LIKE+%27%25Manager%25%27%0D%0AAND+%5Bcounter_name%5D+%3D+%27Page+life+expectancy%27%0D%0A" --decode --warning 50 --critical 200 --querywarning 100:300 --querycritical ~:100 --result "Expected result"
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
dlukinski
Posts: 1130
Joined: Tue Oct 06, 2015 9:42 am

Re: How to set Invert Warning and Critical values

Post by dlukinski »

scottwilkerson wrote:Actually, there was a mistake, should have been

Code: Select all

--username "secret" --password "shadow" --database Mydb --port 1435 --query "SELECT+%0D%0A%5Bcntr_value%5D+as+%27Page+life+expectancy%27+FROM+sys.dm_os_performance_counters%0D%0AWHERE+%5Bobject_name%5D+LIKE+%27%25Manager%25%27%0D%0AAND+%5Bcounter_name%5D+%3D+%27Page+life+expectancy%27%0D%0A" --decode --warning 50 --critical 200 --querywarning 100:300 --querycritical ~:100 --result "Expected result"

This one actually did not work at all:
fikc-m4cldb01s2.res.kcg.globalView service status details for this host MSSQL Query - Count of Page Life expectancyThis service is flappingNotifications are disabled for this service Critical 4m 31s 5/5 2019-03-25 20:48:35 CRITICAL: Query result 1389 was higher than Query critical threshold ~:100.
fikc-m4dbq01s1.res.kcg.globalView service status details for this host MSSQL Query - Count of Page Life expectancyNotifications are disabled for this service Critical 6m 11s 5/5 2019-03-25 20:51:54 CRITICAL: Query result 5024 was higher than Query critical threshold ~:100.
fikc-m4dbq01s2.res.kcg.globalView service status details for this host MSSQL Query - Count of Page Life expectancyNotifications are disabled for this service Critical 3m 45s 5/5 2019-03-25 20:49:21 CRITICAL: Query result 4693 was higher than Query critical threshold ~:100.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: How to set Invert Warning and Critical values

Post by scottwilkerson »

Sorry about that, I misread your criteria, try

Code: Select all

--username "secret" --password "shadow" --database Mydb --port 1435 --query "SELECT+%0D%0A%5Bcntr_value%5D+as+%27Page+life+expectancy%27+FROM+sys.dm_os_performance_counters%0D%0AWHERE+%5Bobject_name%5D+LIKE+%27%25Manager%25%27%0D%0AAND+%5Bcounter_name%5D+%3D+%27Page+life+expectancy%27%0D%0A" --decode --warning 50 --critical 200 --querywarning @100:300 --querycritical 100: --result "Expected result"
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
dlukinski
Posts: 1130
Joined: Tue Oct 06, 2015 9:42 am

Re: How to set Invert Warning and Critical values

Post by dlukinski »

scottwilkerson wrote:Sorry about that, I misread your criteria, try

Code: Select all

--username "secret" --password "shadow" --database Mydb --port 1435 --query "SELECT+%0D%0A%5Bcntr_value%5D+as+%27Page+life+expectancy%27+FROM+sys.dm_os_performance_counters%0D%0AWHERE+%5Bobject_name%5D+LIKE+%27%25Manager%25%27%0D%0AAND+%5Bcounter_name%5D+%3D+%27Page+life+expectancy%27%0D%0A" --decode --warning 50 --critical 200 --querywarning @100:300 --querycritical 100: --result "Expected result"

This worked

Thank you,
Please close the case
Locked