Last active
December 17, 2015 08:09
-
-
Save lmacken/5578372 to your computer and use it in GitHub Desktop.
Count the number of current and maximum fedmsg zeromq connections
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
# A script to count the number of current and maximum fedmsg zeromq connections | |
# Author: Luke Macken <[email protected]> | |
# License: GPLv3 | |
import requests | |
from multiprocessing.pool import ThreadPool | |
from BeautifulSoup import BeautifulSoup | |
num_proxies = 8 | |
cur_sessions = 0 | |
max_sessions = 0 | |
def poll_proxy(proxy): | |
global cur_sessions, max_sessions | |
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) | |
pool = ThreadPool(num_proxies) | |
pool.map(poll_proxy, range(1, num_proxies + 1)) | |
print("total: %d current sessions (%d max)" % (cur_sessions, max_sessions)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment