Script das mich informiert wenn ein Server offline ist?

  • VBScript

Es gibt 12 Antworten in diesem Thema. Der letzte Beitrag () ist von axi92.

    Script das mich informiert wenn ein Server offline ist?

    Kann man ein Script laufen lassen das alle Minuten einen oder mehrere Server prüft ob diese online sind wenn nicht kommt eine Meldung das der betreffende Server ofline ist.

    Derzeit habe ich das:

    VB.NET-Quellcode

    1. On Error Resume Next
    2. 'Use IP address or computer name
    3. strComputer = "INTS"
    4. strPingStatus = PingStatus(strComputer)
    5. If strPingStatus = "Success" Then
    6. Wscript.Echo "Success pinging " & strComputer
    7. Else
    8. Wscript.Echo "Failure pinging " & strComputer & ": " & strPingStatus
    9. End If
    10. '*****************************************************************************
    11. Function PingStatus(strComputer)
    12. On Error Resume Next
    13. strWorkstation = "."
    14. Set objWMIService = GetObject("winmgmts:" _
    15. & "{impersonationLevel=impersonate}!\\" & strWorkstation & "\root\cimv2")
    16. Set colPings = objWMIService.ExecQuery _
    17. ("SELECT * FROM Win32_PingStatus WHERE Address = '" & strComputer & "'")
    18. For Each objPing in colPings
    19. Select Case objPing.StatusCode
    20. Case 0 PingStatus = "Success"
    21. Case 11001 PingStatus = "Status code 11001 - Buffer Too Small"
    22. Case 11002 PingStatus = "Status code 11002 - Destination Net Unreachable"
    23. Case 11003 PingStatus = "Status code 11003 - Destination Host Unreachable"
    24. Case 11004 PingStatus = _
    25. "Status code 11004 - Destination Protocol Unreachable"
    26. Case 11005 PingStatus = "Status code 11005 - Destination Port Unreachable"
    27. Case 11006 PingStatus = "Status code 11006 - No Resources"
    28. Case 11007 PingStatus = "Status code 11007 - Bad Option"
    29. Case 11008 PingStatus = "Status code 11008 - Hardware Error"
    30. Case 11009 PingStatus = "Status code 11009 - Packet Too Big"
    31. Case 11010 PingStatus = "Status code 11010 - Request Timed Out"
    32. Case 11011 PingStatus = "Status code 11011 - Bad Request"
    33. Case 11012 PingStatus = "Status code 11012 - Bad Route"
    34. Case 11013 PingStatus = "Status code 11013 - TimeToLive Expired Transit"
    35. Case 11014 PingStatus = _
    36. "Status code 11014 - TimeToLive Expired Reassembly"
    37. Case 11015 PingStatus = "Status code 11015 - Parameter Problem"
    38. Case 11016 PingStatus = "Status code 11016 - Source Quench"
    39. Case 11017 PingStatus = "Status code 11017 - Option Too Big"
    40. Case 11018 PingStatus = "Status code 11018 - Bad Destination"
    41. Case 11032 PingStatus = "Status code 11032 - Negotiating IPSEC"
    42. Case 11050 PingStatus = "Status code 11050 - General Failure"
    43. Case Else PingStatus = "Status code " & objPing.StatusCode & _
    44. " - Unable to determine cause of failure."
    45. End Select
    46. Next
    47. End Function
    Nutz die Ping-Klasse in einem System.Timers.Timer (oder lagere den Vorgang in einen eigenen Thread mit einer While-Schleife aus und nutze Threading.Thread.Sleep()) und Prüfe die Eigenschaft Status vom Rückgabewert von Ping.Send/SendAsync. Sollte der einfachste Weg sein.
    @xtts02 Oh sorry, lesen muss man können ._.

    Dann bin ich leider raus, von VBS hab' ich keine Ahnung.
    Wie benutze ich das?

    Edit: Ich will einen Text der Aufgeht und kein Icon, oder brauche ich ein Icon um eine Textblase aufgehen zu lassen?
    Genau das möchte ich:


    Achja soll ich dafür ein neues Thema machen, das schießt ja schon am Titel vorbei.

    Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von „axi92“ ()

    Neues Thema halte ich nicht für nötig, aber ich bin kein Mod.

    Ja, das NotifyIcon ist zwingen notwendig, um einen Balloontip (so nennt man das Ding) anzuzeigen, da das Balloontip sozusagen vom Icon ausgeht.