Module: check_mk
Branch: master
Commit: e789e8da40b2b7ebfcdadfb7ab9fcd9021a95da2
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e789e8da40b2b7…
Author: Konstantin Büttner <kb(a)mathias-kettner.de>
Date: Fri Nov 30 14:33:02 2018 +0100
6981 FIX dell_idrac_info: Fix inventory for certain aberrant date formats
Change-Id: Icfe8a3639d830eb5563f870d6118cce47100b973
---
.werks/6981 | 11 +++++++++++
inventory/dell_idrac_info | 17 ++++++++++++++++-
2 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/.werks/6981 b/.werks/6981
new file mode 100644
index 0000000..dc552de
--- /dev/null
+++ b/.werks/6981
@@ -0,0 +1,11 @@
+Title: dell_idrac_info: Fix inventory for certain aberrant date formats
+Level: 1
+Component: inv
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1543584742
+
+
diff --git a/inventory/dell_idrac_info b/inventory/dell_idrac_info
index 8812dd6..3031189 100644
--- a/inventory/dell_idrac_info
+++ b/inventory/dell_idrac_info
@@ -41,7 +41,22 @@ def inv_dell_idrac_info(info):
node = inv_tree("hardware.bios.")
node['version'] = bios_version
node['vendor'] = bios_vendor
- node['date'] = time.mktime(time.strptime(bios_date, "%m/%d/%Y"))
+
+ # Beware: Dell's actual definition of the format supposed
+ # to be here is yyyymmddHHMMSS.uuuuuu+ooo. This has *never*
+ # been observed in the wild. More accurate appears to be
+ # mm/dd/yyyy or 0mm/dd/yyyy or mm/0dd/yyyy. The 0 represents a
+ # random 0 thrown in for good measure :/
+ if bios_date[2] == "/" and bios_date[5] == "/": # mm/dd/yyyy
+ node['date'] = time.mktime(time.strptime(bios_date,
"%m/%d/%Y"))
+ elif bios_date[3] == "/" and bios_date[6] == "/": # 0mm/dd/yyyy
+ node['date'] = time.mktime(time.strptime(bios_date,
"0%m/%d/%Y"))
+ elif bios_date[2] == "/" and bios_date[6] == "/": # mm/0dd/yyyy
+ node['date'] = time.mktime(time.strptime(bios_date,
"%m/0%d/%Y"))
+ elif "/" not in bios_date[:8]: # In case of Dell devices following the MIB
+ node['date'] = time.mktime(time.strptime(bios_date[:8],
"%Y%m%d"))
+ else: # We deliberately ignore any other broken formats that might exist.
+ pass
node = inv_tree("hardware.storage.controller.")
node['version'] = raid_version