Ad Widget

Collapse

Using LLD to monitor Windows Services

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • qix
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Oct 2006
    • 423

    #1

    Using LLD to monitor Windows Services

    I've created a Low Level Discovery script to monitor Windows services automatically.

    By default it will use item and trigger prototypes to start monitoring services that are started on boot time.
    Filtering is possible on multiple discovery macros:

    Code:
    {#SERVICENAME}		The name of the Windows service
    {#SERVICEDISPLAY}	The displayname of the Windows service
    {#SERVICESTATE}		The state of the Windows service
    {#SERVICEDESC}		The Windows service description
    This will also help a lot for applications where a new service is defined per instance (like SAP, MS-SQL, Biztalk, etc.) which are currently kind of hard to create templates for. In this case you can filter on the name instead of the state.

    You can find all you need here: https://github.com/q1x/zabbix-templa...vice-discovery

    Also, if you would like this function build into the agent instead of using a script, please vote for https://support.zabbix.com/browse/ZBXNEXT-1368
    With kind regards,

    Raymond
  • daniel.s
    Junior Member
    • Dec 2012
    • 3

    #2
    Originally posted by qix
    I've created a Low Level Discovery script to monitor Windows services automatically.
    Thanks. This sounds good, I'll try it out this week.

    Great timing as I want to figure out how to get these Windows LLD scripts working and write an Exchange 2010 mailbox discovery script.

    Comment

    • alledm
      Member
      • May 2012
      • 84

      #3
      Hi,

      haven't had the chance to test it but it looks great.

      Can you also add one #SERVICESTARTSTATUS or something similar to tell whether it is "Automatic", "Manual" or "Disabled" ?

      Comment

      • qix
        Senior Member
        Zabbix Certified SpecialistZabbix Certified Professional
        • Oct 2006
        • 423

        #4
        Originally posted by alledm
        Can you also add one #SERVICESTARTSTATUS or something similar to tell whether it is "Automatic", "Manual" or "Disabled" ?
        Shouldn't be too hard to do, however...I wanted to do a discovery on "automatic" services. Therefor, I'm using a filter to only return those services. The macro will never match Manual or Disabled in this case.
        With kind regards,

        Raymond

        Comment

        • alledm
          Member
          • May 2012
          • 84

          #5
          Unfortunately that's exactly what I need because we have loads of manual services that are time dependent and we only start them at specific times

          Comment

          • alledm
            Member
            • May 2012
            • 84

            #6
            Oh well looking at the code it seems extremely easy to change so I will do it myself.
            Thank you for this

            Comment

            • qix
              Senior Member
              Zabbix Certified SpecialistZabbix Certified Professional
              • Oct 2006
              • 423

              #7
              In servdisc.ps1 remove:

              Code:
              | where-object { $_.StartMode -eq 'Auto' }
              Change:
              Code:
               $line =  " { `"{#SERVICESTATE}`":`"" + $objItem.State + "`" , `"{#SERVICEDISPLAY}`":`"" + $objItem.DisplayName + "`" , `"{#SERVICENAME}`":`"" + $objItem.Name + "`" , `"{#SERVICEDESC}`":`"" + $objItem.Description + "`" },"
              Code:
              To:
               $line =  " { `"{#SERVICESTART}`":`"" + $objItem.StartMode + "`" , `"{#SERVICESTATE}`":`"" + $objItem.State + "`" , `"{#SERVICEDISPLAY}`":`"" + $objItem.DisplayName + "`" , `"{#SERVICENAME}`":`"" + $objItem.Name + "`" , `"{#SERVICEDESC}`":`"" + $objItem.Description + "`" },"
              That should do it
              With kind regards,

              Raymond

              Comment

              • qix
                Senior Member
                Zabbix Certified SpecialistZabbix Certified Professional
                • Oct 2006
                • 423

                #8
                The only problem is that you can only filter on one macro during LLD discovery phase. You could also adjust the
                Code:
                | where-object { $_.StartMode -eq 'Auto' }
                to

                Code:
                | where-object { $_.StartMode -eq 'Manual' }
                With kind regards,

                Raymond

                Comment

                • thk

                  #9
                  Hi,

                  My first ZABBIX post and I'm rather new to Zabbix. So bare with me please.
                  I'm pretty much into monitoring and managing host on several systems, but my knowledge are limited to HP OM and IBM Omnibus.

                  This is an interesting post to get started on windows boxes, but I'm not that familiar with ZABBIX templates and LLD. Could someone be so kind to post a quick "how to" or "Step by step" for this Excellent Service-discovery.

                  I guess I would start by importing the xml template Template_Windows_Service_Discovery.xml, but it errors:
                  Code:
                  XML file contains fatal error 76:Opening and ending tag mismatch: meta line 44 and head [ Line: 51 | Column: 10 ]
                  So I'm guessing I'm doing it wrong already?

                  Cheers!

                  Ubuntu 12.04.
                  Zabbix server 2.04

                  Thomas

                  Comment

                  • garcaman
                    Junior Member
                    Zabbix Certified Specialist
                    • Oct 2012
                    • 5

                    #10
                    you have to copy the xml content file in web page and paste for a note pad file, after that save this file with xml extention file and try again

                    Comment

                    • garcaman
                      Junior Member
                      Zabbix Certified Specialist
                      • Oct 2012
                      • 5

                      #11
                      Windows Service LLD Discovery

                      Hello guys,

                      I've done the configuration for monitoring the windows services according the article "http://blog.zabbix.com/low-level-discovery-for-windows-services/1867/#more-1867".

                      I'm receiving the follow information in my host discovery rule "value should be a JSON object". What does it mean?

                      I dont know what I need to do in order to solve this problem, could you please guys help me on that?

                      Thanks in advance.

                      Leandro
                      Last edited by garcaman; 05-03-2013, 18:15. Reason: Subject

                      Comment

                      • qix
                        Senior Member
                        Zabbix Certified SpecialistZabbix Certified Professional
                        • Oct 2006
                        • 423

                        #12
                        Hi Thomas,

                        Welcome to the forum and the Zabbix community!

                        Originally posted by thk
                        Hi,

                        This is an interesting post to get started on windows boxes, but I'm not that familiar with ZABBIX templates and LLD. Could someone be so kind to post a quick "how to" or "Step by step" for this Excellent Service-discovery.
                        For a somewhat more detailed explanation see here:

                        Introduction When monitoring Windows servers and services it would be really handy to have a check to see if all the services that are registered with the system to automatically start up during boot, are also started. You can use the item services[automatic] and compare its results with the output of the item services[automatic,started] using […]


                        If you need any further help, please let us know. Make sure that the XML you are trying to import really is a proper XML formatted file.

                        Please do keep in mind that this is a workaround for the mentioned ticket, so if you want this functionality in a production environment, please vote for the ticket as well!
                        With kind regards,

                        Raymond

                        Comment

                        • qix
                          Senior Member
                          Zabbix Certified SpecialistZabbix Certified Professional
                          • Oct 2006
                          • 423

                          #13
                          Oh, and if you need some help in working with templates and such, you can check here: http://www.zbxtutorials.org/2012/08/...rs-course.html

                          It's for the 1.8 version of Zabbix, but the idea remains the same
                          With kind regards,

                          Raymond

                          Comment

                          • JPtheGeezer
                            Junior Member
                            • Feb 2012
                            • 8

                            #14
                            Hi,

                            I've been using the LLD and for 2K8 servers this works well, and for 2K3 servers the VBS file works to discover the services, it does take a long time to kick in and discover but I don't mind.

                            How do I now create an action to alert us about services stopping?
                            Last edited by JPtheGeezer; 06-05-2013, 03:23. Reason: 2K3 service discovery now works.

                            Comment

                            • JPtheGeezer
                              Junior Member
                              • Feb 2012
                              • 8

                              #15
                              Originally posted by garcaman
                              Hello guys,

                              I've done the configuration for monitoring the windows services according the article "http://blog.zabbix.com/low-level-discovery-for-windows-services/1867/#more-1867".

                              I'm receiving the follow information in my host discovery rule "value should be a JSON object". What does it mean?

                              I dont know what I need to do in order to solve this problem, could you please guys help me on that?

                              Thanks in advance.

                              Leandro
                              Hi, I was having this issue too, you just need to make sure you do this:

                              1. In the CONF file on the servers the User Parameter line should read:

                              UserParameter=service.discovery,cscript /B c:\zabbix\servdisc.vbs

                              2. Make sure the VBS file is located in the same folder that is referenced in the CONF file.

                              3. Restart the service on the server.

                              4. Disable and re-enable the discovery on Zabbix for the host.

                              5. Wait for 30 mins and the services will start discovering and appearing in the items for that host.

                              6. If you still have problems it could be that the VBS file was downloaded and the code is all messed up. If this is the case just go back to the site and rather than downloading the code from your browser just click on the VBS file and let the code open on your browser page. Then just copy the code from your browser into the VBS file using a text editor like notepad or Notepad + (Plus).

                              After all that you should be fine.

                              Comment

                              Working...