Monitor all services RRS feed

  • Question

  • I found this code to create a 2 state monitor - to monitor all services that are started automatically

    Dim oAPI, oBag

    Set oAPI = CreateObject("MOM.ScriptAPI")

    Set oBag = oAPI.CreatePropertyBag()

    strComputer = "."

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

    Set colListOfServices = objWMIService.ExecQuery ("SELECT * FROM Win32_Service WHERE StartMode = 'Auto' AND Started = false")

    If colListOfServices.Count > 0 Then

    For Each objService in colListOfServices

    ' If objService.Caption <> "Performance Logs and Alerts" AND objService.Caption "TypeYourService2NameHere" Then


    If strDesc = "" Then

    strDesc = objService.Caption


    StrDesc = StrDesc & ", " & objService.Caption

    End if


    Call oBag.AddValue("Description", strDesc)

    Call oBag.AddValue("State", "BAD")


    Call oBag.AddValue("State", "GOOD")

    End if

    Call oAPI.Return(oBag)


    I setup the monitor to some test group but nothing happens.

    Anyone have any ideas.



    Dave Kozlowski
    Sunday, December 11, 2011 12:53 PM


All replies

  • I'm really not a fan of monitoring all services because most should be monitored by dedicated management packs anyway, so we typically see a lot of redundancy in logic like this. Of course, that's not the question you asked, so let's see if we can offer some advice here.

    The script does return the list of services, but it's a common delimited list in a single property bag which is a little strange.  You would typically have a script like this return a separate property bag for each service.  That decision completely comes down to the monitor and what kind of behavior you want though.  I'd need to see what the monitor looks like to tell you what's not working right.

    This posting is provided "AS IS" with no warranties, and confers no rights. Use of attachments are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm
    Monday, December 12, 2011 11:51 PM
  • Thanks for the reply

    What we want to do is monitor all selective automatic services and exclude unimportant services.

     That way anyone could add services and they would be automatically monitored.  It beats having 26 seperate monitors.


    Dave Kozlowski
    Tuesday, December 13, 2011 1:34 AM



    Regarding monitoring all services with SCOM, I found the following methods and would like to share with you for your reference:


    Monitoring All Automatic Start Windows Services in SCOM 2007 R2


    Please Note: Since the website is not hosted by Microsoft, the link may change without notice. Microsoft does not guarantee the accuracy of this information.


    Monitoring all services on all computers (service outage report)



    Hope this helps.



    Nicholas Li

    TechNet Community Support

    Tuesday, December 13, 2011 8:33 AM
  • As Brian points out already you get 1 property bag which looks a bit strange. The main problem with this is most likely an object you map this all to. Hence, the bad scenario has a description that can change depending on what services are down, while the good scenario has no description. So you need to post the xml of the monitor/monitortype as well. else it's just a script that returns something...

    Btw, I disagree it beats a monitor for each service. You can configure a roll up monitor to generate just 1 alert when 1 or more service isn't started and use cookdown in the datasource to prevent a script run for each service check.

    Rob Korving
    Tuesday, December 13, 2011 4:09 PM
  • Rob

    thanks  could you explain your last line about the roll up monitor and cookdown.

    Here is what I want to do.  Monitor every service that starts automatically. If for some reason service stops or won't restart I get an alert.

    I want this setup that if someone adds a new application(creates a new service) it is automatically being monitored

    how would this work with your idea?



    Dave Kozlowski
    Tuesday, December 13, 2011 6:21 PM
    • Proposed as answer by Nicholas Li Tuesday, December 20, 2011 5:38 AM
    • Marked as answer by Nicholas Li Wednesday, December 21, 2011 7:10 AM
    Wednesday, December 14, 2011 1:27 PM