Announcement

Collapse
No announcement yet.

server status

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • server status

    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:

    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
    
    '-------------------------------------------------------
    thanks a lot

  • #2
    Re: server status

    Instead of using wshShell.Run cmd /c ping..., you can also use:
    Set oExec = wshShell.Exec(cmd /c ping..... )
    sResultsPingServer = oExec.stdOut.ReadAll

    that way you dont have to write the results to a text-file, and then open it for reading. You'll have the results in the variable sResultsPingServer.

    Ping the server first then if it is not pingable, ping the router. Each time set a boolean result.

    This is the idea:
    If boolean('ping router') And not boolean('ping server') then
    ......
    End If


    \Rems
    Last edited by Rems; 24th September 2007, 15:50.

    This posting is provided "AS IS" with no warranties, and confers no rights.

    __________________

    ** Remember to give credit where credit's due **
    and leave Reputation Points for meaningful posts

    Comment

    Working...
    X