SCOM-script to ping one IP
A while ago I wrote a script to ping some IP from MOM2005.
Made a small update to SCOM.
Go to OM-Console -> Authoring -> Management Pack Objects -> Rules -> New… -> Collection Rules \ Probe based \ Script (perfomance)
A few next-clicks and then paste the script…
Parameters
1: IP-adress to ping- 192.168.0.10
2: Timeout (ms) – 1000
3: Buffertsize – 4096
Example: 192.168.0.10 1000 4096
Perfomance mapper
Object = PingRoundtrip
Counter = $Data/Property[@Name='serverToPingFrom']$
Instance = $Data/Property[@Name='serverToPingIP']$
Value = $Data/Property[@Name='Roundtrip']$
'-------------------------------------------------------------------------------------
' Script to write perf-data from a ping against some IP
'
' Rikard Rönnkvist / snowland.se / 2007-10-23
'-------------------------------------------------------------------------------------
' --- Set up variables and objects
Option Explicit
Dim serverToPingIP, serverToPingFrom, pingTimeout, pingBufferSize, perfData
Dim oArgs, oPing, oStatus, oAPI, oBag
' --- Get parameters
Set oArgs = WScript.Arguments
serverToPingIP = oArgs.Item(0)
pingTimeout = oArgs.Item(1)
pingBufferSize = oArgs.Item(2)
Set oArgs = Nothing
' --- Get computername
Set oArgs = WScript.CreateObject("WScript.Network")
serverToPingFrom = oArgs.ComputerName
Set oArgs = Nothing
' --- Ping the host
Set oPing = GetObject("winmgmts:{impersonationLevel=impersonate}")._
ExecQuery("select * from Win32_PingStatus where address = '" & serverToPingIP & "' and BufferSize=" & pingBufferSize & " And Timeout=" & pingTimeout)
For Each oStatus in oPing
If IsNull(oStatus.StatusCode) Or oStatus.StatusCode<>0 Then
perfData = pingTimeout ' Got no answer. logging maxTime
Else
perfData = oStatus.ResponseTime ' Got answer, logging responsetime
End If
Next
Set oPing = Nothing
Set oStatus = Nothing
' --- Create properies in SCOM
Set oAPI = CreateObject("MOM.ScriptAPI")
Set oBag = oAPI.CreatePropertyBag()
oBag.AddValue "serverToPingIP", serverToPingIP
oBag.AddValue "serverToPingFrom", serverToPingFrom
oBag.AddValue "pingTimeout", pingTimeout
oBag.AddValue "pingBufferSize", pingBufferSize
oBag.AddValue "Roundtrip", perfData
oAPI.AddItem(oBag)
oAPI.ReturnItems
Set oAPI = Nothing
Set oBag = Nothing





2007-10-23 15:57
Nice…
Det var nog performancemappern jag missade på.
2007-10-24 08:59
[...] a post yesterday there was a script to ping some node, the script uses WMI to ping. Did some testing, and… Why [...]
2009-03-04 10:35
May you instruct me to see the result? performance view? many thanks!
2009-11-20 20:23
Hi there, thanks for sharing this script. My question is how I can get the results of this script. Should I spect an alert? I set a very low timeout value so I can test it, but I get no alerts. Maybe I’m not using the parameters in the right manner. First, I put them in the filename, like “Script.vbs 10.10.10.1 30 4096″. Didn’t work (I got an alert saying there was an error executing the script). How should I do it? Thanks in advance!
2009-11-21 07:40
You will get the result from the script in a “propertybag”, then you use that bag to create an alert or performance-data.
The script does not generate any alert or performance by itself, so if you don’t use the propertybag nothing will happen.