From 6cf81bed12f119c580f9d3a0231aa46b2b165929 Mon Sep 17 00:00:00 2001 From: Pavel Moravec Date: Wed, 15 Mar 2017 22:12:14 +0100 Subject: [haproxy] collect haproxy overview page Collect 'curl http://$provision_ip:1993/\;csv' Resolves: #961 Signed-off-by: Pavel Moravec --- sos/plugins/haproxy.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/sos/plugins/haproxy.py b/sos/plugins/haproxy.py index 90845068..b945b723 100644 --- a/sos/plugins/haproxy.py +++ b/sos/plugins/haproxy.py @@ -15,6 +15,7 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. from sos.plugins import Plugin, RedHatPlugin, DebianPlugin +from urlparse import urlparse class HAProxy(Plugin, RedHatPlugin, DebianPlugin): @@ -37,4 +38,20 @@ class HAProxy(Plugin, RedHatPlugin, DebianPlugin): self.add_copy_spec("/var/log/haproxy.log") + # collect haproxy overview - curl to IP address taken from haproxy.cfg + # as 2nd word on line below "haproxy.stats" + # so parse haproxy.cfg until "haproxy.stats" read, and take 2nd word + # from the next line + matched = None + for line in open("/etc/haproxy/haproxy.cfg").read().splitlines(): + if matched: + provision_ip = line.split()[1] + break + matched = match(".*haproxy\.stats.*", line) + # check if provision_ip contains port - if not, add default ":1993" + if urlparse("http://"+provision_ip).port is None: + provision_ip = provision_ip + ":1993" + self.add_cmd_output("curl http://"+provision_ip+"/\;csv", + suggest_filename="haproxy_overview.txt") + # vim: set et ts=4 sw=4 : -- cgit