SCOM WMI Ping instead of script

In a post yesterday there was a script to ping some node, the script uses WMI to ping.
Did some testing, and… Why did I write a script when you can use the built in WMI-support to do the same thing?

Why (not) a script?
OK, there is one thing that (afaik) you can’t do with WMI-queries… JOIN.
I would like to do some sort of query that puts out CSName from Win32_OperatingSystem along with StatusCode and ResponseTime from Win32_PingStatus, but… I can’t figure out how.

Ok?
Since you have the performance mapper to point out Object, Counter and so on you can’t make a simple WMI-query that allows you to get the name of the agent. And if you can’t get that to work you will get a mix of multiple agents performance-data on one counter…
The script returns serverToPingFrom, thats what I’m missing.

The solution
When I first looked at it… I only looked at the WMI-query and didn’t think about what SCOM and the performance mapper can do.
The solution is to name the Counter with use of some data that SCOM already know.

Yada yada yada… on to the script!
Go to OM-Console -> Authoring -> Management Pack Objects -> Rules -> New… -> Collection Rules \ Performance based \ WMI performance
A few next-clicks and then paste the following:

WMI Namespace
root\cimv2

Query

select * from Win32_PingStatus where address = '192.168.0.10' and BufferSize=4096 And Timeout=1000

Perfomance mapper
Object = WMIPingRoundtrip
Counter = $Target/Property[Type=”System!System.Entity”]/DisplayName$
Instance = $Data/Property[@Name=’Address’]$
Value = $Data/Property[@Name=’ResponseTime’]$

2 comments

  1. Brian

    I am trying to figure out a way in SCOM 2007 to create a rule to gather the ping response time. I saw your post and gave it a shot.

    I created the rule (I changed the ’ to ‘ ) anyway I can’t get it to run, as it doesn’t show up at all in the performance view of the objects in that group.

    Also, is there a way to use the objects IP in the query rather then hardcoding the IP. That way you can use one rule for all devices in the group?

    Here is what I have:

    SELECT * FROM Win32_PingStatus WHERE address = ‘172.16.2.1’ AND BufferSize=4096 AND Timeout=1000

    WMIPingRoundtrip
    $Target/Property[Type=”System!System.Entity”]/DisplayName$
    $Data/Property[@Name=’Address’]$
    $Data/Property[@Name=’ResponseTime’]$

  2. riro

    The way I use the script is to ping from the agent to the SCOM-server.

    But if you need to run a ping against every (for example) SNMP-node you need some more coding.
    Shouldn’t be that hard to do in VBScript…