Ad Widget
Collapse
Monitoring available Windows updates
Collapse
X
-
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
Now everything works fineCode: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
Comment
-
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.
RegardsLast edited by harmonica; 19-12-2011, 15:34.Comment
-
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 FilesComment
..
Comment