Module: check_mk
Branch: master
Commit: ce7d1288ec5b866f8a9e022eadfe254d597a01e8
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ce7d1288ec5b86…
Author: Sebastian Herbord <sh(a)mathias-kettner.de>
Date: Mon Feb 8 14:22:09 2016 +0100
#3070 FIX windows agent: replaced a very costy section regarding installed software
To retrieve the list of installed software the mk_inventory.vbs script uses two different approaches
that heavily overlap: One retrieves the list of uninstall-entries from the registry, the other
retrieved the list of installers registered in the windows installer database (via wmi query to
Win32_Product).
The latter list is usually a subset of the former and can take excessively long to query as it
triggers a verification of the database. In the process it also prints a lot of messages to
the event log (see https://support.microsoft.com/de-de/kb/974524).
Therefore the query to Win32_Product has been replaced with a query via a vbs-interface to the
installer database. This should produce the same results without the drawbacks mentioned.
---
.werks/3070 | 18 +++++++++++++++++
ChangeLog | 1 +
agents/windows/plugins/mk_inventory.vbs | 32 +++++++++++++++++++++++++++++--
3 files changed, 49 insertions(+), 2 deletions(-)
diff --git a/.werks/3070 b/.werks/3070
new file mode 100644
index 0000000..f640501
--- /dev/null
+++ b/.werks/3070
@@ -0,0 +1,18 @@
+Title: windows agent: replaced a very costy section regarding installed software
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.7i4
+Date: 1454934777
+Class: fix
+
+To retrieve the list of installed software the mk_inventory.vbs script uses two different approaches
+that heavily overlap: One retrieves the list of uninstall-entries from the registry, the other
+retrieved the list of installers registered in the windows installer database (via wmi query to
+Win32_Product).
+The latter list is usually a subset of the former and can take excessively long to query as it
+triggers a verification of the database. In the process it also prints a lot of messages to
+the event log (see https://support.microsoft.com/de-de/kb/974524).
+
+Therefore the query to Win32_Product has been replaced with a query via a vbs-interface to the
+installer database. This should produce the same results without the drawbacks mentioned.
diff --git a/ChangeLog b/ChangeLog
index fcce31e..88fb757 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -257,6 +257,7 @@
* 2930 FIX: juniper_cpu_util: Better detection, find more devices...
* 3163 FIX: Treat interface name '1' and '01' as identical when grouping interfaces...
* 3167 FIX: apc_inrow_airflow: fix exception in displaying parameters in WATO services list...
+ * 3070 FIX: windows agent: replaced a very costy section regarding installed software...
Multisite:
* 2684 Added icons for downloading agent data / walks of hosts...
diff --git a/agents/windows/plugins/mk_inventory.vbs b/agents/windows/plugins/mk_inventory.vbs
index f4b522a..190118a 100644
--- a/agents/windows/plugins/mk_inventory.vbs
+++ b/agents/windows/plugins/mk_inventory.vbs
@@ -43,10 +43,22 @@ If (fso.FileExists(timestamp)) Then
End If
End If
+
+' handle error message ourselves so this script can also be run directly, for testing
+On Error Resume Next
+
' create new timestamp file
' only allowed when script runs as administrator user
Set stampo = fso.CreateTextFile(timestamp)
+If Err.Number <> 0 Then
+ outPut "Failed to create time stamp: " & Err.Description & " (" & Err.Number & ")"
+ Err.Clear
+End If
+
+On Error Goto 0
+
+
' determine the timezone offset w/t GMT
Set systemParams = objClass.ExecQuery("Select * from Win32_ComputerSystem")
For Each param in systemParams
@@ -117,6 +129,22 @@ Sub RecurseForExecs(strFolderPath)
Next
End Sub
+Sub SoftwareFromInstaller(fields)
+ Dim installer
+ Set installer = CreateObject("WindowsInstaller.Installer")
+ Dim productCode, productName
+ For Each productCode In installer.Products
+ values = fields ' copy
+ idx = 0
+
+ For Each field In fields
+ values(idx) = installer.ProductInfo(productCode, field)
+ idx = idx + 1
+ Next
+ outPut(Join(values, "|"))
+ Next
+End Sub
+
' Processor
Call startSection("win_cpuinfo",58,timeUntil)
cpuVars = Array( "Name","Manufacturer","Caption","DeviceID","MaxClockSpeed","AddressWidth","L2CacheSize","L3CacheSize","Architecture","NumberOfCores","NumberOfLogicalProcessors","CurrentVoltage","Status" )
@@ -152,8 +180,8 @@ Call getWMIObject("Win32_VideoController",adapterVars)
' Installed Software
Call startSection("win_wmi_software",124,timeUntil)
-swVars = Array( "Name", "Vendor", "Version", "InstallDate", "Language")
-Call getWMIObject2("Win32_Product",swVars)
+swVars = Array( "ProductName", "Publisher", "VersionString", "InstallDate", "Language")
+Call SoftwareFromInstaller(swVars)
' Search Registry
Call startSection("win_reg_uninstall",124,timeUntil)