Check All Services Which Set To Automatic Mode Are Running

Hi All,

This is my first post emoticons_wink.png  OK, straight to the point:

Attached template is based on VBScript and will check status of all services on the Windows based machines. If those services which set to automatic are not running script will increase "Statistic" counter. I have set threshold to CRITICAL = "1", as there is no real reason why AUTOMATIC service should not be running (there are some exceptions of course). The template will also report back names (Service Display Name) of those services which are set to automatic and not running. This is handled by "Massage" variable and will be visible in SAM, so, you can see in SolarWinds SAM all you need straight away.

You can also define exceptions. Well, this can be improved to make it bit more easier to manage. At the moment you will need to modify VBScript itself. Just open it and you will see straight away the line of code which you need to copy-pase. Add additional exception if you need to.

Thank you very much for using it,

Best of luck,

Alex

Parents
  • This is exactly what I needed, Thanks Alex!! 

    I ran into a similar issue where our development team was spinning up new services on servers that needed to be monitored.  As you can imagine, this becomes a royal pain as we would need to add the new service to monitoring each time.  What I needed was a monitor that would check any service on a node with a specific prefixed name such as "CORE." and was set to automatic startup. 

    Below is the VB Script that I used

    ______________________________________________________________________________

    Const wbemFlagReturnImmediately = &h10

    Const wbemFlagForwardOnly = &h20

    Dim MonitoredServer

    Dim arrComputers

    Dim StrComputer

    Dim objItem, objWMIService, colItems

    Dim Statistic

    Dim Message

    'SCRIPT INPUT: ${IP}

    MonitoredServer = WScript.Arguments(0)

    arrComputers = Array(MonitoredServer)

    For Each strComputer In arrComputers

        statistic = 0

        message = "Stopped services - "

        Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

        Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Service where name like 'core.%'", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)

        For Each objItem In colItems

            If StrComp(objItem.StartMode,"Auto") <> 0 Then

                If StrComp(objItem.State,"Running") <> 0 Then

                    statistic = statistic + 1

                    message = message & " | " & objItem.DisplayName

                End If

            End If

        Next

    Next

    If statistic = 0 Then

        WScript.Echo "Message: All services are running"

        WScript.Echo "Statistic: 0"

        Wscript.quit(0)

    else

        WScript.Echo "Message: " & message

        WScript.Echo "Statistic: " & statistic

        Wscript.quit(1)

    End If

    ______________________________________________________________________________

    There are a couple of tweaks I am planning to do with this like adding the service name search prefix as a parameter passed into the script by the calling component check, probably removing the server loop as only one server is being passed into the script at a time and maybe automatically restarting the service but for now, this works great.

    Thanks again!

Comment
  • This is exactly what I needed, Thanks Alex!! 

    I ran into a similar issue where our development team was spinning up new services on servers that needed to be monitored.  As you can imagine, this becomes a royal pain as we would need to add the new service to monitoring each time.  What I needed was a monitor that would check any service on a node with a specific prefixed name such as "CORE." and was set to automatic startup. 

    Below is the VB Script that I used

    ______________________________________________________________________________

    Const wbemFlagReturnImmediately = &h10

    Const wbemFlagForwardOnly = &h20

    Dim MonitoredServer

    Dim arrComputers

    Dim StrComputer

    Dim objItem, objWMIService, colItems

    Dim Statistic

    Dim Message

    'SCRIPT INPUT: ${IP}

    MonitoredServer = WScript.Arguments(0)

    arrComputers = Array(MonitoredServer)

    For Each strComputer In arrComputers

        statistic = 0

        message = "Stopped services - "

        Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

        Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Service where name like 'core.%'", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)

        For Each objItem In colItems

            If StrComp(objItem.StartMode,"Auto") <> 0 Then

                If StrComp(objItem.State,"Running") <> 0 Then

                    statistic = statistic + 1

                    message = message & " | " & objItem.DisplayName

                End If

            End If

        Next

    Next

    If statistic = 0 Then

        WScript.Echo "Message: All services are running"

        WScript.Echo "Statistic: 0"

        Wscript.quit(0)

    else

        WScript.Echo "Message: " & message

        WScript.Echo "Statistic: " & statistic

        Wscript.quit(1)

    End If

    ______________________________________________________________________________

    There are a couple of tweaks I am planning to do with this like adding the service name search prefix as a parameter passed into the script by the calling component check, probably removing the server loop as only one server is being passed into the script at a time and maybe automatically restarting the service but for now, this works great.

    Thanks again!

Children
No Data