[checkmk-commits] Check_MK Git: check_mk: #2022 FIX SNMP: Fixed handling of backslashes in SNMP data

Lars Michelsen lm at mathias-kettner.de
Thu Feb 26 15:54:41 CET 2015


Module: check_mk
Branch: master
Commit: efd56aa0dc2b4126edadc1e472ad9fcdf94c2594
URL:    http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=efd56aa0dc2b4126edadc1e472ad9fcdf94c2594

Author: Lars Michelsen <lm at mathias-kettner.de>
Date:   Thu Feb 26 15:50:20 2015 +0100

#2022 FIX SNMP: Fixed handling of backslashes in SNMP data

Some checks like the hr_fs checks e.g. create services with
backslashes in the service descriptions when monitoring
windows filesystems. Those services were named "Filesystem c:\\..."
for example, which was using a double backslash which is wrong.
This behaviour has now been changed to just use a single slash.

With this change your services will be reported as UNKNOWN when
you have such services with double backslashes in their names.
You will then need to rediscover the services to get them with
just a single slash. If you like to keep the performance graph
history, you will need to migrate them on your own.

---

 .werks/2022     |   19 +++++++++++++++++++
 ChangeLog       |    2 ++
 modules/snmp.py |    6 +++++-
 3 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/.werks/2022 b/.werks/2022
new file mode 100644
index 0000000..ca275be
--- /dev/null
+++ b/.werks/2022
@@ -0,0 +1,19 @@
+Title: SNMP: Fixed handling of backslashes in SNMP data
+Level: 2
+Component: checks
+Compatible: incomp
+Version: 1.2.7i1
+Date: 1424962027
+Class: fix
+
+Some checks like the hr_fs checks e.g. create services with
+backslashes in the service descriptions when monitoring
+windows filesystems. Those services were named "Filesystem c:\\..."
+for example, which was using a double backslash which is wrong.
+This behaviour has now been changed to just use a single slash.
+
+With this change your services will be reported as UNKNOWN when
+you have such services with double backslashes in their names.
+You will then need to rediscover the services to get them with
+just a single slash. If you like to keep the performance graph
+history, you will need to migrate them on your own.
diff --git a/ChangeLog b/ChangeLog
index 6f9d88e..cee1858 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -200,6 +200,8 @@
     * 2048 FIX: netapp_api_fan, netapp_api_psu, netapp_api_temp: fixed typo in service description Shelfes -> Shelves
             NOTE: Please refer to the migration notes!
     * 2021 FIX: if_lancom: Also used for checking ELSA/T-Systems branded devices
+    * 2022 FIX: SNMP: Fixed handling of backslashes in SNMP data...
+            NOTE: Please refer to the migration notes!
 
     Multisite:
     * 1758 Improved exception hander: Shows details without additional debug request, added mailto link for error report...
diff --git a/modules/snmp.py b/modules/snmp.py
index 4225dc4..cbd955f 100644
--- a/modules/snmp.py
+++ b/modules/snmp.py
@@ -41,7 +41,11 @@ def strip_snmp_value(value, hex_plain = False):
         if len(v) > 2 and is_hex_string(v):
             return not hex_plain and convert_from_hex(v) or value
         else:
-            return v.strip()
+            # Fix for non hex encoded string which have been somehow encoded by the
+            # netsnmp command line tools. An example:
+            # Checking windows systems via SNMP with hr_fs: disk names like c:\
+            # are reported as c:\\, fix this to single \
+            return v.strip().replace('\\\\', '\\')
     else:
         return v
 



More information about the checkmk-commits mailing list