Module: check_mk
Branch: master
Commit: 64c6e23f074ba9ce45702cfa7cd57688f1ceef57
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=64c6e23f074ba9…
Author: Sven Rueß <sr(a)mathias-kettner.de>
Date: Fri Mar 3 15:42:10 2017 +0100
8285 FIX apache_status: Fixed wrong IPv6 URLs to query the information
If the information from Apache is queried by IPv6, the request was denied,
because we created a bad request. Now IPv6 addresses are surrounded by
square bracket.
Service description for IPv6 Apache status information services will change,
because the general CIDR notation will be used as new service description.
In version 1.2.8 and 1.4.0:
Apache ::1:80 Status
Apache 2001:cdba::3257:9652:443 Status
Since version 1.5.0:
Apache [::1]:80 Status
Apache [2001:cdba::3257:9652]:443 Status
If historic information should not be lost and graphs should be continued,
then you have to follow three steps:
<ul>
<li>Rename existing RRDs to new service description:
Example:
mv Apache___1_80_Status.rrd Apache_[__1]_80_Status.rrd
mv Apache_2001_cdba__3257_9652_443_Status.rrd
Apache_[2001_cdba__3257_9652]_443_Status.rrd
</li>
<li>Update apache_status plugin on monitored hosts</li>
<li>Make a service discovery of the affected hosts</li>
</ul>
Change-Id: I59ba71ed27a445dc4606cc986bb3e34a1901edc6
---
.werks/8285 | 36 ++++++++++++++++++++++++++++++++++++
agents/plugins/apache_status | 16 ++++++++++++----
2 files changed, 48 insertions(+), 4 deletions(-)
diff --git a/.werks/8285 b/.werks/8285
new file mode 100644
index 0000000..555462b
--- /dev/null
+++ b/.werks/8285
@@ -0,0 +1,36 @@
+Title: apache_status: Fixed wrong IPv6 URLs to query the information
+Level: 1
+Component: checks
+Compatible: incomp
+Edition: cee
+Version: 1.5.0i1
+Date: 1488549674
+Class: fix
+
+If the information from Apache is queried by IPv6, the request was denied,
+because we created a bad request. Now IPv6 addresses are surrounded by
+square bracket.
+
+Service description for IPv6 Apache status information services will change,
+because the general CIDR notation will be used as new service description.
+
+In version 1.2.8 and 1.4.0:
+Apache ::1:80 Status
+Apache 2001:cdba::3257:9652:443 Status
+
+Since version 1.5.0:
+Apache [::1]:80 Status
+Apache [2001:cdba::3257:9652]:443 Status
+
+If historic information should not be lost and graphs should be continued,
+then you have to follow three steps:
+
+<ul>
+ <li>Rename existing RRDs to new service description:
+ Example:
+ mv Apache___1_80_Status.rrd Apache_[__1]_80_Status.rrd
+ mv Apache_2001_cdba__3257_9652_443_Status.rrd
Apache_[2001_cdba__3257_9652]_443_Status.rrd
+ </li>
+ <li>Update apache_status plugin on monitored hosts</li>
+ <li>Make a service discovery of the affected hosts</li>
+</ul>
diff --git a/agents/plugins/apache_status b/agents/plugins/apache_status
index 2c986f9..d92f15d 100755
--- a/agents/plugins/apache_status
+++ b/agents/plugins/apache_status
@@ -63,9 +63,11 @@ ssl_ports = [ 443, ]
if os.path.exists(config_file):
execfile(config_file)
+
def try_detect_servers():
pids = []
results = []
+
for line in os.popen('netstat -tlnp 2>/dev/null').readlines():
parts = line.split()
# Skip lines with wrong format
@@ -91,7 +93,6 @@ def try_detect_servers():
continue
pids.append(pid)
- proto = 'http'
address, port = parts[3].rsplit(':', 1)
port = int(port)
@@ -99,17 +100,22 @@ def try_detect_servers():
if address == '0.0.0.0':
address = '127.0.0.1'
elif address == '::':
- address = '::1'
+ address = '[::1]'
+ elif ':' in address:
+ address = '[%s]' % address
# Switch protocol if port is SSL port. In case you use SSL on another
# port you would have to change/extend the ssl_port list
if port in ssl_ports:
proto = 'https'
+ else:
+ proto = 'http'
results.append((proto, address, port))
return results
+
if servers is None:
servers = try_detect_servers()
@@ -117,6 +123,7 @@ if servers is None:
if not servers:
sys.exit(0)
+
sys.stdout.write('<<<apache_status>>>\n')
for server in servers:
if isinstance(server, tuple):
@@ -147,7 +154,7 @@ for server in servers:
except Exception, e:
if 'doesn\'t match' in str(e):
# HACK: workaround if SSL port is found and localhost is using
- # SSL connections but certifiacte is mismatched
+ # SSL connections but certificate does not match
portspec = ':80'
url = 'http://%s%s/server-status?auto' % (address, portspec)
fd = urllib2.urlopen(url)
@@ -158,8 +165,9 @@ for server in servers:
if not line.strip():
continue
if line.lstrip()[0] == '<':
- # seems to be html output. Skip this server.
+ # Seems to be html output. Skip this server.
break
+
sys.stdout.write("%s %s %s\n" % (address, port, line))
except urllib2.HTTPError, e:
sys.stderr.write('HTTP-Error (%s%s): %s %s\n' % (address, portspec,
e.code, e))