source: nscp/scripts/check_updates.vbs @ f881d47

0.4.00.4.10.4.2
Last change on this file since f881d47 was 7443b58, checked in by Michael Medin <michael@…>, 2 years ago

0.4.x a lot of tweaks and fixes (now works as a replacement for 0.3.x in many ways)

  • Property mode set to 100644
File size: 2.4 KB
Line 
1' =========================================================
2' Script to check for updates onwwindows machines.
3' Shamelessly stolen from Micha³ Jankowski (fooky@pjwstk.edu.pl) script.
4' =========================================================
5
6' Required Variables
7Const PROGNAME = "check_updates"
8Const VERSION = "0.0.1"
9
10' Default settings for your script.
11threshold_warning = 50
12threshold_critical = 20
13
14' Create the NagiosPlugin object
15Set np = New NagiosPlugin
16
17' Define what args that should be used
18np.add_arg "warning", "warning threshold", 0
19np.add_arg "critical", "critical threshold", 0
20
21' If we have no args or arglist contains /help or not all of the required arguments are fulfilled show the usage output,.
22If Args.Exists("help") Then
23        np.Usage
24End If
25
26' If we define /warning /critical on commandline it should override the script default.
27If Args.Exists("warning") Then threshold_warning = Args("warning")
28If Args.Exists("critical") Then threshold_critical = Args("critical")
29np.set_thresholds threshold_warning, threshold_critical
30
31Set objAutoUpdate = CreateObject("Microsoft.Update.AutoUpdate")
32
33intResultDetect = objAutoUpdate.DetectNow
34If intResultDetect <> 0 Then: np.nagios_exit "UNKNOWN: Unable to detect Automatic Updates.", UNKNOWN
35
36Set objSession = CreateObject("Microsoft.Update.Session")
37Set objSearcher = objSession.CreateUpdateSearcher
38
39intUncompleted = 0
40intUncompletedSoftware = 0
41
42Set objSysInfo = CreateObject("Microsoft.Update.SystemInfo")
43If objSysInfo.RebootRequired Then: np.nagios_exit "WARNING: Reboot required.", WARNING
44
45Set result = objSearcher.Search("IsInstalled = 0 and IsHidden = 0")
46Set colDownloads = result.Updates
47
48For i = 0 to colDownloads.Count - 1
49        If colDownloads.Item(i).AutoSelectOnWebsites Then
50                updatesNames = colDownloads.Item(i).Title & "+ " & updatesNames
51                intUncompleted = intUncompleted + 1
52        Else
53                intUncompletedSoftware = intUncompletedSoftware + 1
54        End If
55Next
56
57return_code = OK
58
59If intUncompleted > 0 Then
60        return_code = np.check_threshold(intUncompleted)
61        np.nagios_exit "Number of critical updates not installed: " & intUncompleted & " <br />Number of software updates not installed: " & intUncompletedSoftware & " <br /> Critical updates name: " & updatesNames, return_code
62Else
63        np.nagios_exit "There is no critical updates <br />Number of software or driver updates not installed: " & intUncompletedSoftware, OK
64End If
Note: See TracBrowser for help on using the repository browser.