Ad Widget

Collapse

Windows Update Monitoring

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • officielmc
    Member
    • Apr 2011
    • 32

    #1

    Windows Update Monitoring

    Hello,

    I would like to monitor the number of windows update available (win serv 2008). I find VB script online.

    Set updateSession = CreateObject("Microsoft.Update.Session")
    Set updateSearcher = updateSession.CreateupdateSearcher()
    Set searchResult = updateSearcher.Search("IsInstalled=0 and Type='Software'")
    WScript.Echo searchResult.Updates.Count

    On the server side I add this line at the end:
    UserParameter=wua.getnumupdates,%systemroot%\syste m32\cscript.exe /nologo c:\zabbix\wu\getnumupdates.vbs


    I open Windows command line and copy past this:
    %systemroot%\system32\cscript.exe /nologo c:\zabbix\wu\getnumupdates.vbs

    And I got result .

    But when i tried to use this command from zabbix server i got:

    [131009154640 root@cnmontest02 zabbix_get]# ./zabbix_get -s 10.114.1.5 -p 10050 -k "wua.getnumupdates[]"
    ZBX_NOTSUPPORTED



    So i guess i did mistake somewhere but I don't know where, if someone know how to solve it, I will be happy.

    Thanks

    Zabbix 2.0.8
    Centos 6.4
    Postgresql
  • steveboyson
    Senior Member
    • Jul 2013
    • 582

    #2
    It's probably a timeout issue occuring on your zabbix agent.
    Try increasing the timeout in the config file up to 30 seconds.
    Checking for (Windows) updates is a time consuming issue and can most likely not be finished within 30 sec.

    If that does not work, create a scheduled task on the box(es) which writes the previously gathered Windows update status to a text file. Then, from the zabbix agent, create a "Userparameter" which just parses the relevant lines from the file and returns these to the zabbix server.

    Comment

    • officielmc
      Member
      • Apr 2011
      • 32

      #3
      Thanks Steve for your quick answer,

      I increased the Timeout but still same and I put 30s, but after 5s on the server side I have ZBX_NOTSUPPORTED.

      I would like to try your technique
      -create a scheduled task
      -writes the previously gathered Windows update status to a text file
      -Then, from the zabbix agent, create a "Userparameter" which just parses the relevant lines from the file and returns these to the zabbix server.

      If you already did it can you explain me step by step with details how to do please.

      Thanks

      Comment

      • steveboyson
        Senior Member
        • Jul 2013
        • 582

        #4
        You might need to increase the timeout on the zabbix_server as well, but this increases load of your zabbix_server as it delays item gathering quite a lot.

        My approach:
        Have a .CMD as a "scheduled task", run it as often as you like.

        Code:
        @echo off
        set LOG=C:\Program Files\Zabbix Agent\log\winupdates.log
        echo %date% %time% >> "%LOG%"
        cscript.exe //NoLogo "C:\Program Files\Zabbix Agent\conf\winupdate.vbs" >> "%LOG%" 2>&1
        Then create a .VBS which checks for the updates. That VBS will send the gathered data via "zabbix_sender".

        Code:
        ' https://www.zabbix.com/forum/showthread.php?t=13358'
        serverName = "zabbix"
        hostName = "<your-host-name>"
        zbxSender = "C:\Program Files\Zabbix Agent\zabbix_sender.exe"
        
        updatesHigh = 0
        updatesOptional = 0
        
        Set objSearcher = CreateObject("Microsoft.Update.Searcher")
        Set objSysInfo = CreateObject("Microsoft.Update.SystemInfo")
        Set objResults = objSearcher.Search("IsInstalled=0")
        Set colUpdates = objResults.Updates
        Set WSHShell = CreateObject("WScript.Shell")
        
        For i = 0 to colUpdates.Count - 1
        
        	If (colUpdates.Item(i).IsInstalled = False AND colUpdates.Item(i).AutoSelectOnWebSites = False AND colUpdates.Item(i).IsHidden = False) Then
        		updatesOptional = updatesOptional + 1
        	ElseIf (colUpdates.Item(i).IsInstalled = False AND colUpdates.Item(i).AutoSelectOnWebSites = True AND colUpdates.Item(i).IsHidden = False) Then
        		updatesHigh = updatesHigh + 1
        	End IF
            
        Next
        
        updatesTotal = (updatesHigh + updatesOptional)
        
        WScript.Echo "updatesTotal = " & updatesTotal
        WScript.Echo "updatesHigh = " & updatesHigh
        WScript.Echo "updatesOptional = " & updatesOptional
        WScript.Echo "RebootRequired = " & objSysInfo.RebootRequired
        
        WSHShell.Exec zbxSender & " -z " & serverName & " -s " & hostName & " -k win_updates[total] -o " & updatesTotal
        WSHShell.Exec zbxSender & " -z " & serverName & " -s " & hostName & " -k win_updates[high] -o " & updatesHigh
        WSHShell.Exec zbxSender & " -z " & serverName & " -s " & hostName & " -k win_updates[optional] -o " & updatesOptional
        WSHShell.Exec zbxSender & " -z " & serverName & " -s " & hostName & " -k win_updates[reboot] -o " & objSysInfo.RebootRequired
        
        WScript.Quit 0
        Finnaly, create "Zabbix trapper" items on yopur host/template:
        win_updates[total]
        win_updates[high]
        win_updates[optional]
        win_updates[reboot]

        (see last 4 lines of VBS)

        Thus you don't need a "UserParameter" in your agent's conf and the values get sent to the zabbix_server as soon as they are defined on windows side.

        Please note that I exclude "hidden" updates (means updates which have been manually excluded by intention).

        Comment

        • steveboyson
          Senior Member
          • Jul 2013
          • 582

          #5
          Courtesy of all this goes to https://www.zabbix.com/forum/member.php?u=2979

          See https://www.zabbix.com/forum/showthread.php?t=13358

          Comment

          • steveboyson
            Senior Member
            • Jul 2013
            • 582

            #6
            The reason I write everything in a LOGFILE besides sending it via zabbix_sender is that I want to track the whole process. You don't need to write out the logfile from the CMD, so you can directly hook the VBS into "scheduled tasks"if you want.

            Comment

            • officielmc
              Member
              • Apr 2011
              • 32

              #7
              Hi steveboyson,

              Thank for your support I was off these days. I will follow the step you wrote tomorrow and let you know how it's work for me.

              Thanks a lot

              Comment

              • Navoyenok
                Senior Member
                • Dec 2011
                • 101

                #8
                Hi

                Use EXEC function (Its not time limited).

                Comment

                • officielmc
                  Member
                  • Apr 2011
                  • 32

                  #9
                  Hi Navoyenok,

                  Can you give me more details please? How to use exec function please.

                  Thanks

                  Comment

                  • steveboyson
                    Senior Member
                    • Jul 2013
                    • 582

                    #10
                    He probably means "remote commands". I would strictly recommend NOT to use it due to security considerations.

                    Comment

                    • Navoyenok
                      Senior Member
                      • Dec 2011
                      • 101

                      #11
                      Sorry for EXEC. Its named is system.run.

                      Try using items:

                      system.run[command,<mode>]

                      Comment

                      • officielmc
                        Member
                        • Apr 2011
                        • 32

                        #12
                        [SOLVED]Check Windows updates

                        Hello,

                        Thank you guys for your help. Now everything works very well. Finally I follow steveboyson methods.

                        Thank you very much

                        Comment

                        Working...