Module: check_mk
Branch: master
Commit: fc5181ab46f2ac989c9f60f94f10305c7bdb0710
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=fc5181ab46f2ac…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Tue Jan 30 09:56:14 2018 +0100
5626 win_wmi_updates: Inventory of Windows Update KBs
Change-Id: Ib34bf6e58c5b540c053ff53c38e429d90bcf16bd
---
.werks/5626 | 10 ++++++
agents/windows/plugins/mk_inventory.vbs | 9 +++++
inventory/win_wmi_updates | 60 +++++++++++++++++++++++++++++++++
3 files changed, 79 insertions(+)
diff --git a/.werks/5626 b/.werks/5626
new file mode 100644
index 0000000..eb2f555
--- /dev/null
+++ b/.werks/5626
@@ -0,0 +1,10 @@
+Title: win_wmi_updates: Inventory of Windows Update KBs
+Level: 1
+Component: inv
+Compatible: compat
+Edition: cre
+Version: 1.5.0i3
+Date: 1517302546
+Class: feature
+
+
diff --git a/agents/windows/plugins/mk_inventory.vbs
b/agents/windows/plugins/mk_inventory.vbs
index 19f74fe..21788f9 100644
--- a/agents/windows/plugins/mk_inventory.vbs
+++ b/agents/windows/plugins/mk_inventory.vbs
@@ -309,6 +309,15 @@ Call startSection("win_wmi_software",124,timeUntil)
swVars = Array( "ProductName", "Publisher",
"VersionString", "InstallDate", "Language")
Call SoftwareFromInstaller(swVars)
+' Windows Updates
+Call startSection("win_wmi_updates",44,timeUntil)
+Set objShell = WScript.CreateObject("WScript.Shell")
+Set objExecObject = objShell.Exec("wmic qfe get HotfixID,Description,InstalledOn
/format:csv")
+Do While Not objExecObject.StdOut.AtEndOfStream
+ strText = objExecObject.StdOut.ReadLine()
+ outPut(strText)
+Loop
+
' Search Registry
Call startSection("win_reg_uninstall",124,timeUntil)
Set rego =
GetObject("WinMgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
diff --git a/inventory/win_wmi_updates b/inventory/win_wmi_updates
new file mode 100644
index 0000000..3a415b5
--- /dev/null
+++ b/inventory/win_wmi_updates
@@ -0,0 +1,60 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2013 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-
+# tails. 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.
+
+
+# Example output
+#<<<win_wmi_updates:sep(44):cached(1494868004,3600)>>>
+#Node,Description,HotFixID,InstalledOn^M
+#S050MWSIZ001,Update,KB2849697,5/10/2017^M
+#S050MWSIZ001,Update,KB2849697,5/10/2017^M
+#S050MWSIZ001,Update,KB2849696,5/10/2017^M
+#S050MWSIZ001,Update,KB2849696,5/10/2017^M
+#S050MWSIZ001,Update,KB2841134,5/10/2017^M
+# Microsoft Office Professional Plus 2010|Microsoft Corporation|14.0.7015.1000
+
+
+def inv_win_wmi_updates(info):
+ paclist = inv_tree("software.packages:")
+ for line in info:
+ if len(line) <> 4:
+ continue
+
+ _, description, knowledge_base, install_date = line
+ date_number = None
+ if re.match(".*20.", install_date):
+ date_number = int(time.mktime(time.strptime(install_date,
"%m/%d/%Y")))
+ paclist.append({
+ "name" : "Windows Update " + knowledge_base,
+ "version" : knowledge_base,
+ "vendor" : "Micorosoft " + description,
+ "install_date" : date_number,
+ "package_type" : "wmi",
+ })
+
+
+inv_info['win_wmi_updates'] = {
+ "inv_function": inv_win_wmi_updates,
+}