Module: check_mk
Branch: master
Commit: 050d2bd2656fec7354e971817486389d6c1ffdb6
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=050d2bd2656fec…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Mar 16 16:18:17 2015 +0100
#2144 FIX Fixed exception in inventory GUI when trying to render dates of inventorized exe
files
Till this change the agent provided the installation dates of the exe files in a
localized
format (depending on the system locale config). The new agent is now providing a non
localized format which can easily be parsed by the check.
Not parsed installation dates lead to exceptions in the GUI when showing the inventorized
information of a host.
---
.werks/2144 | 15 +++++++++++++++
ChangeLog | 1 +
agents/windows/plugins/mk_inventory.ps1 | 3 ++-
inventory/win_exefiles | 11 +++++++++--
4 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/.werks/2144 b/.werks/2144
new file mode 100644
index 0000000..91d05d3
--- /dev/null
+++ b/.werks/2144
@@ -0,0 +1,15 @@
+Title: Fixed exception in inventory GUI when trying to render dates of inventorized exe
files
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.7i1
+Date: 1426518769
+
+Till this change the agent provided the installation dates of the exe files in a
localized
+format (depending on the system locale config). The new agent is now providing a non
+localized format which can easily be parsed by the check.
+
+Not parsed installation dates lead to exceptions in the GUI when showing the
inventorized
+information of a host.
diff --git a/ChangeLog b/ChangeLog
index 0b22b7d..bef1923 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -259,6 +259,7 @@
* 1895 FIX: temperature.include: Fixed Fahrenheit handling...
* 2097 FIX: apc_symmetra: Fixed false alert during self test...
* 2143 FIX: Solaris-Agent: Fixed broken zfsget checks on solaris 10
+ * 2144 FIX: Fixed exception in inventory GUI when trying to render dates of
inventorized exe files...
Multisite:
* 1758 Improved exception hander: Shows details without additional debug request,
added mailto link for error report...
diff --git a/agents/windows/plugins/mk_inventory.ps1
b/agents/windows/plugins/mk_inventory.ps1
index 0a11313..6c71525 100644
--- a/agents/windows/plugins/mk_inventory.ps1
+++ b/agents/windows/plugins/mk_inventory.ps1
@@ -2,6 +2,8 @@
$delay = 14400 # execute agent only every $delay seconds
$exe_paths = @("c:\Program Files (x86)")
+[System.Threading.Thread]::CurrentThread.CurrentCulture =
[Globalization.CultureInfo]::InvariantCulture
+[System.Threading.Thread]::CurrentThread.CurrentUICulture =
[Globalization.CultureInfo]::InvariantCulture
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
write-output "" # workaround to prevent the byte order mark to be at the
beginning of the first section
$name = (Get-Item env:\Computername).Value
@@ -17,7 +19,6 @@ if (!$agent_dir) {
$timestamp = $agent_dir + "\timestamp."+ $remote_host
-
# does $timestamp exist?
If (Test-Path $timestamp){
$filedate = (ls $timestamp).LastWriteTime
diff --git a/inventory/win_exefiles b/inventory/win_exefiles
index 4641532..b5d1862 100644
--- a/inventory/win_exefiles
+++ b/inventory/win_exefiles
@@ -35,13 +35,20 @@ def inv_win_exefiles(info):
paclist = inv_tree("software.packages:")
for full_name, write_time, size, description, product_version, product_name in info:
parts = full_name.split('\\')
- # 14.02.2014 23:12:04
+ # Since 1.2.6p1 the agent always provides a date format of "04/18/2003
18:06:32".
+ # Old agent versions provided localized date formats which lead to problems here
+ # when none of the implemented parsers matches. We keep the existing parsers for
+ # compatibility, all users with yet unhandled formats should update the agent to
+ # solve the problems.
if re.match("^\d{2}\.\d{2}\.20\d{2} \d{2}:\d{2}:\d{2}", write_time):
install_date = int(time.mktime(time.strptime(write_time, "%d.%m.%Y
%H:%M:%S")))
elif re.match("^\d{1,2}/\d{1,2}/20\d{2} \d{1,2}:\d{2}:\d{2} (AM|PM)",
write_time):
install_date = int(time.mktime(time.strptime(write_time, "%m/%d/%Y
%H:%M:%S %p")))
+ elif re.match("^\d{1,2}/\d{1,2}/20\d{2} \d{1,2}:\d{2}:\d{2}",
write_time):
+ # This is the 1.2.6p1 new default date
+ install_date = int(time.mktime(time.strptime(write_time, "%m/%d/%Y
%H:%M:%S")))
else:
- install_date = write_time
+ install_date = None # need to return 0 to not break the painter which assumes
an int
entry = {
"name" : parts[-1],