Search Exchange

Search All Sites

Nagios Live Webinars

Let our experts show you how Nagios can help your organization.

Contact Us

Phone: 1-888-NAGIOS-1
Email: sales@nagios.com

Login

Remember Me

Directory Tree

Check Windows Updates

Rating
5 votes
Favoured:
0
Owner
Hits
174494
Files:
FileDescription
check_windows_updates.wsfcheck_windows_updates.wsf
COPYINGLicensce
Nagios CSP

Meet The New Nagios Core Services Platform

Built on over 25 years of monitoring experience, the Nagios Core Services Platform provides insightful monitoring dashboards, time-saving monitoring wizards, and unmatched ease of use. Use it for free indefinitely.

Monitoring Made Magically Better

  • Nagios Core on Overdrive
  • Powerful Monitoring Dashboards
  • Time-Saving Configuration Wizards
  • Open Source Powered Monitoring On Steroids
  • And So Much More!
A check to see: - how many updates are available? - how many important and optional updates are available? - if system is awaiting for rebooting after installing updates
I was using coxwal's "Check for Windows Updates"
(http://www.nagiosexchange.org/Windows_NRPE.66.0.html?&tx_netnagext_pi1p_view=903&tx_netnagext_pi1page=10%3A10)
but it wasn't enough.

So I wrote this script which uses Windows Updates API to check which updates should be installed and also is checking if you need to reboot your system.

On May 2009 Albrecht Dress sent me new version. Now it's v.1.5.
Thanks for the update.

Parameters:
w - numbers of updates before warning level default 0
c - numbers of updates before critical level default 0

Result:
Warning - When you need to reboot your system.
Critical - When there is more than "c" updates awaiting for installation.
Warning - When there is more than "w" updates awaiting for installation.
OK - When there is less than "c" or "w" updates awaiting for installation.


commandwindows_updates=c:\windows\system32\cscript.exe //NoLogo //T:120 c:\nrpe_nt\plugins\check_windows_updates.wsf /w:0 /c:1
Reviews (4)
byCyber Saiyan, February 22, 2016
Can you post a quick set of install instructions? I would like to get this installed on our network soon.
bysebp, December 1, 2011
thanks a lot for this check!

since there are a lot of ms updates that are neither critical nor important, i wanted to have the test only check for a given subset of update-categories.

category scheme by microsoft can be found here:
[url]http://msdn.microsoft.com/en-us/library/windows/desktop/ff357803(v=vs.85).aspx[/url]

edit vbs to more complex search criteria:
[url]http://msdn.microsoft.com/en-us/library/windows/desktop/aa386526(v=VS.85).aspx[/url]

change code to this:
' critical updates E6CF1350-C01B-414D-A61F-263D14D133B4
' security updates 0FA1201D-4330-4FA8-8AE9-B877473B6441
Set searchResult = updateSearcher.Search("(IsInstalled=0 and Type='Software' and CategoryIDs contains '0FA1201D-4330-4FA8-8AE9-B877473B6441') or (IsInstalled=0 and Type='Software' and CategoryIDs contains 'E6CF1350-C01B-414D-A61F-263D14D133B4')")

since i am not a developer, please let me know if the code might be changed in a better way. at least it is working at my site. ;-)

sebastian
Great script.

I got an error due to win update being disabled. I've modified the script for this scenario. Put this in the top of "main":

''''''''''''''''''''''
' Main
''''''''''''''''''''''
Set objAutoUpdate = CreateObject("Microsoft.Update.AutoUpdate")

If objAutoUpdate.ServiceEnabled "True" Then
Wscript.Echo "Windows Update service disabled on client. Please enable."
Wscript.Quit(intCritical)
End If

Set objSettings = objAutoUpdate.Settings

If objSettings.NotificationLevel = 1 Then
Wscript.Echo "Windows Update notification level is set to 'Never check for updated (not recommended)' - please change to 'Check for updates but let me choose wether to download and install them' or higher."
Wscript.Quit(intCritical)
End If

intResultDetect = objAutoUpdate.DetectNow

...
byGrenage, January 31, 2011
1 of 1 people found this review helpful
This was just what I needed, although bear in mind that NRPE can only handle 1024b of data in the return (unless custom compile), so the script causes an error if you have a lot of updates.

Easy work around was the addition of a length check, and truncation if needed:

If intImportant > 0 Then

If Len(importantNames) > 970 Then

importantNames = Left(importantNames, 970) & "..."

End If