Commit 6764e5a2 authored by ulif's avatar ulif 🐻

Add role to setup munin-node monitoring.

parent 48b4bd92
munin_server_ipv4: ""
munin_server_ipv6: ""
# Frank Schiebel
# Adapted for munin by ulif <>
# GPL v3
import sys
import socket
import hashlib
import requests
import subprocess
from collections import defaultdict
from xml.dom.minidom import parse, parseString
def get_api_checksum():
"""Get API Secret
output = subprocess.check_output(['bbb-conf', '--secret']).decode('utf-8')
secret = [x.strip() for x in output.split('\n') if 'Secret: ' in x][0].split(" ")[-1]
qstringwithsecret = "getMeetings" + secret
return hashlib.sha1(qstringwithsecret.encode('utf-8')).hexdigest()
def get_meeting_data(checksum):
"""Request current traffic data
from BBB via XML API.
fqdn = socket.getfqdn()
full_query_uri = "https://%s/bigbluebutton/api/getMeetings?checksum=%s" % (fqdn, checksum)
result = requests.get(full_query_uri)
return result.status_code, result.text
(status, xml) = get_meeting_data(get_api_checksum())
numMeetings = 0
numAttendees = 0
numWithVideo = 0
numWithVoice = 0
numListeners = 0
if status != 200:
print("HTTP return code was not 200/OK")
meetingdata = parseString(xml)
if returncode != "SUCCESS":
print("API returncode was not SUCCESS")
# get numbers from active meetings
for m in meetings:
p = m.getElementsByTagName("bbb-origin-server-name")[0]
numMeetings += 1
p = m.getElementsByTagName("participantCount")[0]
numAttendees += int(p.firstChild.wholeText)
p = m.getElementsByTagName("listenerCount")[0]
numListeners += int(p.firstChild.wholeText)
p = m.getElementsByTagName("voiceParticipantCount")[0]
numWithVoice += int(p.firstChild.wholeText)
p = m.getElementsByTagName("videoCount")[0]
numWithVideo += int(p.firstChild.wholeText)
if "autoconf" in sys.argv:
elif "config" in sys.argv:
print("graph_order attendees listeners voice video meetings ")
print("graph_title BigBlueButton conferences")
print("graph_args --base 1000 -l 0")
print("graph_category system")
print("attendees.label attendees")
print("attendees.type DERIVE")
print(" Number of attendees")
print("attendees.draw AREA")
print("meetings.label meetings")
print("meetings.type DERIVE")
print(" Number of active conferences")
print("video.label video")
print("video.type DERIVE")
print(" Number of video streams")
print("video.draw STACK")
print("voice.label voice")
print("voice.type DERIVE")
print(" Number of voice streams")
print("voice.draw STACK")
print("listeners.label listeners")
print("listeners.type DERIVE")
print(" Number of listening attendees")
print("listeners.draw STACK")
print("meetings.value %s" % numMeetings)
print("attendees.value %s" % numAttendees)
print("video.value %s" % numWithVideo)
print("voice.value %s" % numWithVoice)
print("listeners.value %s" % numListeners)
[Munin Node]
title=Munin Node
description=Daemon gathering system metrics
- name: restart munin_node
service: name=munin-node state=restarted
# Enable monitoring with munin
- name: install packages for monitoring
- smartmontools
- munin-node
state: latest
- name: check if ufw rules dir exists
path: /etc/ufw/applications.d
register: ufw_dir
- name: Copy ufw rules to target
src: files/munin_node.ufw
dest: /etc/ufw/applications.d/munin-node
owner: root
group: root
mode: 0644
when: ufw_dir.stat.exists == true
# in case there is no munin server ip defines, we allow access from everywhere
- name: allow munin server to access node in ufw (all IPs allowed)
rule: allow
name: "Munin Node"
state: enabled
when: ufw_dir.stat.exists == true and not munin_server_ipv4 and not munin_server_ipv6
- name: allow munin server to access node through ufw (certain server, ipv4)
rule: allow
proto: tcp
src: "{{ munin_server_ipv4 }}"
port: "4949"
when: munin_server_ipv4 | length
- name: allow munin server to access node through ufw (certain server, ipv6)
rule: allow
proto: tcp
src: "{{ munin_server_ipv6 }}"
port: "4949"
when: munin_server_ipv6 | length
- name: Copy to /etc/munin/plugins/bbb on target
dest: /etc/munin/plugins/bbb
owner: root
group: root
mode: 0755
notify: restart munin_node
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment