Problem with syntax with check_wmi and win32_PingStatus


#1

Hi all, i have a syntax problem. I work with NSClient++ 0.4.4.19.

I want to monitor a network interface which is not on the same Network of my Nagios Server. To do this, i try to execute this command :

check_nrpe -H LAN-IP -p 5666 -c check_wmi -a "query=select StatusCode from win32_pingstatus where Address=‘NOT-LAN-IP’" It’s return a 0 which is OK.

If i do this command again with a wrong IP it’s return a 1120 but it’s always an OK Status. So i had the following syntax at the end: “critical=StatusCode Not like ‘0’”

The command is:

check_nrpe -H LAN-IP -p 5666 -c check_wmi -a “query=select StatusCode from win32_pingstatus where Address=‘NOT-LAN-IP’” “critical=StatusCode Not like ‘0’”

Now, le Status is OK again.

I try:

check_nrpe -H LAN-IP -p 5666 -c check_wmi -a “query=select StatusCode from win32_pingstatus where Address=‘NOT-LAN-IP’” “critical=StatusCode >0”.

And it works!

2 questions:

  1. I would prefer to write something like "if statuscode is different of 0 then it’s a CRITICAL state.

  2. How changing the Output because i have a “0”

I don’t understand the syntax.

Could you please help me.


#2

1, not sure but does “critical=StatusCode != 0” or “critical=StatusCode ne 0” not work? 2, the syntax can be customized by two arguments: “top-syntax=%(list)” “detail-syntax=My status is: %(StatusCode) for %(Address)”

(you need to select Address as well for the latter to work)


#3

Thanks for your answer.

About customized output, it works perfectly. But the return code is OK whatever the IP.

Here is my command:

check_nrpe -H $HOSTADDRESS$ -p 5666 -c check_wmi -a “query=select statuscode from win32_pingstatus where Address=’$ARG1$’” “critical=StatusCode !=0” “detail-syntax=My status is: %(StatusCode) for $ARG1$”

With a bad IP i have this Status Information : Status Information:My status is: 11010 for 10.56.11.81

11010 means Request Timed Out.

But Status remains OK.


#4

Im using 0.5.0 here but it seems to work fine for me:

check_wmi "query=select statuscode, Address from win32_pingstatus where Address='192.168.0.201'" "critical=StatusCode !=0" "detail-syntax=My status is: %(StatusCode) for %(Address)"
L        cli OK: My status is: 0 for 192.168.0.201
L        cli  Performance data: 'StatusCode'=0;0;0
check_wmi "query=select statuscode, Address from win32_pingstatus where Address='192.168.0.201'" "critical=StatusCode !=0" "detail-syntax=My status is: %(StatusCode) for %(Address)" show-all
L        cli OK: My status is: 0 for 192.168.0.201
L        cli  Performance data: 'StatusCode'=0;0;0
check_wmi "query=select statuscode, Address from win32_pingstatus where Address='192.168.0.3'" "critical=StatusCode !=0" "detail-syntax=My status is: %(StatusCode) for %(Address)" show-all
L        cli CRITICAL: critical(My status is: 11003 for 192.168.0.3)
L        cli  Performance data: 'StatusCode'=11003;0;0
check_wmi "query=select statuscode, Address from win32_pingstatus where Address='192.168.0.5'" "critical=StatusCode !=0" "detail-syntax=My status is: %(StatusCode) for %(Address)" show-all
L        cli CRITICAL: critical(My status is: 11003 for 192.168.0.5)
L        cli  Performance data: 'StatusCode'=11003;0;0

#5

I’m trying to execute command on localhost:

C:\Program Files\NSClient++>nscp client -q check_wmi “query=select statuscode, Address from win32_pingstatus where Address=‘10.56.11.41’” “critical=StatusCode !=0” “detail-syntax=My status is: %(StatusCode) for %(Address)”

This is the output:

My status is: 11003 for 10.56.11.41|‘StatusCode’=11003;0;0

How can i see the Exit Code (OK or CRITICAL) ?


#6

Do you mean from command line?

echo %ERRORLEVEL%

#7

No, i understood. With NRPE, i received StatusCode value. I’ve just write a script to manage WMI PingStatus StatusCode. It works. Many thanks


#8

I’m getting Unknown command(s): check_wmi output

NSClinet version : 0.5

Systax : ./check_nrpe -H 10.122.33.96 -p 5666 -c check_wmi -a check_wmi “query=select statuscode, Address from win32_pingstatus where Address=‘10.122.33.96’” “critical=StatusCode !=0” “detail-syntax=My status is: %(StatusCode) for %(Address)”


#9

Have you enabled the CheckWMi module?

[/modules]
; CheckWMI - Check status via WMI
CheckWMI = enabled