Module: check_mk
Branch: master
Commit: bba523c3cd06a9f267d119429604193e56d306da
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=bba523c3cd06a9…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Mar 22 14:34:15 2011 +0100
Added windows_update check
---
ChangeLog | 3 +
agents/windows/plugins/windows_updates.vbs | 56 +++++++++++++++++++
checks/windows_updates | 83 ++++++++++++++++++++++++++++
3 files changed, 142 insertions(+), 0 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index d50bbe8..31a3487 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -45,6 +45,9 @@
* canon_pages: Added new check for monitoring processed pages on canon
printer/multi-function devices
* strem1_sensors: added check to monitor sensors attached to Sensatorinc EM1 devices
+ * windows_update: Added check to monitor windows update states on windows
+ clients. The check monitors the number of pending updates and checks if
+ a reboot is needed after updates have been installed.
1.1.10:
diff --git a/agents/windows/plugins/windows_updates.vbs
b/agents/windows/plugins/windows_updates.vbs
new file mode 100644
index 0000000..972c5dd
--- /dev/null
+++ b/agents/windows/plugins/windows_updates.vbs
@@ -0,0 +1,56 @@
+' -----------------------------------------------------------------------------
+' windows_updates.vbs - check_mk agent plugin to monitor pending windows updates
+'
+' To use this just place it in the plugins/ directory below the path of the
+' check_mk_agent. After that an inventory run on the Nagios host should lead
+' to a new inventorized service.
+'
+' Author: Lars Michelsen <lm(a)mathias-kettner.de>de>, 2011-03-21
+' -----------------------------------------------------------------------------
+
+Option Explicit
+
+Dim result, reboot, numImp, numOpt, important, opti
+Dim updtSearcher, colDownloads, objEntry
+
+If CreateObject("Microsoft.Update.AutoUpdate").DetectNow <> 0 Then
+ WScript.Echo "<<<windows_updates>>>"
+ WScript.Quit(0)
+End If
+
+Set updtSearcher =
CreateObject("Microsoft.Update.Session").CreateUpdateSearcher
+
+reboot = 0
+numImp = 0
+numOpt = 0
+
+If CreateObject("Microsoft.Update.SystemInfo").RebootRequired Then
+ reboot = 1
+End If
+
+Set result = updtSearcher.Search("IsInstalled = 0 and IsHidden = 0")
+Set colDownloads = result.Updates
+
+For Each objEntry in colDownloads
+ if objEntry.AutoSelectOnWebSites Then
+ if numImp = 0 Then
+ important = objEntry.Title
+ else
+ important = important & "; " & objEntry.Title
+ End If
+ numImp = numImp + 1
+ Else
+ If numOpt = 0 Then
+ opti = objEntry.Title
+ Else
+ opti = opti & "; " & objEntry.Title
+ End If
+ numOpt = numOpt + 1
+ End If
+Next
+
+WScript.Echo "<<<windows_updates>>>"
+WScript.Echo reboot & " " & numImp & " " & numOpt
+WScript.Echo important
+WScript.Echo opti
+WScript.Quit()
diff --git a/checks/windows_updates b/checks/windows_updates
new file mode 100644
index 0000000..e94827e
--- /dev/null
+++ b/checks/windows_updates
@@ -0,0 +1,83 @@
+#!/usr/bin/python
+# -*- encoding: utf-8 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2010 mk(a)mathias-kettner.de |
+# +------------------------------------------------------------------+
+#
+# This file is part of Check_MK.
+# The official homepage is at
http://mathias-kettner.de/check_mk.
+#
+# check_mk is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation in version 2. check_mk is distributed
+# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
+# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. See the GNU General Public License for more de-
+# ails. You should have received a copy of the GNU General Public
+# License along with GNU Make; see the file COPYING. If not, write
+# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301 USA.
+
+# Author: Lars Michelsen <lm(a)mathias-kettner.de>
+
+# <<<windows_updates>>>
+# 0 2 5
+# Windows XP Service Pack 3 (KB936929); Windows-Tool zum Entfernen sch�dlicher Software -
M�rz 2011 (KB890830)
+# Update f�r WMDRM-f�hige Medienplayer (KB891122); Windows Media Player 11; Windows
Search 4.0 f�r Windows XP (KB940157); Microsoft Base
Smartcard-Kryptografiedienstanbieter-Paket: x86 (KB909520); Update f�r die Microsoft .NET
Framework 3.5 Service Pack 1- und .NET Framework 3.5-Produktfamilie (KB951847) x86
+
+# First row: Reboot_required, num_important, num_optional
+# Second row: List of all important updates
+# Thirt row: List of all optional updates
+
+windows_updates_default_params = (None, None, None, None)
+
+def inventory_windows_updates(checktype, info):
+ if info and len(info[0]) == 3:
+ return [(None, "windows_updates_default_params")]
+
+def check_windows_updates(_unused, params, info):
+ if info and len(info[0]) == 3:
+ status = 0
+ reboot_required, num_imp, num_opt = map(saveint, info[0])
+ imp_warn, imp_crit, opt_warn, opt_crit = params
+ important = ''
+ if len(info) >= 2:
+ important = ' '.join(info[1])
+ optional = ''
+ if len(info) >= 3:
+ optional = ' '.join(info[2])
+
+ txt = []
+ perfdata = []
+ for label, updates, cur, warn, crit in [ ('important', important,
num_imp, imp_warn, imp_crit),
+ ('optional', optional,
num_opt, opt_warn, opt_crit) ]:
+ this_txt = '%d %s' % (cur, label)
+ if label == 'important' and cur > 0:
+ this_txt += ' (%s)' % updates
+ if crit and cur >= crit:
+ this_txt += ' (CRIT: >=%d)' % crit
+ if status < 2:
+ status = 2
+ elif warn and cur >= warn:
+ this_txt += ' (WARN: >=%d)' % warn
+ if status < 1:
+ status = 1
+ txt.append(this_txt)
+ perfdata.append((label, cur, warn, crit))
+
+ if reboot_required == 1:
+ if status < 1:
+ status = 1
+ txt.append('WARN: A reboot is required to finish update
installations')
+
+ return (status, '%s - %s' % (nagios_state_names[status], ',
'.join(txt)), perfdata)
+
+ return (3, 'UNKNOWN - No windows update information provided')
+
+check_info['windows_updates'] = (check_windows_updates, "System
Updates", 1, inventory_windows_updates)