Ad Widget

Collapse

Monitoring Windows Services Over Active Checks

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • richb
    Junior Member
    • Jul 2007
    • 7

    #1

    Monitoring Windows Services Over Active Checks

    Hi all,

    I looked for a way to monitor whether services had stopped on our remote Windows boxes and found this blog post:



    The server that it's hosted on seems a little slow and I hate it when people post links which then become unavailable, so I'll post it in its entirety:

    It is handy to know any Windows services that are set to start automatically that are no longer running. This script will report a list of auto start services not running


    Code:
    ' -------------------------
    ' Auto Services Not Running
    ' -------------------------
    '
    ' Version 1.00
    ' 11 August 2006, Peter Field
    '
    ' Original script source unknown.
    '
    ' Displays a list of Windows services that are set to start Automatically,
    ' but are not currently running.
    '
    Dim strComputer, wbemServices, wbemObjectSet, wbemObject, strMessage
    On Error Resume Next
    Set wbemServices = GetObject("winmgmts:.")
    Set wbemObjectSet = wbemServices.InstancesOf("Win32_Service")
    strMessage=""
    For Each wbemObject In wbemObjectSet
      if wbemObject.StartMode = "Auto" Then
          if wbemObject.State <> "Running" Then
    '       Wscript.Echo """" & wbemObject.Name & """,""" & wbemObject.State & """,""" & wbemObject.DisplayName & """"
            If strMessage<>"" Then strMessage=strMessage & ", "
            strMessage=strMessage & wbemObject.DisplayName
          End If
      End If
    Next
    If strMessage="" Then
    	Wscript.Echo "None"
    Else
    	Wscript.Echo strMessage
    End If

    Save it as 'Auto-Services-Not-Running.vbs' in your Zabbix agent folder. Put a line in your agent config like:
    UserParameter=uServicesNotRunning,cscript.exe /nologo "c:zabbixAuto-Services-Not-Running.vbs"

    Then create an item in Zabbix:
    key: uServicesNotRunning
    type: character
    update interval: high (mine is 14400 as the script is slow)

    Then create a trigger in Zabbix:
    Expression: {Windows_t:uServicesNotRunning.str(None)}=0

    You might want to change your action to include
    Value: {{HOSTNAME}:{TRIGGER.KEY}.last(0)}
    in the message so you can see the services not running right in the alert email.

  • bbrendon
    Senior Member
    • Sep 2005
    • 870

    #2
    FYI If you search zabbix.com, this is already here, posted, and talked about.
    Unofficial Zabbix Expert
    Blog, Corporate Site

    Comment

    Working...