Skip to content

Instantly share code, notes, and snippets.

@mmaridev
Created April 6, 2020 13:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mmaridev/b24b33af3dc6a924f903d83df4affbde to your computer and use it in GitHub Desktop.
Save mmaridev/b24b33af3dc6a924f903d83df4affbde to your computer and use it in GitHub Desktop.
BigBlueButton monitoring via Python 3 script
#!/usr/bin/python3
# Copyright (c) 2020 Marco Marinello <mmarinello@fuss.bz.it>
import sys, requests
from xml.etree.ElementTree import fromstring, ElementTree
SERVER = sys.argv[1]
SUM = sys.argv[2]
QUERY = sys.argv[3]
ct = requests.get(
"https://{}/bigbluebutton/api/getMeetings?checksum={}".format(
SERVER, SUM
)
).text
tree = ElementTree(fromstring(ct))
root = tree.getroot()
if QUERY == "webcam":
total = 0
if not "meetings" in map(lambda s: s.tag, root):
print("0")
exit()
for meeting in root.find("meetings"):
if meeting.find("videoCount") is not None:
total += int(meeting.find("videoCount").text)
print(total)
elif QUERY == "meetings":
try:
print(len(root.find("meetings")))
except TypeError:
print("0")
elif QUERY == "totusers":
total = 0
if not "meetings" in map(lambda s: s.tag, root):
print("0")
exit()
for meeting in root.find("meetings"):
if meeting.find("participantCount") is not None:
total += int(meeting.find("participantCount").text)
print(total)
elif QUERY == "mics":
total = 0
if not "meetings" in map(lambda s: s.tag, root):
print("0")
exit()
for meeting in root.find("meetings"):
if meeting.find("voiceParticipantCount") is not None:
total += int(meeting.find("voiceParticipantCount").text)
print(total)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment