Skip to content

Instantly share code, notes, and snippets.

@lmacken
Last active December 17, 2015 08:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lmacken/5578372 to your computer and use it in GitHub Desktop.
Save lmacken/5578372 to your computer and use it in GitHub Desktop.
Count the number of current and maximum fedmsg zeromq connections
# A script to count the number of current and maximum fedmsg zeromq connections
# Author: Luke Macken <lmacken@redhat.com>
# 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