-
-
Save ralphbean/5578517 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# A script to count the number of current and maximum fedmsg zeromq connections | |
# Author: Luke Macken <[email protected]> | |
# License: GPLv3 | |
import os | |
import requests | |
from BeautifulSoup import BeautifulSoup | |
cur_sessions = 0 | |
max_sessions = 0 | |
for proxy in range(1, 9): | |
r = requests.get("https://admin.fedoraproject.org/haproxy/proxy0%d" % proxy) | |
soup = BeautifulSoup(r.text) | |
outbound = soup.find('a', {'class': 'lfsb', 'href': '#fedmsg-raw-zmq-outbound/Frontend'}) | |
cur = outbound.next.next.next.next.next.next.next.next.next.next | |
max = cur.next.next | |
print("proxy0%d: %s (%s max)" % (proxy, cur, max)) | |
cur_sessions += int(cur) | |
max_sessions += int(max) | |
msg = "%d(%d)" % (cur_sessions, max_sessions) | |
filename = os.path.expanduser("~/.cache/fedmsg.dat") | |
print "Writing", msg, "to", filename | |
with open(filename, "w") as f: | |
f.write(msg) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment