Module: check_mk
Branch: master
Commit: 5b69f71ea1fc388ad72e99d2256c9012d8b71063
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=5b69f71ea1fc38…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Mar 18 09:46:13 2015 +0100
#2148 FIX win_os: Fixed inventory of OS with older powershell versions
---
.werks/2148 | 10 ++++++++++
ChangeLog | 1 +
agents/windows/plugins/mk_inventory.ps1 | 2 +-
inventory/win_os | 11 +++++++----
4 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/.werks/2148 b/.werks/2148
new file mode 100644
index 0000000..4b2a588
--- /dev/null
+++ b/.werks/2148
@@ -0,0 +1,10 @@
+Title: win_os: Fixed inventory of OS with older powershell versions
+Level: 1
+Component: inv
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.7i1
+Date: 1426668169
+
+
diff --git a/ChangeLog b/ChangeLog
index dd93893..2f4ddf7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -404,6 +404,7 @@
* 1943 FIX: inventory plugin win_os: no longer detects incorrect i386
architecture...
* 1995 FIX: dmidecode: Fix parsing when memory devices are listed before controller
* 2147 FIX: Fixed exception in HW-/SW-Inventory GUI with special characters in
inventorized data...
+ * 2148 FIX: win_os: Fixed inventory of OS with older powershell versions
1.2.6b1:
diff --git a/agents/windows/plugins/mk_inventory.ps1
b/agents/windows/plugins/mk_inventory.ps1
index 6c71525..3f0f0c7 100644
--- a/agents/windows/plugins/mk_inventory.ps1
+++ b/agents/windows/plugins/mk_inventory.ps1
@@ -44,7 +44,7 @@ foreach ( $entry in $cpu ) { foreach ( $item in $cpu_vars) { write-host
$item "
# OS Version
write-host "<<<win_os:sep(124):persist($until)>>>"
-Get-WmiObject Win32_OperatingSystem -ComputerName $name -Recurse | foreach-object {
write-host -separator $separator $_.csname, $_.caption, $_.version, $_.OSArchitecture,
$_.servicepackmajorversion, $_.ServicePackMinorVersion, $_.InstallDate }
+Get-WmiObject Win32_OperatingSystem -ComputerName $name | foreach-object { write-host
-separator $separator $_.csname, $_.caption, $_.version, $_.OSArchitecture,
$_.servicepackmajorversion, $_.ServicePackMinorVersion, $_.InstallDate }
# Memory
#Get-WmiObject Win32_PhysicalMemory -ComputerName $name | select
BankLabel,DeviceLocator,Capacity,Manufacturer,PartNumber,SerialNumber,Speed
diff --git a/inventory/win_os b/inventory/win_os
index 3d51076..a6d8bfe 100644
--- a/inventory/win_os
+++ b/inventory/win_os
@@ -26,7 +26,7 @@
# Example output
# <<<win_os>>>
-# WIN7|Microsoft Windows 7 Home Premium |6.1.7601|64-Bit|1|0
+# WIN2003|Microsoft(R) Windows(R) Server 2003 Standard
Edition|5.2.3790||2|0|20100620230628.000000+120
def inv_win_os(info):
node = inv_tree("software.os.")
@@ -40,9 +40,12 @@ def inv_win_os(info):
else:
node["arch"] = "i386"
node["service_pack"] = line[4]+"."+line[5]
- dat = re.sub("\+\d+","",line[6])
- tz = int(re.sub("\d{14}.\d{6}","",line[6]))
- node["install_date"] = int(time.mktime(time.strptime(dat,
"%Y%m%d%H%M%S.%f"))) - tz*60
+
+ if '+' in line[6]:
+ datestr, tz = line[6].split('+')
+ else:
+ datestr, tz = line[6], 0
+ node["install_date"] = int(time.mktime(time.strptime(datestr,
"%Y%m%d%H%M%S.%f"))) - int(tz)*60
inv_info['win_os'] = {