WMI Query filtering

Started by LeapfrogIT, November 17, 2008, 04:51:30 PM

Previous topic - Next topic

LeapfrogIT


Is it possible to use more complex wmi queries ad DCI's ?

For example something like

WMI.Query(root\CIMV2,select * FROM Win32_Service WHERE Name = 'ApacheTomcatApplicationServer',status)

Thankyou to any assistance some can provide


kindest regards


Victor Kirhenshtein

Hi!

Yes, it shoulod be possible. WMI subagent will accept any valid WMI queries.

Best regards,
Victor

LeapfrogIT

excellent :) that certainly opens up the queries I can run.


Now I know that I can go back degugging my WQL queries themselfs will add them to Toads Pinned list once I have a decent number of queries made up. Like with most of these things it will probably be the first querie that takes some time afterthat I should be able to duplicate the priciples nice and easly :)



LeapfrogIT

Sorry to be a bother , but I am really having a hard time getting this to work for me

As an example , I am trying to run

WMI.Query(root\CIMV2,select * FROM Win32_Service WHERE Name = 'WsusService', Status)

When I use scriptomatic or WMI Query tester it works fine giving the resullt that I expect  however Netxms Console tells me that it's an unsupported DCI , and when I try and run it via nxget i get an internal server 500 error .

Could this possibly be an extention of the current WMI.nsm bug for 2.22 ?  I was seing similar signs happening when I first installed 2.22 without upgrading the wmi part of the agent to the 2.23 rc release

Victor Kirhenshtein

Hi!

You should enclose query string in double quotes, because otherwise NetXMS agent incorrectly interprets single quotes within query. Correct syntax for parameter will be following:

WMI.Query(root\CIMV2,"select * FROM Win32_Service WHERE Name = 'WsusService'", Status)

Best regards,
Victor

LeapfrogIT

That worked perfectly thankyou victor :)

Anth0ny

How can i use it at command prompt (for testing purposes)?

Is it right?

nxget host_ip WMI.Query(root\CIMV2,"select * FROM Win32_Service WHERE Name = 'WsusService'", Status)

Victor Kirhenshtein

Correct command line on Windows:

nxget host_ip "WMI.Query(root\CIMV2,\"select * FROM Win32_Service WHERE Name = 'WsusService'\", Status)"

on UNIX:
nxget host_ip "WMI.Query(root\\CIMV2,\"select * FROM Win32_Service WHERE Name = 'WsusService'\", Status)"

Best regards,
Victor

Anth0ny