aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Moravec <pmoravec@redhat.com>2017-12-05 12:52:40 +0100
committerBryn M. Reeves <bmr@redhat.com>2017-12-08 13:07:39 +0000
commit119593cff13b1d1d8d34b11fbb92893d70e634d6 (patch)
tree0677a80aebe5983c8426ba7829c78d4bc3ca5e75
parentae56ea578fe6f7443d2dce73e2b8fcf2bd5542d1 (diff)
downloadsos-119593cff13b1d1d8d34b11fbb92893d70e634d6.tar.gz
[haproxy] catch exception when parsing haproxy.cfg
catch exception when parsed haproxy.cfg file isnt accessible Resolves: #1160 Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
-rw-r--r--sos/plugins/haproxy.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/sos/plugins/haproxy.py b/sos/plugins/haproxy.py
index eb696c9f..1807e6d7 100644
--- a/sos/plugins/haproxy.py
+++ b/sos/plugins/haproxy.py
@@ -49,11 +49,15 @@ class HAProxy(Plugin, RedHatPlugin, DebianPlugin):
# from the next line
matched = None
provision_ip = None
- for line in open("/etc/haproxy/haproxy.cfg").read().splitlines():
- if matched:
- provision_ip = line.split()[1]
- break
- matched = match(".*haproxy\.stats.*", line)
+ try:
+ for line in open("/etc/haproxy/haproxy.cfg").read().splitlines():
+ if matched:
+ provision_ip = line.split()[1]
+ break
+ matched = match(".*haproxy\.stats.*", line)
+ except:
+ # fallback when the cfg file is not accessible
+ pass
if not provision_ip:
return