Module: check_mk
Branch: master
Commit: 33c15fa21c98109d9828ade3e4a4c24653a0e678
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=33c15fa21c9810…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Dec 4 09:39:51 2014 +0100
#1624 FIX Remove illegal characters from service descriptions of active checks
This fix removes illegal characters like brackets from service descriptions
of configured active checks (<tt>legacy_checks</tt>,
<tt>custom_checks</tt> and
<tt>active_checks</tt>). These characters are disallowed by Nagios and will
lead to configuration errors.
---
.werks/1624 | 12 ++++++++++++
ChangeLog | 11 ++++++-----
modules/check_mk.py | 12 +++++++++---
3 files changed, 27 insertions(+), 8 deletions(-)
diff --git a/.werks/1624 b/.werks/1624
new file mode 100644
index 0000000..8f43465
--- /dev/null
+++ b/.werks/1624
@@ -0,0 +1,12 @@
+Title: Remove illegal characters from service descriptions of active checks
+Level: 1
+Component: core
+Compatible: compat
+Version: 1.2.5i7
+Date: 1417682307
+Class: fix
+
+This fix removes illegal characters like brackets from service descriptions
+of configured active checks (<tt>legacy_checks</tt>,
<tt>custom_checks</tt> and
+<tt>active_checks</tt>). These characters are disallowed by Nagios and will
+lead to configuration errors.
diff --git a/ChangeLog b/ChangeLog
index 8c35b8a..90a0758 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,7 @@
* 1545 FIX: Check_MK Inventory check is now resulting in correct state on duplicate
host
* 1555 FIX: Improved validation on timeperiod references of non existing periods...
* 1574 FIX: Hosts named like used python modules do not break precompiled checks
anymore...
+ * 1624 FIX: Remove illegal characters from service descriptions of active checks...
Checks & Agents:
* 1197 climaveneta_temp: New check for temperature sensors on Climaveneta clima
devices
@@ -32,10 +33,10 @@
* 1518 raritan_pdu_inlet, raritan_pdu_inlet_summary: Modified existing check to give
one item per phase and support setting levels....
NOTE: Please refer to the migration notes!
* 1592 AIX: New Plugin to monitor errpt in logwatch style...
- * 1594 ibm_svc_host: Can now be set to be always OK...
- * 1595 esx_vsphere_objects_count: New Check to Ouput the number of VMs
* 1565 mem.win: set default levels for page file to 80%/90%
* 1608 zpool_status: Add an overall state check (thx to Craig Cook)...
+ * 1594 ibm_svc_host: Can now be set to be always OK...
+ * 1595 esx_vsphere_objects_count: New Check to Ouput the number of VMs
* 1567 postfix_mailq: speedup in Linux agent for large mail queues...
* 1611 mssql.vbs: Supporting SQL-Server 2014 now
* 1568 f5_bigip_cluster_v11: new check for F5 cluster status for firmware version 11
@@ -67,9 +68,6 @@
* 1572 FIX: Sample configs, plugins etc. for windows agent use windows linebreaks
now...
* 1575 FIX: vSphere Monitoring works with RedHat 5.x now...
* 1584 FIX: winperf_if: Fixed checks of interfaces with equal names but one with
index...
- * 1593 FIX: IBM SVC Checks: The Service Descriptions not longer contain IBM SVC as
prefix...
- NOTE: Please refer to the migration notes!
- * 1596 FIX: etherbox: Fix for the inventory in case of not connected temperature
sensors...
* 1590 FIX: printer_supply_ricoh: Fixed broken check
* 1591 FIX: netapp_volumes: The state mixed_raid_type is now treated as non-critical
state
* 1602 FIX: dell_om_esmlog: Fixed typo in plugin output
@@ -77,10 +75,13 @@
* 1604 FIX: mysql_slave: Dealing with situation where connection with master is lost
* 1563 FIX: Reworked configuration of process monitoring...
NOTE: Please refer to the migration notes!
+ * 1593 FIX: IBM SVC Checks: The Service Descriptions not longer contain IBM SVC as
prefix...
+ NOTE: Please refer to the migration notes!
* 1564 FIX: check_mk_agent.linux: fix situation where async plugin is not executed
after crash...
* 1609 FIX: zpool_status: fix problem when the zpool has a separate log or cache
device...
* 1566 FIX: 3ware_disks: consider VERIFYING state as OK now...
* 1612 FIX: job: Fixed wrong reported start time for running jobs
+ * 1596 FIX: etherbox: Fix for the inventory in case of not connected temperature
sensors...
* 1571 FIX: check_mk_agent.linux: fix output of lnx_if on Ubuntu 8.04 (on older
kernels), repairs tcp_conn_stats...
* 1622 FIX: megaraid_bbu: handle case isSOHGood and consider it as critical...
* 1617 FIX: lnx_if: Deal with data provided by cluster host
diff --git a/modules/check_mk.py b/modules/check_mk.py
index f1afbe8..3820fb9 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -1332,6 +1332,11 @@ def exit_code_spec(hostname):
return spec
+# Remove illegal characters from a service description
+def sanitize_service_description(descr):
+ return "".join([ c for c in descr if c not in nagios_illegal_chars ])
+
+
def service_description(check_type, item):
if check_type not in check_info:
if item:
@@ -1354,7 +1359,7 @@ def service_description(check_type, item):
if type(item) == str:
# Remove characters from item name that are banned by Nagios
- item_safe = "".join([ c for c in item if c not in nagios_illegal_chars
])
+ item_safe = sanitize_service_description(item)
if "%s" not in descr_format:
descr_format += " %s"
return (descr_format % (item_safe,)).strip()
@@ -2290,6 +2295,7 @@ define service {
if len(legchecks) > 0:
outfile.write("\n\n# Legacy checks\n")
for command, description, has_perfdata in legchecks:
+ description = sanitize_service_description(description)
if do_omit_service(hostname, description):
continue
@@ -2341,8 +2347,8 @@ define service {
g_hostname = hostname
has_perfdata = act_info.get('has_perfdata', False)
- description = act_info["service_description"](params)
description = description.replace('$HOSTNAME$', g_hostname)
+ description =
sanitize_service_description(act_info["service_description"](params))
if do_omit_service(hostname, description):
continue
@@ -2395,7 +2401,7 @@ define service {
# "command_name" (optional) Name of Monitoring command to
define. If missing,
# we use "check-mk-custom"
# "has_perfdata" (optional) If present and True, we activate
perf_data
- description = entry["service_description"]
+ description =
sanitize_service_description(entry["service_description"])
has_perfdata = entry.get("has_perfdata", False)
command_name = entry.get("command_name",
"check-mk-custom")
command_line = entry.get("command_line", "")