From ae6f7ce3f0c2b18db6977ee286b358f8b799866d Mon Sep 17 00:00:00 2001 From: Eric Risler Date: Mon, 27 Feb 2017 12:27:54 -0500 Subject: [PATCH 1/2] Fix for #10 and #9 I'm no python guy so please review. #9: https://github.com/gpmidi/zabbix-apache-stats/issues/9 #10: https://github.com/gpmidi/zabbix-apache-stats/issues/10 Apache server-status that outputs the TLSSessionCacheStatus section breaks the csv reader since that line contains no ":". I've added a breakout condition to end parsing the server-status after the Scorebaord status. --- bin/check_apache | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bin/check_apache b/bin/check_apache index c4e6dbd..05aaa32 100755 --- a/bin/check_apache +++ b/bin/check_apache @@ -149,8 +149,11 @@ def parse(data, version): replace = '() ' csvobj = csv.reader(StringIO.StringIO(data), delimiter = ":", skipinitialspace = True) ret = {} + breakout = False for (key, val) in csvobj: if key == 'Scoreboard': + # end processing at Scorboard key + breakout = True sb = { "Waiting for Connection":0, "Starting up":0, @@ -169,6 +172,8 @@ def parse(data, version): ret[key] = sb else: ret[key] = val + if breakout == True: + break ret2 = {} for (key, val) in ret.items(): if key == "Scoreboard": From 531ee8092c64d9db23586a776f522de65622c765 Mon Sep 17 00:00:00 2001 From: Eric Risler Date: Mon, 27 Feb 2017 12:49:40 -0500 Subject: [PATCH 2/2] Fix for #9, #10 Skip "TLSSessionCacheStatus" line as it causes parse error. Fix for: https://github.com/gpmidi/zabbix-apache-stats/issues/9 and https://github.com/gpmidi/zabbix-apache-stats/issues/10 --- bin/check_apache | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/bin/check_apache b/bin/check_apache index 05aaa32..21f0d3f 100755 --- a/bin/check_apache +++ b/bin/check_apache @@ -143,17 +143,16 @@ def parse(data, version): continue if l.startswith('RestartTime'): continue + if l.startswith('TLSSessionCacheStatus'): + continue lines.append(l) data = "\n".join(lines) # Clean out certain chars replace = '() ' csvobj = csv.reader(StringIO.StringIO(data), delimiter = ":", skipinitialspace = True) ret = {} - breakout = False for (key, val) in csvobj: if key == 'Scoreboard': - # end processing at Scorboard key - breakout = True sb = { "Waiting for Connection":0, "Starting up":0, @@ -172,8 +171,6 @@ def parse(data, version): ret[key] = sb else: ret[key] = val - if breakout == True: - break ret2 = {} for (key, val) in ret.items(): if key == "Scoreboard":