WMI text strings

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
mcnabbm
Posts: 5
Joined: Wed Sep 25, 2013 8:32 am

WMI text strings

Post by mcnabbm »

I am using WMI to do checks on our windows servers for specific processes such as "BlackBerry Dispatcher". I have not been able to get the syntax correct in the where clause to only look for the one service. I would also like to see the output but don't get anything. Please help.

"Query=Select Displayname, Started, StartMode, State, Status from Win32_BaseService Where Started=0"

I want it to read: Where Displayname = 'BlackBerry Dispatcher' but it doesn't like text. I used \ and double ' ' (single quotes) which was alluded to on a website but no luck.


Running XI Enterprise.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: WMI text strings

Post by lmiltchev »

Can you show us the exact command that you are running from the CLI and the output of it?
Be sure to check out our Knowledgebase for helpful articles and solutions!
mcnabbm
Posts: 5
Joined: Wed Sep 25, 2013 8:32 am

Re: WMI text strings

Post by mcnabbm »

COMMAND: /usr/local/nagios/libexec/check_nrpe -H besp1s1 -t 30 -c CheckWMIValue -a "Query=Select Displayname, Started, StartMode, State, Status from Win32_BaseService Where Started=0 and Displayname=\'BlackBerry Dispatcher\'"
OUTPUT: WMIQuery failed: ExecQuery of 'Select Displayname, Started, StartMode, State, Status from Win32_BaseService Where Started=0 and Displayname=\'BlackBerry Dispatcher\'' failed: WinMgmt - The query was not syntactically valid.)
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: WMI text strings

Post by tmcdonald »

What lmiltchev was asking is if you can run the actual command from the command line, something similar to the following:

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H besp1s1 -t 30 -c CheckWMIValue -a "Query=Select Displayname, Started, StartMode, State, Status from Win32_BaseService Where Started=0 and Displayname='BlackBerry Dispatcher'"
If you would not include the backslashes in the command line, then don't include them when you run it.
Former Nagios employee
mcnabbm
Posts: 5
Joined: Wed Sep 25, 2013 8:32 am

Re: WMI text strings

Post by mcnabbm »

PROD [andersonr@nagios-p1-s1 ~]$ /usr/local/nagios/libexec/check_nrpe -H besp1s1 -t 30 -c CheckWMIValue -a "Query=Select Displayname, Started, StartMode, State, Status from Win32_BaseService Where Started=0 and Displayname='BlackBerry Dispatcher'"
OK: Everything seems fine.
mcnabbm
Posts: 5
Joined: Wed Sep 25, 2013 8:32 am

Re: WMI text strings

Post by mcnabbm »

I think the backslashes are inserted through the XI interface. I had my SA run the command from the command line and it seems to work. It just doesn't have the right syntax for the XI front-end to pass it correctly.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: WMI text strings

Post by lmiltchev »

I would recommend always to test your commands from the CLI. Testing them from the CCM works most of the time but not always, because of the escaping issues, and the fact that they are run as apache user. The test button in the CCM is placed for convenience. It's not meant to replace testing from the CLI.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked