Ad Widget

Collapse

Monitoring available Windows updates

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Palindrom
    Junior Member
    • Sep 2011
    • 4

    #61
    Originally posted by Shad0w
    run the script ..

    __________________
    my solution was the right name.. zabbix is case senstiv..
    the script send SERVER1 but zabbix need server1 ^^
    Lot of thanks! This was my error. I´m searching 2 Days.
    I was already mad

    Very best regards! Palindrom

    Comment

    • G19star
      Junior Member
      • Oct 2011
      • 1

      #62
      Few Changes

      Hi There,

      I'm pretty new to zabbix and i'm exploring it verry wel now, however for some reason with the latest zabbix_sender i was not able to use your script without problems, for some reason the zabbix_sender needs the zabbix_agentd.conf, if any one got problems running the script see the code bellow


      Code:
      zbxSender = "C:\ZabbixAgent\zabbix_sender.exe"
      zabbixserv = "192.168.1.146"
      config = "C:\ZabbixAgent\zabbix_agentd.conf"
      hostName = "MICHEL-PC"
      
      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) Then
      		updatesOptional = updatesOptional + 1
      	ElseIf (colUpdates.Item(i).IsInstalled = False AND colUpdates.Item(i).AutoSelectOnWebSites = True) Then
      		updatesHigh = updatesHigh + 1
      	End IF
          
      Next
      
      updatesTotal = (updatesHigh + updatesOptional)
      
      WSHShell.Exec zbxSender & " -z " & zabbixserv & " -c " & config & " -s " & hostName & " -k win_updates[total] -o " & updatesTotal
      WSHShell.Exec zbxSender & " -z " & zabbixserv & " -c " & config & " -s " & hostName & " -k win_updates[high] -o " & updatesHigh
      WSHShell.Exec zbxSender & " -z " & zabbixserv & " -c " & config & " -s " & hostName & " -k win_updates[optional] -o " & updatesOptional
      WSHShell.Exec zbxSender & " -z " & zabbixserv & " -c " & config & " -s " & hostName & " -k win_updates[reboot] -o " & objSysInfo.RebootRequired
      
      WScript.Quit 0
      Now everything works fine

      Comment

      • harmonica
        Senior Member
        • Jan 2009
        • 251

        #63
        Originally posted by eger
        What error do you get? I still use the original script on my Windows 2008 R2 servers. No problems here.
        I have been testing this script in Windows Server 2008 R2 Enterprise but without success. I get this error:



        when I run the command manually, i have success:

        c:\Program Files (x86)\Zabbix Agent>zabbix_sender.exe -z serverName -s hostName -k win_updates[reboot] -o yes
        Info from server: "Processed 1 Failed 0 Total 1 Seconds spent 0.000076" sent: 1; skipped: 0; total: 1

        I'm using the original script.

        Regards
        Last edited by harmonica; 19-12-2011, 15:34.

        Comment

        • harmonica
          Senior Member
          • Jan 2009
          • 251

          #64
          I

          The problem was related to Windows Updates, because they were not working properly.

          Comment

          • waclaw
            Junior Member
            • Nov 2012
            • 5

            #65
            Hi,

            I created smal exe that can report number of days form last Windows Update.


            C# code:
            Code:
            using System;
            using System.Collections.Generic;
            using System.Linq;
            using System.Text;
            using Microsoft.Win32;
            namespace dataownik
            {
                class Program
                {
                    static void Main(string[] args)
                    {
                        if (args[0].StartsWith("/?") )
                        {
                            Console.WriteLine("Last Windows Update Checker");
                            Console.WriteLine("Writen by: Tomasz Pawelczak: [email][email protected][/email]");
                            Console.WriteLine("Returns number of days from last update");
                        }
                        const string key = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\WindowsUpdate\\Auto Update\\Results\\Install";
                        const string value = "LastSuccessTime";
                        string regKey = (string)Registry.GetValue(key, value, "2010-01-01"); 
                        DateTime dt = Convert.ToDateTime(regKey);
                        DateTime dn = DateTime.Now;
                        System.TimeSpan diff = dn - dt;
                        Console.WriteLine("{0}", diff.Days);
                    }
                }
            }
            Attached Files

            Comment

            Working...