Page 1 of 1
WMI text strings
Posted: Tue Dec 03, 2013 4:30 pm
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.
Re: WMI text strings
Posted: Tue Dec 03, 2013 5:30 pm
by lmiltchev
Can you show us the exact command that you are running from the CLI and the output of it?
Re: WMI text strings
Posted: Fri Dec 06, 2013 9:13 am
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.)
Re: WMI text strings
Posted: Fri Dec 06, 2013 9:46 am
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.
Re: WMI text strings
Posted: Tue Dec 10, 2013 11:05 am
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.
Re: WMI text strings
Posted: Tue Dec 10, 2013 11:07 am
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.
Re: WMI text strings
Posted: Tue Dec 10, 2013 11:48 am
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.