Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
bbbmon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bbb
bbbmon
Commits
9e07d4bc
Commit
9e07d4bc
authored
5 years ago
by
David Huss
Browse files
Options
Downloads
Patches
Plain Diff
Add --twolines flag
parent
225da055
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
bbbmon/bbbmon.py
+11
-4
11 additions, 4 deletions
bbbmon/bbbmon.py
bbbmon/meetings.py
+61
-0
61 additions, 0 deletions
bbbmon/meetings.py
with
72 additions
and
4 deletions
bbbmon/bbbmon.py
+
11
−
4
View file @
9e07d4bc
...
...
@@ -2,6 +2,7 @@
# -*- coding: utf-8 -*-
import
os
import
time
import
json
import
click
...
...
@@ -60,9 +61,10 @@ def main():
@click.option
(
'
--presenter/--no-presenter
'
,
default
=
True
,
show_default
=
True
,
help
=
"
Hide or show the presenters
"
)
@click.option
(
'
--presenter-id/--no-presenter-id
'
,
default
=
False
,
show_default
=
True
,
help
=
"
Hide or show the presenter IDs
"
)
@click.option
(
'
--short
'
,
'
-s
'
,
is_flag
=
True
,
help
=
"
Print less
"
)
@click.option
(
'
--twolines
'
,
'
-2
'
,
is_flag
=
True
,
help
=
"
Print essentials on two lines
"
)
@click.option
(
'
--all
'
,
'
-a
'
,
'
all_
'
,
is_flag
=
True
,
help
=
"
Print all
"
)
@click.option
(
'
--fancy/--no-fancy
'
,
default
=
True
,
show_default
=
True
,
help
=
"
Use fancy headers
"
)
def
meetings
(
ctx
,
short
,
all_
,
leaderboards
,
participants
,
presenter
,
watch
,
presenter_id
,
meetings
,
endpoint
,
fancy
):
def
meetings
(
ctx
,
short
,
all_
,
twolines
,
leaderboards
,
participants
,
presenter
,
watch
,
presenter_id
,
meetings
,
endpoint
,
fancy
):
"""
View currently active meetings
"""
if
short
:
leaderboards
=
False
...
...
@@ -77,8 +79,14 @@ def meetings(ctx, short, all_, leaderboards, participants, presenter, watch, pre
config
.
filter_endpoints
(
endpoint
)
if
watch
is
not
None
:
while
watch
is
not
None
:
if
twolines
:
meetings_twolines
(
config
,
watch
,
fancy
)
else
:
list_meetings
(
config
,
leaderboards
,
participants
,
presenter
,
presenter_id
,
meetings
,
watch
,
fancy
)
time
.
sleep
(
watch
)
else
:
if
twolines
:
meetings_twolines
(
config
,
watch
,
fancy
)
else
:
list_meetings
(
config
,
leaderboards
,
participants
,
presenter
,
presenter_id
,
meetings
,
watch
,
fancy
)
...
...
@@ -122,6 +130,5 @@ def config(ctx, new, edit, path, print_):
if
__name__
==
"
__main__
"
:
main
()
\ No newline at end of file
This diff is collapsed.
Click to expand it.
bbbmon/meetings.py
+
61
−
0
View file @
9e07d4bc
...
...
@@ -168,4 +168,65 @@ def list_meetings(config: Config, leaderboards: bool, participants: bool, presen
def
meetings_twolines
(
config
:
Config
,
watch
:
int
,
fancy
:
bool
):
"""
For each endpoint in the configuration get the active meetings and print
out an overview of the current bbb-usage
"""
# Request Meetings from API
meetings
=
[
get_meetings
(
e
.
secret
,
e
.
url
,
config
.
path
)
for
e
in
config
.
endpoints
]
# Clear screen after request is done, and before printing new data to keep
# blinking to a minimum
if
watch
is
not
None
:
click
.
clear
()
for
i
,
endpoint
in
enumerate
(
config
.
endpoints
):
meeting
=
meetings
[
i
]
# Print divider if there is more than one endpoint
if
i
>
0
:
print
(
"
=
"
*
click
.
get_terminal_size
()[
0
])
# If there are no meetings, skip to next endpoint
if
len
(
meeting
)
==
0
:
lines
=
[
"
{:^60}
"
.
format
(
"
bbb there are no meetings currently.
"
),
""
]
# Cut above 60 characters fill empty
lines
=
[
"
{:<60}
"
.
format
(
l
[:
61
])
for
l
in
lines
]
lines
=
"
\n
"
.
join
(
lines
)
print
(
lines
)
continue
n_running
=
len
(
meeting
)
n_recording
=
len
([
m
for
m
in
meeting
if
m
[
"
recording
"
]
==
"
true
"
])
n_participants
=
sum
([
int
(
m
[
"
participantCount
"
])
for
m
in
meeting
])
n_listeners
=
sum
([
int
(
m
[
"
listenerCount
"
])
for
m
in
meeting
])
n_voice
=
sum
([
int
(
m
[
"
voiceParticipantCount
"
])
for
m
in
meeting
])
n_video
=
sum
([
int
(
m
[
"
videoCount
"
])
for
m
in
meeting
])
n_moderator
=
sum
([
int
(
m
[
"
moderatorCount
"
])
for
m
in
meeting
])
avg_s
=
sum
([
int
(
get_duration
(
m
).
total_seconds
())
for
m
in
meeting
])
/
float
(
n_running
)
avg_s
=
avg_s
/
60.
/
60.
if
not
fancy
:
lines
=
[
"
{} rec / ses ppl mod vid mic ear
"
.
format
(
endpoint
.
name
),
"
stats {:>2} / {:<2} {:>3} {:>3} {:>3} {:>3} {:>3}
"
\
.
format
(
n_recording
,
n_running
,
n_participants
,
n_moderator
,
n_video
,
n_voice
,
n_listeners
)
]
else
:
lines
=
[
"
{}: There are {} people in {} meetings for {:.1f}h on average
"
\
.
format
(
endpoint
.
name
,
n_participants
,
n_running
,
avg_s
),
"
{} webcams and {} microphones are on. {} just listen. {} mods
"
\
.
format
(
n_video
,
n_voice
,
n_listeners
,
n_moderator
)
]
# Cut above 60 characters fill empty
lines
=
[
"
{:^60}
"
.
format
(
l
[:
61
])
for
l
in
lines
]
lines
=
"
\n
"
.
join
(
lines
)
print
(
lines
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment