server status

Home Forums Scripting General Scripting server status

Viewing 1 post (of 1 total)
  • Author
    Posts
  • Avatar
    chance
    Member
    #127917

    Hi there,

    situation is like this:
    I am using MOM 2005 and i want to monitor Servers (plain monitoring – alive – not alive). I used script from bellow to create one in MOM 2005, and than attached it to Event Rule and than created alert rule. Thats fine, but i need a bit complex solution.

    I need to monitor two things (server and its router), and i need alert only in case when server is not reachable and router is. To make it more clear:
    Router | Server


    up | up
    up | down < --- ALERT
    down | up
    down | down

    Anyone can help me modify this script so this can work? I will try to do it, but before that, maybe some guru around here can do it in a sec…

    Original Script:

    ‘——————————————————

    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 = “SERVER IP ADDRESS x.x.x.x”

    ‘ — 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

    ‘——————————————————-[/CODE]

    thanks a lot[CODE]’



    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 = “SERVER IP ADDRESS x.x.x.x”

    ‘ — 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


    [/CODE]

    thanks a lot

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.