forked from bigbluebutton/bigbluebutton
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbbb-record
executable file
·558 lines (475 loc) · 15.2 KB
/
bbb-record
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
#!/bin/bash
#
# Copyright (c) 2008-2011 by BigBlueButton Inc.
#
# This file is part of BigBlueButton - http://www.bigbluebutton.org
#
# BigBlueButton is free software; you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
#
# BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License along
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
#
# Author(s):
# Fred Dixon <[email protected]>
#
# Changelog:
# 2011-08-18 FFD Inital Version
# 2011-11-20 FFD Added more checks for processing of recording
# 2012-01-04 GUG Add option to check for errors
# 2012-02-27 GUG Add option to delete one meeting and recording
set -e
#set -x
BASE=/var/bigbluebutton/recording
STATUS=$BASE/status
source /etc/bigbluebutton/bigbluebutton-release
RECORDING_DIR=$(cat /usr/local/bigbluebutton/core/scripts/bigbluebutton.yml | sed -n '/\(recording_dir\)/{s/.*recording_dir:[ ]*//;s/;//;p}')
PUBLISHED_DIR=$(cat /usr/local/bigbluebutton/core/scripts/bigbluebutton.yml | sed -n '/\(published_dir\)/{s/.*published_dir:[ ]*//;s/;//;p}')
RAW_AUDIO_SRC=$(cat /usr/local/bigbluebutton/core/scripts/bigbluebutton.yml | sed -n '/\(raw_audio_src\)/{s/.*raw_audio_src:[ ]*//;s/;//;p}')
RAW_VIDEO_SRC=$(cat /usr/local/bigbluebutton/core/scripts/bigbluebutton.yml | sed -n '/\(raw_video_src\)/{s/.*raw_video_src:[ ]*//;s/;//;p}')
RAW_DESKSHARE_SRC=$(cat /usr/local/bigbluebutton/core/scripts/bigbluebutton.yml | sed -n '/\(raw_deskshare_src\)/{s/.*raw_deskshare_src:[ ]*//;s/;//;p}')
RAW_PRESENTATION_SRC=$(cat /usr/local/bigbluebutton/core/scripts/bigbluebutton.yml | sed -n '/\(raw_presentation_src\)/{s/.*raw_presentation_src:[ ]*//;s/;//;p}')
TYPES=$(cd /usr/local/bigbluebutton/core/scripts/process; ls *.rb | sed s/.rb//g)
mark_for_rebuild() {
MEETING_ID=$1
#set -x
for type in $TYPES; do
if [ -d $BASE/process/$type/$MEETING_ID ]; then
rm -rf $BASE/process/$type/$MEETING_ID
# else
# echo "Warn: Didn't find $BASE/process/$type/$MEETING_ID"
# exit 1
fi
if [ -f $STATUS/processed/$MEETING_ID-$type.done ]; then
rm $STATUS/processed/$MEETING_ID-$type.done
# else
# echo "Warn: Didn't find $STATUS/processed/$MEETING_ID-$type.done"
# exit 1
fi
if [ -d $BASE/publish/$type/$MEETING_ID ]; then
rm -rf $BASE/publish/$type/$MEETING_ID
fi
if [ -d /var/bigbluebutton/processed/$type/$MEETING_ID ]; then
rm -rf /var/bigbluebutton/published/$type/$MEETING_ID
fi
if [ -d /var/bigbluebutton/published/$type/$MEETING_ID ]; then
rm -rf /var/bigbluebutton/published/$type/$MEETING_ID
fi
if [ -d /var/bigbluebutton/unpublished/$type/$MEETING_ID ]; then
rm -rf /var/bigbluebutton/unpublished/$type/$MEETING_ID
fi
done
}
BIGBLUEBUTTON_RELEASE=0.8-beta-4
need_root() {
if [ $EUID != 0 ]; then
echo "Need to be root to run this option"
exit 1
fi
}
print_header() {
if [ ! $HEADER ]; then
echo
echo "** Potential problems described below **"
HEADER=1
fi
}
usage() {
echo "BigBlueButton Recording Diagnostic Utility (BigBlueButton Version $BIGBLUEBUTTON_RELEASE)"
echo
echo " bbb-record [options]"
echo
echo "Reporting:"
echo " --list List all recordings"
echo
echo "Monitoring:"
echo " --watch Watch processing of recordings"
echo " --rebuild [meetingID] rebuild the output for meetingID"
echo " --delete [meetingID] delete one meeting and recording"
echo " --deletall delete all meetings and recordings"
echo " --debug check for recording errors"
echo " --check check for configuration errors"
echo
}
if [ $# -eq 0 ]; then
usage
exit 1
fi
# Parse the parameters
while [ $# -gt 0 ]; do
if [ "$1" = "-watch" -o "$1" = "--watch" ]; then
WATCH=1
shift
continue
fi
if [ "$1" = "-list" -o "$1" = "--list" ]; then
LIST=1
shift
continue
fi
if [ "$1" = "--list20" ]; then
LIST=1
HEAD=20
shift
continue
fi
if [ "$1" = "-rebuild" -o "$1" = "--rebuild" ]; then
need_root
if [ ! -z "${2}" ]; then
MEETING_ID="${2}"
shift
fi
REBUILD=1
shift
continue
fi
if [ "$1" = "-delete" -o "$1" = "--delete" ]; then
need_root
if [ ! -z "${2}" ]; then
MEETING_ID="${2}"
shift
fi
DELETE=1
shift
continue
fi
if [ "$1" = "-deleteall" -o "$1" = "--deleteall" ]; then
need_root
DELETEALL=1
shift
continue
fi
if [ "$1" = "-check" -o "$1" = "--check" ]; then
need_root
CHECK=1
shift
continue
fi
if [ "$1" = "-debug" -o "$1" = "--debug" ]; then
need_root
DEBUG=1
shift
continue
fi
usage
exit 1
done
if [ $REBUILD ]; then
if [ -z "$MEETING_ID" ]; then
#
# Regenerate all meetings
#
for recording in $(dir $BASE/raw); do
echo "Marking for rebuild: $MEETING_ID"
mark_for_rebuild $MEETING_ID
done
else
echo "Marking for rebuild: $MEETING_ID"
mark_for_rebuild $MEETING_ID
fi
fi
if [ $DELETE ]; then
if [ ! -z "$MEETING_ID" ]; then
for type in $TYPES; do
rm -rf /var/bigbluebutton/published/$type/$MEETING_ID*
rm -rf /var/bigbluebutton/unpublished/$type/$MEETING_ID*
rm -rf /var/bigbluebutton/recording/process/$type/$MEETING_ID*
rm -rf /var/bigbluebutton/recording/publish/$type/$MEETING_ID*
rm -rf /var/bigbluebutton/recording/raw/$MEETING_ID*
rm -rf /var/log/bigbluebutton/$type/*$MEETING_ID*
done
rm -f /var/bigbluebutton/recording/status/recorded/$MEETING_ID*
rm -f /var/bigbluebutton/recording/status/archived/$MEETING_ID*
rm -f /var/bigbluebutton/recording/status/processed/$MEETING_ID*
rm -rf /usr/share/red5/webapps/video/streams/$MEETING_ID
rm -f /var/bigbluebutton/deskshare/$MEETING_ID*.flv
rm -f /var/freeswitch/meetings/$MEETING_ID*.wav
rm -rf /var/bigbluebutton/$MEETING_ID
echo "deleting: $MEETING_ID"
else
echo "Give a meeting id or use --deleteall"
fi
fi
if [ $DELETEALL ]; then
for type in $TYPES; do
rm -rf /var/bigbluebutton/published/$type/*
rm -rf /var/bigbluebutton/unpublished/$type/*
rm -rf /var/bigbluebutton/recording/process/$type/*
rm -rf /var/bigbluebutton/recording/publish/$type/*
rm -rf /var/bigbluebutton/recording/raw/*
rm -rf /var/log/bigbluebutton/$type/*
done
rm -f /var/bigbluebutton/recording/status/recorded/*
rm -f /var/bigbluebutton/recording/status/archived/*
rm -f /var/bigbluebutton/recording/status/processed/*
rm -f /usr/share/red5/webapps/video/streams/*.flv
rm -f /var/bigbluebutton/deskshare/*.flv
rm -f /var/freeswitch/meetings/*.wav
for meeting in $(ls /var/bigbluebutton | grep "[0-9]\{13\}$"); do
echo "deleting: $meeting"
rm -rf /var/bigbluebutton/$meeting
done
fi
if [ $LIST ]; then
# Does the meeting contain:
# A -- Audio
# P -- Presentation
# V -- Video
# D -- Desktop
#
# Does the archive contain
# A -- Audio
# P -- Presentation
# V -- Video
# D -- Desktop
# E -- Events
#
# Is there a done flag (trigger rap-worker.rb to process) for
# R -- Recording
# A -- Archiving
#
echo "MeetingID Time APVD APVDE RA Slides Processed Published Description"
echo "------------------------------------------------------ ---------------------------- ---- ----- -- ------ -------------------- -------------------- -----------------------------"
if [ -z $HEAD ]; then
# If we're not called with --list20, show all recordings
HEAD=99999
fi
for meeting in $(ls -t /var/bigbluebutton | grep "[0-9]\{13\}$" | head -n $HEAD); do
echo -n "$meeting"
timestamp=$(echo $meeting | sed s/.*-//g)
epoc=$(($timestamp/1000))
echo -n " "
echo -n $(date --date "Jan 1, 1970 00:00:00 +0000 + $epoc seconds") | awk '{ printf("%-28s",$0) }'
echo -n " "
#
# Monitor the live recordings
#
#
# Check if there is any recorded audio
if ls -A $RAW_AUDIO_SRC/$meeting-*.wav &> /dev/null; then
echo -n "X"
else
echo -n " "
fi
#
# Check if there area uploaded presentations
if [ -d $RAW_PRESENTATION_SRC/$meeting/$meeting ]; then
if [ "$(ls -A $RAW_PRESENTATION_SRC/$meeting/$meeting)" ]; then
echo -n "X"
else
echo -n " "
fi
else
echo -n " "
fi
#
# Check if there is any recorded videos
if [ -d $RAW_VIDEO_SRC/$meeting ]; then
if [ "$(ls -A $RAW_VIDEO_SRC/$meeting)" ]; then
echo -n "X"
else
echo -n " "
fi
else
echo -n " "
fi
#
# Check if there is any recorded desktop sharing
if ls -A $RAW_DESKSHARE_SRC/$meeting-*.flv &> /dev/null; then
echo -n "X"
else
echo -n " "
fi
#
# Monitor the archived files
#
RAW_DIR=$RAW_PRESENTATION_SRC/recording/raw/$meeting
echo -n " "
# Check if there area uploaded presentations
#echo "$RAW/audio"
DIRS="audio presentation video deskshare"
for dir in $DIRS; do
if [ -d $RAW_DIR/$dir ]; then
if [ "$(ls -A $RAW_DIR/$dir)" ]; then
echo -n "X"
else
echo -n " "
fi
else
echo -n " "
fi
done
if [ -f $RAW_DIR/events.xml ]; then
echo -n "X"
else
echo -n " "
fi
#
# Check the status files
#
echo -n " "
STATUS_DIR=$RAW_PRESENTATION_SRC/recording/status
DIRS="recorded archived"
for dir in $DIRS; do
if [ -f $STATUS_DIR/$dir/$meeting.done ]; then
echo -n "X"
else
echo -n " "
fi
done
#
# Numbe rof slides
printf "%7s" $(find /var/bigbluebutton/$meeting/$meeting -name "*.swf" | wc -l)
echo -n " "
#echo $BASE/raw/$meeting
if [ -d $BASE/raw/$meeting ]; then
recording=$meeting
#
# Checka processed
processed=""
for type in $TYPES; do
if [ -f $STATUS/processed/$recording-$type.done ]; then
if [ ! -z "$processed" ]; then
processed="$processed,"
fi
processed="$processed$type"
fi
done
printf "%-21s" $processed
#
# Check archived
published=""
for type in $TYPES; do
if [ -f /var/bigbluebutton/published/$type/$recording/metadata.xml ]; then
if [ ! -z "$published" ]; then
published="$published,"
fi
published="$published$type"
fi
done
printf "%-17s" $published
if [ -f /var/bigbluebutton/recording/raw/$recording/events.xml ]; then
echo -n " "
echo -n $(head -n 5 /var/bigbluebutton/recording/raw/$recording/events.xml | grep description | sed s/.*description=\"//g | sed s/\".*//g) | sed -e 's/<[^>]*>//g' -e 's/</</g' -e 's/>/>/g' -e 's/&/\&/g' -e 's/ \{1,\}/ /g' | tr -d '\n'
fi
fi
echo
done
echo
echo "--"
ps fU tomcat6 -o "%c%a" | grep -v COMMAND | grep -v logging.properties
echo "--"
if tail -n 20 /var/log/bigbluebutton/bbb-web.log | grep -q "is recorded. Process it."; then
echo -n "Last meeting processed (bbb-web.log): "
tail -n 20 /var/log/bigbluebutton/bbb-web.log | grep "is recorded. Process it." | sed "s/.*\[//g" | sed "s/\].*//g"
fi
fi
if [ $WATCH ]; then
watch -n 2 "bbb-record --list20"
fi
if [ $CHECK ]; then
if [ -f /var/bigbluebutton/recording/process/slides ]; then
if [ ! -w /var/bigbluebutton/recording/process/slides ]; then
print_header
echo "# Error: The output director for slides"
echo "#"
echo "# /var/bigbluebutton/recording/process/slides"
echo "#"
echo "# is not writeable."
echo
fi
fi
fi
if [ $DEBUG ]; then
LOG_DIR=/var/log/bigbluebutton
if [ -f /var/log/bigbluebutton/bbb-rap-worker.log ]; then
grep -i error /var/log/bigbluebutton/bbb-rap-worker.*
fi
#
#Failures while archiving files
#
if [ -f $LOG_DIR/archive.log ]; then
grep "Failed to" "$LOG_DIR/archive.log" > /tmp/t
if [ -s /tmp/t ]; then
echo " -- ERRORS found while archiving files -- "
cat /tmp/t
echo
grep "on ASCII" /tmp/t > /tmp/u
if [ -s /tmp/u ]; then
echo " -- events.xml was not created. There is a problem with the character encoding "
echo
fi
fi
fi
#
# We're going to look through the output files for each of the processed types
#
STAGES="process publish"
for type in $TYPES; do
for stage in $STAGES; do
if ls -A $LOG_DIR/$type/$stage-* &> /dev/null; then
rm -rf /tmp/t
grep -B 3 "ERROR -- : Error:" $LOG_DIR/$type/$stag-* | egrep -w 'Task:| Error:' > /tmp/t
if [ -s /tmp/t ]; then
echo " -- ERRORS found while processing slides $LOG_DIR/$type/$stag-* -- "
cat /tmp/t
echo
fi
fi
done
done
#
# Additional checks for record and playback
#
rm -rf /tmp/t
if ls /var/log/bigbluebutton/slides-process-* > /dev/null 2>1; then
sudo grep -i Error /var/log/bigbluebutton/slides-process-* > /tmp/t
if [ -s /tmp/t ]; then
echo " -- Ingest and Processing errors found in /var/log/bigbluebutton/slides-process-*.log -- "
cat /tmp/t
echo
fi
fi
rm -rf /tmp/t
if ls /var/log/bigbluebutton/slides-publish-* > /dev/null 2>1; then
sudo grep -i Error /var/log/bigbluebutton/slides-publish-* > /tmp/t
if [ -s /tmp/t ]; then
echo " -- Ingest and Processing errors found in /var/log/bigbluebutton/slides-publish-*.log -- "
cat /tmp/t
echo
fi
fi
rm -rf /tmp/t
if ls /var/log/bigbluebutton/slides-process-* > /dev/null 2>1; then
for file in /var/log/bigbluebutton/slides-process-*; do
if [ ! -f $(echo $file | sed 's/process/publish/g') ]; then
echo " $file" >> /tmp/t
fi
done
if [ -s /tmp/t ]; then
echo " -- Ingest and Processing: found process file but not publish -- "
cat /tmp/t
echo
fi
fi
rm -rf /tmp/t
if ls /var/bigbluebutton/recording/status/recorded/*.done > /dev/null 2>1; then
for file in /var/bigbluebutton/recording/status/recorded/*.done; do
if [ ! -f $(echo $file | sed 's/recorded/archived/g') ]; then
echo " $file" >> /tmp/t
fi
done
if [ -s /tmp/t ]; then
echo " -- Ingest and Processing: found recorded meeting but no archive files-- "
cat /tmp/t
echo
fi
fi
exit 0
fi