Created
April 6, 2020 13:46
-
-
Save mmaridev/b24b33af3dc6a924f903d83df4affbde to your computer and use it in GitHub Desktop.
BigBlueButton monitoring via Python 3 script
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/python3 | |
# Copyright (c) 2020 Marco Marinello <[email protected]> | |
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