Skip to content

Instantly share code, notes, and snippets.

@ralphbean
Forked from lmacken/fedmsg-sessions.py
Last active December 17, 2015 08:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ralphbean/5578517 to your computer and use it in GitHub Desktop.
Save ralphbean/5578517 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# A script to count the number of current and maximum fedmsg zeromq connections
# Author: Luke Macken <lmacken@redhat.com>
# 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