aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Moravec <pmoravec@redhat.com>2017-03-15 22:12:14 +0100
committerBryn M. Reeves <bmr@redhat.com>2017-10-27 14:23:01 +0100
commit6cf81bed12f119c580f9d3a0231aa46b2b165929 (patch)
treeead065d51b4f435615fbdee43722bf5c651f4ed9
parent8abdbbf099b740ab213f51a006fb3c2150a2ec80 (diff)
downloadsos-6cf81bed12f119c580f9d3a0231aa46b2b165929.tar.gz
[haproxy] collect haproxy overview page
Collect 'curl http://$provision_ip:1993/\;csv' Resolves: #961 Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
-rw-r--r--sos/plugins/haproxy.py17
1 files changed, 17 insertions, 0 deletions
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 :