Module: check_mk
Branch: master
Commit: e75347fdb48fc5be804938e2b19982bdb93fe6fb
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e75347fdb48fc5…
Author: Bastian Kuhn <bk(a)mathias-kettner.de>
Date: Thu Apr 17 16:17:48 2014 +0200
FIX windows_updates: Added Error Handling (Thanks to Stefan Kick)
The windows_update plugin now also handles windows servers with deactivated update
function.
---
.werks/152 | 8 ++++++++
ChangeLog | 1 +
agents/windows/plugins/windows_updates.vbs | 15 ++++++++++++++-
checks/windows_updates | 3 +++
4 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/.werks/152 b/.werks/152
new file mode 100644
index 0000000..bed4540
--- /dev/null
+++ b/.werks/152
@@ -0,0 +1,8 @@
+Title: windows_updates: Added Error Handling (Thanks to Stefan Kick)
+Level: 1
+Component: checks
+Version: 1.2.5i3
+Date: 1397744176
+Class: fix
+
+The windows_update plugin now also handles windows servers with deactivated update
function.
diff --git a/ChangeLog b/ChangeLog
index b34156d..477451c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -44,6 +44,7 @@
* 0882 FIX: check_bi_local.py: fix crash in case of non-ascii characters...
* 0606 FIX: apache_status: now also sends an accept header to make it work with
mod_security enables servers
* 0832 FIX: solaris_mem: fixed invalid calculation of total swap...
+ * 0152 FIX: windows_updates: Added Error Handling (Thanks to Stefan Kick)...
Multisite:
* 0779 Hostgroups (Summary): Empty hostgroups are no longer shown (can be re-enabled
by filter)
diff --git a/agents/windows/plugins/windows_updates.vbs
b/agents/windows/plugins/windows_updates.vbs
index 7ef05df..596fce4 100644
--- a/agents/windows/plugins/windows_updates.vbs
+++ b/agents/windows/plugins/windows_updates.vbs
@@ -6,7 +6,7 @@
' to a new inventorized service.
'
' Author: Lars Michelsen <lm(a)mathias-kettner.de>de>, 2011-03-21
-' Editor: Patrick Schlüter <ps(a)pdv-systeme.de>de>, 2011-08-21
+' Editor: Patrick SchlÃŒter <ps(a)pdv-systeme.de>de>, 2011-08-21
'
' Updated by Phil Randal, 2012-09-21, to cache results using a randomised check
interval
' of 16 to 24 hours
@@ -16,6 +16,8 @@
'
' Updated by Bastian Kuhn, 2014-03-03: Removed all caching functions cause the
current agent
' has a native caching support. Make sure that you activate caching for this script
in check_mk.ini
+'
+' 2014-04-17: Fix by Stefan Kick to handle errors. Payed by Adaptron.
'
-----------------------------------------------------------------------------------------
Option Explicit
@@ -64,7 +66,18 @@ If CreateObject("Microsoft.Update.SystemInfo").RebootRequired
Then
reboot = 1
End If
+On Error Resume Next
+
Set result = updtSearcher.Search("IsInstalled = 0 and IsHidden = 0")
+
+If Err.Number <> 0 then
+ WScript.Echo "<<<windows_updates>>>"
+ Wscript.Echo "x x x"
+ Wscript.Echo "There was an error getting update information. Maybe Windows
update is not activated. Error Number: " & Err.Number
+ WScript.Quit()
+End If
+
+
Set colDownloads = result.Updates
For Each objEntry in colDownloads
diff --git a/checks/windows_updates b/checks/windows_updates
index 1a6c153..9f04829 100644
--- a/checks/windows_updates
+++ b/checks/windows_updates
@@ -47,6 +47,9 @@ def inventory_windows_updates(info):
def check_windows_updates(_unused, params, info):
if info and len(info[0]) == 3:
status = 0
+ # Workarround to return errors from the plugin
+ if info[0][0] == 'x':
+ return 2, ' '.join(info[1])
reboot_required, num_imp, num_opt = map(saveint, info[0])
imp_warn, imp_crit, opt_warn, opt_crit = params[0:4]
if len(params) == 7: