Module: check_mk
Branch: master
Commit: 737bf92495e5fdd9df2f7a055f655f1aa621e739
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=737bf92495e5fd…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Nov 22 08:50:44 2012 +0100
apache_status: Modified to be usable on python < 2.6 (eg RHEL 5.x)
---
ChangeLog | 1 +
agents/plugins/apache_status | 16 +++++++++-------
2 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 38056c5..1d51143 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,7 @@
* Linux Agent, mk_postgres: Supporting pgsql and postgres as user
* Linux Agent, mk_postgres: Fixed database stats query to be compatible
with more versions of postgres
+ * apache_status: Modified to be usable on python < 2.6 (eg RHEL 5.x)
Multisite:
* Implemented LDAP integration of Multisite. You can now authenticate your
diff --git a/agents/plugins/apache_status b/agents/plugins/apache_status
index dd0c607..fd63734 100755
--- a/agents/plugins/apache_status
+++ b/agents/plugins/apache_status
@@ -18,7 +18,7 @@
# It is also possible to override or extend the ssl_ports variable to make the
# check contact other ports than 443 with HTTPS requests.
-import os, sys, urllib
+import os, sys, urllib2
config_file = os.getenv("MK_CONFDIR", "/etc/check_mk") +
"/apache_status.conf"
@@ -79,11 +79,13 @@ for proto, address, port in servers:
try:
# Try to fetch the status page for each server
url = '%s://%s:%s/server-status?auto' % (proto, address, port)
- fd = urllib.urlopen(url)
- if fd.getcode() == 200:
- for line in fd.read().split('\n'):
- if not line.strip():
- continue
- print address, port, line
+ fd = urllib2.urlopen(url)
+ for line in fd.read().split('\n'):
+ if not line.strip():
+ continue
+ print address, port, line
+ except urllib2.HTTPError, e:
+ sys.stderr.write('HTTP-Error (%s:%d): %s %s\n' % (address, port, e.code,
e))
+
except Exception, e:
sys.stderr.write('Exception (%s:%d): %s\n' % (address, port, e))