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.
WMI text strings
Re: WMI text strings
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!
Re: WMI text strings
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.)
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.)
Re: WMI text strings
What lmiltchev was asking is if you can run the actual command from the command line, something similar to the following:
If you would not include the backslashes in the command line, then don't include them when you run it.
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'"
Former Nagios employee
Re: WMI text strings
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.
OK: Everything seems fine.
Re: WMI text strings
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.
Re: WMI text strings
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!