Grab our RSS feeds Follow us on Twitter Join our Facebook Group Connect with us on LinkedIn
myITforum.com, Powered by You.
you are not logged in

Articles

Newslinks

Links

Downloads

Site Services

Community Forums

Discussion Lists

Article Search

Newsletter

Web Blogs

FAQs

Live Support

myITforum TV

Take a Poll

Monthly Drawing

myITforum Network

User Group Directory

Our Partners

About Us

Register

Login

BRONZE PARTNER:

BRONZE PARTNER:



Industry News:




  Home : Articles : MOM print | email | | Forums |   print | email | | Blogs |   print | email | | Wiki |   print | email | | FAQs |   print | email | Article Search  
Ping script for Microsoft Operations Manager 2005


Bookmark and Share

By: Andy Dominey
Posted On: 9/30/2005

The following script runs a ping from a MOM agent to a network device or unmanaged system and generates an alert into the MOM data stream if the device does not respond.

'------------------------------------------------------

Option Explicit

' -- Define variables
Dim wshShell
Dim objFileSystem
Dim strPingDest
Dim objLogFile
Dim strLogData
Dim fOpenLog
Dim objMOMEvent

' -- Create a Shell object
Set wshShell = CreateObject("WScript.Shell")

' -- Create a FileSystemObject
Set objFileSystem = CreateObject("Scripting.FileSystemObject")

' -- Define ping destination
strPingDest = "192.168.32.11"

' -- Define log file location
objLogFile = "C:\PingLog.txt"

' -- Run the ping and pipe output to the log file
wshShell.Run "cmd.exe /c ping " & strPingDest & " > " & objLogFile,,true

' -- Open log file and read line 6
Set fOpenLog = objFileSystem.OpenTextFile(objLogFile, 1)
fOpenLog.ReadLine
fOpenLog.ReadLine
fOpenLog.ReadLine
fOpenLog.ReadLine
fOpenLog.ReadLine
strLogData = fOpenLog.ReadLine

' -- Generate alert if the 6th line is Request timed out.
Select Case strLogData
Case "Request timed out." & vbCR

' -- Create error event to be submitted to MOM server (Ping Test failed)
Set objMOMEvent = ScriptContext.CreateEvent()
objMOMEvent.EventSource = "MOM Ping Monitor Tool"
objMOMEvent.EventNumber = 10002
objMOMEvent.EventType = 1
objMOMEvent.Message = "Ping Test to " & strPingDest & " failed. Please investigate."

'-- Submit Created Error Event to MOM data stream
ScriptContext.Submit(objMOMEvent)

Case Else

'-- Create information event and submit to MOM data stream for tracking purposes
Set objMOMEvent = ScriptContext.CreateEvent()
objMOMEvent.EventSource = "MOM Ping Monitor Tool"
objMOMEvent.EventNumber = 10001
objMOMEvent.EventType = 4
objMOMEvent.Message = "Ping Test to " & strPingDest & " succeeded. No action necessary."

'-- Submit Created Error Event to MOM data stream
ScriptContext.Submit(objMOMEvent)

End Select

' -- Reset all variables
Set wshShell = Nothing
Set objFileSystem = Nothing
Set strPingDest = Nothing
Set objLogFile = Nothing
Set strLogData = Nothing
Set fOpenLog = Nothing
Set objMOMEvent = Nothing

'-------------------------------------------------------

All you need to do to use this script is to change the ping destination, create a new script in MOM and copy and paste the code.
You can then create an Event Rule to run the script on a timed basis and finally configure event rules to pick the events out from the MOM data stream and raise an alert as necessary.

To check the MOM data stream for the alerts, go to the Events view in the Operator Console.

Please mail me on andydominey@f2s.com if you need any additional information or assistance.

  myITforum.com ©2010 | Legal | Privacy