From ef01260a7d69e6258bc2ade9e78c31d8f6a4ff40 Mon Sep 17 00:00:00 2001 From: nachmi Date: Wed, 26 Apr 2017 17:11:05 +0100 Subject: [PATCH] Fix bug parse data when --status-versio is set to "2.4.13" Now parse function returns the same data for both apache2 server-status output. --- bin/check_apache | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/bin/check_apache b/bin/check_apache index c4e6dbd..b05e546 100755 --- a/bin/check_apache +++ b/bin/check_apache @@ -134,17 +134,13 @@ def parse(data, version): # First remove server name on first line data = data.splitlines(False) data = data[1:] - # Then remove lines with dates (and more than : delimiter in it) - lines=[] - for l in data: - if l.startswith('Server Built'): - continue - if l.startswith('CurrentTime'): - continue - if l.startswith('RestartTime'): - continue - lines.append(l) - data = "\n".join(lines) + stats = ["BytesPerSec CPULoad", "BusyWorkers", "ReqPerSec", "BytesPerReq", "Scoreboard"] + _data = [] + for item in data: + for i in stats: + if i in item: + _data.append(item) + data = "\n".join(_data) # Clean out certain chars replace = '() ' csvobj = csv.reader(StringIO.StringIO(data), delimiter = ":", skipinitialspace = True)