Module: check_mk
Branch: master
Commit: eec68385c04b9301c2346a5ca850f2d66cedbb10
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=eec68385c04b93…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Nov 11 13:03:06 2015 +0100
#2763 apache_status: Can now be configured to use the protocols default port
When specifiying None as port number, no port number is used to contact
the web server. The resulting service will also only contain the host name
without the tailing :[port].
---
.werks/2763 | 11 +++++++++++
ChangeLog | 1 +
agents/plugins/apache_status | 10 ++++++----
checks/apache_status | 5 ++++-
4 files changed, 22 insertions(+), 5 deletions(-)
diff --git a/.werks/2763 b/.werks/2763
new file mode 100644
index 0000000..86600b4
--- /dev/null
+++ b/.werks/2763
@@ -0,0 +1,11 @@
+Title: apache_status: Can now be configured to use the protocols default port
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.7i4
+Date: 1447243247
+Class: feature
+
+When specifiying None as port number, no port number is used to contact
+the web server. The resulting service will also only contain the host name
+without the tailing :[port].
diff --git a/ChangeLog b/ChangeLog
index b6417a3..e7c9e05 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -25,6 +25,7 @@
* 2707 winperf_processor: can now be configured to warn if a single cpu core exceeds
a utilization threshold for a while...
* 2708 sap, sap_state: new sap_state service reports connection problems to sap
hosts...
* 2740 local: better warning output in case of invalid agent output
+ * 2763 apache_status: Can now be configured to use the protocols default port...
* 2660 FIX: fixed windows agent using the wrong working directory...
* 2664 FIX: ps: Speedup in situation with many matching processes...
* 2661 FIX: windows agent: fixed incomplete process list...
diff --git a/agents/plugins/apache_status b/agents/plugins/apache_status
index f06b05d..43978b6 100755
--- a/agents/plugins/apache_status
+++ b/agents/plugins/apache_status
@@ -128,8 +128,10 @@ for server in servers:
port = server['port']
page = server.get('page', 'server-status')
+ portspec = port and ":%d" % port or ""
+
try:
- url = '%s://%s:%s/%s?auto' % (proto, address, port, page)
+ url = '%s://%s%s/%s?auto' % (proto, address, portspec, page)
# Try to fetch the status page for each server
try:
request = urllib2.Request(url, headers={"Accept" :
"text/plain"})
@@ -138,7 +140,7 @@ for server in servers:
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)
+ url = 'http://%s%s/server-status?auto' % (address, portspec)
fd = urllib2.urlopen(url)
else:
raise
@@ -151,7 +153,7 @@ for server in servers:
break
print address, port, line
except urllib2.HTTPError, e:
- sys.stderr.write('HTTP-Error (%s:%d): %s %s\n' % (address, port, e.code,
e))
+ sys.stderr.write('HTTP-Error (%s%s): %s %s\n' % (address, portspec,
e.code, e))
except Exception, e:
- sys.stderr.write('Exception (%s:%d): %s\n' % (address, port, e))
+ sys.stderr.write('Exception (%s%s): %s\n' % (address, portspec, e))
diff --git a/checks/apache_status b/checks/apache_status
index 14c2109..28b37bd 100644
--- a/checks/apache_status
+++ b/checks/apache_status
@@ -78,7 +78,10 @@ def apache_status_parse(info):
continue # Skip unexpected lines
label = (' '.join(line[2:-1])).rstrip(':')
value = _apache_status_fields[label][1](line[-1])
- item = '%s:%s' % (address, port)
+ if port == None:
+ item = address
+ else:
+ item = '%s:%s' % (address, port)
if item not in data:
data[item] = {}