Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
bbb-dc-ansible
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ulif
bbb-dc-ansible
Commits
6764e5a2
Commit
6764e5a2
authored
May 13, 2020
by
ulif
🐻
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add role to setup munin-node monitoring.
parent
48b4bd92
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
175 additions
and
0 deletions
+175
-0
roles/munin-node/defaults/main.yml
roles/munin-node/defaults/main.yml
+2
-0
roles/munin-node/files/bbb.py
roles/munin-node/files/bbb.py
+113
-0
roles/munin-node/files/munin_node.ufw
roles/munin-node/files/munin_node.ufw
+4
-0
roles/munin-node/handlers/main.yml
roles/munin-node/handlers/main.yml
+2
-0
roles/munin-node/tasks/main.yml
roles/munin-node/tasks/main.yml
+54
-0
No files found.
roles/munin-node/defaults/main.yml
0 → 100644
View file @
6764e5a2
munin_server_ipv4
:
"
"
munin_server_ipv6
:
"
"
roles/munin-node/files/bbb.py
0 → 100755
View file @
6764e5a2
#!/usr/bin/python3
#
# bbb.py
# Frank Schiebel frank@linuxmuster.net
# Adapted for munin by ulif <ulif@riseup.net>
# 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
cf. https://docs.bigbluebutton.org/dev/api.html
"""
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"
)
sys
.
exit
(
-
1
)
meetingdata
=
parseString
(
xml
)
returncode
=
meetingdata
.
getElementsByTagName
(
"returncode"
)[
0
]
returncode
=
returncode
.
firstChild
.
wholeText
if
returncode
!=
"SUCCESS"
:
print
(
"API returncode was not SUCCESS"
)
sys
.
exit
(
-
1
)
# get numbers from active meetings
meetings
=
meetingdata
.
getElementsByTagName
(
"meeting"
)
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
:
print
(
"yes"
)
sys
.
exit
(
0
)
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
(
"attendees.info Number of attendees"
)
print
(
"attendees.draw AREA"
)
print
(
"meetings.label meetings"
)
print
(
"meetings.type DERIVE"
)
print
(
"meetings.info Number of active conferences"
)
print
(
"video.label video"
)
print
(
"video.type DERIVE"
)
print
(
"video.info Number of video streams"
)
print
(
"video.draw STACK"
)
print
(
"voice.label voice"
)
print
(
"voice.type DERIVE"
)
print
(
"voice.info Number of voice streams"
)
print
(
"voice.draw STACK"
)
print
(
"listeners.label listeners"
)
print
(
"listeners.type DERIVE"
)
print
(
"listeners.info Number of listening attendees"
)
print
(
"listeners.draw STACK"
)
sys
.
exit
(
0
)
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
)
sys
.
exit
(
0
)
roles/munin-node/files/munin_node.ufw
0 → 100644
View file @
6764e5a2
[Munin Node]
title=Munin Node
description=Daemon gathering system metrics
ports=4949/tcp
roles/munin-node/handlers/main.yml
0 → 100644
View file @
6764e5a2
-
name
:
restart munin_node
service
:
name=munin-node state=restarted
roles/munin-node/tasks/main.yml
0 → 100644
View file @
6764e5a2
# Enable monitoring with munin
-
name
:
install packages for monitoring
apt
:
name
:
-
smartmontools
-
munin-node
state
:
latest
-
name
:
check if ufw rules dir exists
stat
:
path
:
/etc/ufw/applications.d
register
:
ufw_dir
-
name
:
Copy ufw rules to target
copy
:
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)
ufw
:
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)
ufw
:
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)
ufw
:
rule
:
allow
proto
:
tcp
src
:
"
{{
munin_server_ipv6
}}"
port
:
"
4949"
when
:
munin_server_ipv6 | length
-
name
:
Copy bbb.py to /etc/munin/plugins/bbb on target
copy
:
src
:
bbb.py
dest
:
/etc/munin/plugins/bbb
owner
:
root
group
:
root
mode
:
0755
notify
:
restart munin_node
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment