Module: check_mk
Branch: master
Commit: b9ab41fc943cde29cd599afcb045d626860cb9b2
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b9ab41fc943cde…
Author: Bastian Kuhn <bk(a)mathias-kettner.de>
Date: Wed Oct 29 10:39:14 2014 +0100
#1196 apache_status: Added timeout
The apache_status plugin now has a timeout for the urlopen operation.
---
.werks/1196 | 10 ++++++++++
ChangeLog | 1 +
agents/plugins/apache_status | 6 ++++--
3 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/.werks/1196 b/.werks/1196
new file mode 100644
index 0000000..2068bde
--- /dev/null
+++ b/.werks/1196
@@ -0,0 +1,10 @@
+Title: apache_status: Added timeout
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.5i6
+Date: 1414575509
+Class: feature
+
+The apache_status plugin now has a timeout for the urlopen operation.
+
diff --git a/ChangeLog b/ChangeLog
index 2c9d4f0..84e5d6c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -85,6 +85,7 @@
* 1193 ps: Manual Checks can now use RegEx for user matching...
* 1194 Linux Agent now supports monitoring of cifs mounts
* 1195 AIX Agent now also supports monitoring of cifs mounts
+ * 1196 apache_status: Added timeout...
* 1051 FIX: tcp_conn_stats: fix missing performance data...
* 1142 FIX: winperf_ts_sessions: fix computation, check has never really worked
* 1090 FIX: zfsget: fixed exception which happened on incomplete zfs entries
diff --git a/agents/plugins/apache_status b/agents/plugins/apache_status
index 8def826..de7b187 100755
--- a/agents/plugins/apache_status
+++ b/agents/plugins/apache_status
@@ -45,6 +45,8 @@ import os, sys, urllib2, re
config_dir = os.getenv("MK_CONFDIR", "/etc/check_mk")
config_file = config_dir + "/apache_status.conf"
+timeout = 5
+
if not os.path.exists(config_file):
config_file = config_dir + "/apache_status.cfg"
@@ -127,13 +129,13 @@ for server in servers:
# Try to fetch the status page for each server
try:
request = urllib2.Request(url, headers={"Accept" :
"text/plain"})
- fd = urllib2.urlopen(request)
+ fd = urllib2.urlopen(request, timeout=timeout)
except urllib2.URLError, e:
if 'SSL23_GET_SERVER_HELLO:unknown protocol' in str(e):
# HACK: workaround misconfigurations where port 443 is used for
# serving non ssl secured http
url = 'http://%s:%s/server-status?auto' % (address, port)
- fd = urllib2.urlopen(url)
+ fd = urllib2.urlopen(url, timeout=timeout)
else:
raise