Ad Widget

Collapse

Monitor Windows Updates

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AlexYoung
    Member
    • Jul 2013
    • 37

    #1

    Monitor Windows Updates

    Has anyone got a working monitor for Zabbix 3.0 and letting you know how many pending updates? i've tried a few even the one on the zabbix site doesnt appear to work anymore.
  • IT-Yannick
    Junior Member
    • Nov 2016
    • 9

    #2
    Hi,
    I used this a few months ago and it worked.

    1.Install the agent on the host you want to monitor
    2.Add an userparameter on the zabbix_agentd.conf like this:

    Code:
    userparameter=custom.check_win_update[*],cscript //NoLogo "C:\Zabbix\scripts\ZabbixWindowsUpdate.vbs" $1
    3.Put the script in the folder that you specified in the userparameter in this case is C:\Zabbix\scripts\zabbix....vbs)

    4.Create on Zabbix frontend 5 items for the host:
    keys/types to use:
    item1: type: zabbix agent (active) key: custom.check_win_update["last"] (numeric/decimal)
    item2: type: zabbix agent (active) key: custom.check_win_update["optional"] (numeric/decimal)
    item3: type: zabbix agent (active) key: custom.check_win_update["priority"] (numeric/decimal)
    item4: type: zabbix agent (active) key: custom.check_win_update["total"](numeric/decimal)
    item5: type: zabbix agent (active) key: custom.check_win_update["full"] (text)


    ZabbixWindowsUpdate.vbs script:

    Code:
    Set args = WScript.Arguments
    
    IF (WScript.Arguments.Count > 0) Then
    	IF (WScript.Arguments.Item(0) = "last") Then
    		Set objSession = CreateObject("Microsoft.Update.Session")
    		Set objSearcher = objSession.CreateUpdateSearcher
    		Set colHistory = objSearcher.QueryHistory(0,1)
    		
    		For Each objEntry in colHistory
    			WScript.Echo  date2epoch(objEntry.Date)
    		Next
    		
    	Else
    		Wscript.Echo getUpdates(WScript.Arguments.Item(0))
    	End IF	
    Else
    	Wscript.Echo "ERROR in CheckWinUpdate parameter"
    End IF
    
    
    Function getUpdates(updateType)
    	Set objSearcher = CreateObject("Microsoft.Update.Searcher")
    	Set objResults = objSearcher.Search("IsInstalled=0")
    	Set colUpdates = objResults.Updates
    
    	updatesHigh = 0
    	updatesOptional = 0
    	priorityUpdateList = "Priority Updates:" & vbCrLf
    	optionalUpdateList = "Optional Updates:" & vbCrLf
    
    	For i = 0 to colUpdates.Count - 1
    		If (colUpdates.Item(i).IsInstalled = False AND colUpdates.Item(i).AutoSelectOnWebSites = False) Then
    			updatesOptional = updatesOptional + 1
    			title = "Optional Update"
    			optionalUpdateList = optionalUpdateList & colUpdates.Item(i).Title & vbCrLf
    		ElseIf (colUpdates.Item(i).IsInstalled = False AND colUpdates.Item(i).AutoSelectOnWebSites = True) Then
    			updatesHigh = updatesHigh + 1
    			title = "High Priority Update"
    			priorityUpdateList = priorityUpdateList & colUpdates.Item(i).Title & vbCrLf
    		End IF
    	Next
    
    	IF (updateType = "priority") Then
    		getUpdates = updatesHigh
    	ElseIf (updateType = "optional") Then
    		getUpdates = updatesOptional
    	ElseIf (updateType = "total") Then
    		getUpdates = (updatesHigh + updatesOptional)
    	ElseIf (updateType = "full") Then
    		getUpdates = priorityUpdateList & vbCrLf & optionalUpdateList
    	Else
    		getUpdates = "ERROR in CheckWinUpdate parameter"
    	End IF
    End function
    
    Function getmydat(wmitime) 
      dtmInstallDate.Value = wmitime 
      getmydat = dtmInstallDate.GetVarDate
    End function
    
    
    function date2epoch(myDate)
    date2epoch = DateDiff("s", "01/01/1970 00:00:00", myDate)
    end function
    Last edited by IT-Yannick; 21-11-2016, 16:45.

    Comment

    • AlexYoung
      Member
      • Jul 2013
      • 37

      #3
      thanks,

      I've tried that and works for "last" but total i'm getting a error message

      c:\Program Files (x86)\Zabbix Agent\CheckWindowUpdate.vbs(23, 2) (null): 0x80072EFD

      any ideas?

      Comment

      • IT-Yannick
        Junior Member
        • Nov 2016
        • 9

        #4
        Check this site I found the error code there


        0x80072EFD = ERROR_INTERNET_CANNOT_CONNECT


        BTW I just found the "original" post of the tutorial:
        Join the friendly and open Zabbix community on our forums and social media platforms.
        Last edited by IT-Yannick; 21-11-2016, 16:58.

        Comment

        • IT-Yannick
          Junior Member
          • Nov 2016
          • 9

          #5
          Do you still have problems using this method?

          Comment

          • AlexYoung
            Member
            • Jul 2013
            • 37

            #6
            Yeah it's got no problem with the "last" but having problems with "total", "optional", "priority"

            Comment

            Working...