Module: check_mk
Branch: master
Commit: 9cb2388bdb560ea57e3f468569a34e02ecc7360d
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=9cb2388bdb560e…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Dec 9 10:31:19 2013 +0100
FIX apache_status: Fixed exception when agent reports HTML code as apache-status data
When the apache-status module is not enabled or the webserver is somehow missconfigured,
the agents HTTP request to the apache-status URL might return HTML code instead of the
expected textual response. Added code to detect HTML code and skip the webserver instance
in this case.
---
.werks/305 | 11 +++++++++++
ChangeLog | 1 +
agents/plugins/apache_status | 5 ++++-
3 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/.werks/305 b/.werks/305
new file mode 100644
index 0000000..9bacd05
--- /dev/null
+++ b/.werks/305
@@ -0,0 +1,11 @@
+Title: apache_status: Fixed exception when agent reports HTML code as apache-status data
+Level: 1
+Component: checks
+Version: 1.2.3i8
+Date: 1386581355
+Class: fix
+
+When the apache-status module is not enabled or the webserver is somehow missconfigured,
+the agents HTTP request to the apache-status URL might return HTML code instead of the
+expected textual response. Added code to detect HTML code and skip the webserver
instance
+in this case.
diff --git a/ChangeLog b/ChangeLog
index 1a67109..89a7192 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,7 @@
* 0103 FIX: services: Fixed bug with service inventory defined in main.mk...
* 0299 FIX: borcade_mlx_fan: Prettified output, handling "other" state now
* 0300 FIX: cisco_fru_power: Trying not to inventorize not plugged in FRUs...
+ * 0305 FIX: apache_status: Fixed exception when agent reports HTML code as
apache-status data...
Multisite:
* 0302 FIX: Fixed highlight of choosen elements in foldertee/views snapin in
Chrome/IE
diff --git a/agents/plugins/apache_status b/agents/plugins/apache_status
index 79d9de3..f2bd8fa 100755
--- a/agents/plugins/apache_status
+++ b/agents/plugins/apache_status
@@ -20,7 +20,7 @@
import os, sys, urllib2, re
-config_dir = os.getenv("MK_CONFDIR", "/etc/check_mk")
+config_dir = os.getenv("MK_CONFDIR", "/etc/check_mk")
config_file = config_dir + "/apache_status.conf"
if not os.path.exists(config_file):
config_file = config_dir + "/apache_status.cfg"
@@ -116,6 +116,9 @@ for server in servers:
for line in fd.read().split('\n'):
if not line.strip():
continue
+ if line.lstrip()[0] == '<':
+ # seems to be html output. Skip this server.
+ break
print address, port, line
except urllib2.HTTPError, e:
sys.stderr.write('HTTP-Error (%s:%d): %s %s\n' % (address, port, e.code,
e))