Page 1 of 1

How to set Invert Warning and Critical values

Posted: Fri Mar 22, 2019 8:38 am
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

Re: How to set Invert Warning and Critical values

Posted: Fri Mar 22, 2019 10:01 am
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.

Re: How to set Invert Warning and Critical values

Posted: Fri Mar 22, 2019 1:46 pm
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

Re: How to set Invert Warning and Critical values

Posted: Fri Mar 22, 2019 2:02 pm
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.

Re: How to set Invert Warning and Critical values

Posted: Sat Mar 23, 2019 9:34 am
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

Re: How to set Invert Warning and Critical values

Posted: Mon Mar 25, 2019 7:51 am
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"

Re: How to set Invert Warning and Critical values

Posted: Mon Mar 25, 2019 3:53 pm
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.

Re: How to set Invert Warning and Critical values

Posted: Mon Mar 25, 2019 4:47 pm
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"

Re: How to set Invert Warning and Critical values

Posted: Tue Apr 02, 2019 1:38 pm
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