2014-07-21 22:14:18 +08:00
|
|
|
#!/usr/bin/ruby
|
2012-09-05 05:42:13 +08:00
|
|
|
# encoding: UTF-8
|
|
|
|
#
|
|
|
|
# BigBlueButton open source conferencing system - http://www.bigbluebutton.org/
|
|
|
|
#
|
|
|
|
# Copyright (c) 2012 BigBlueButton Inc. and by respective authors (see below).
|
|
|
|
#
|
|
|
|
# This program 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 3.0 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/>.
|
|
|
|
#
|
|
|
|
|
|
|
|
|
2012-08-21 07:12:58 +08:00
|
|
|
require '../lib/recordandplayback'
|
|
|
|
require 'logger'
|
|
|
|
require 'trollop'
|
|
|
|
require 'yaml'
|
2012-08-14 04:22:53 +08:00
|
|
|
require "nokogiri"
|
2012-08-16 08:10:29 +08:00
|
|
|
require "redis"
|
|
|
|
require "fileutils"
|
2012-08-14 04:22:53 +08:00
|
|
|
|
2012-08-16 08:10:29 +08:00
|
|
|
def check_events_xml(raw_dir,meeting_id)
|
|
|
|
filepath = "#{raw_dir}/#{meeting_id}/events.xml"
|
2012-08-14 04:22:53 +08:00
|
|
|
raise Exception, "Events file doesn't exists." if not File.exists?(filepath)
|
2012-08-21 07:12:58 +08:00
|
|
|
bad_doc = Nokogiri::XML(File.open(filepath)) { |config| config.options = Nokogiri::XML::ParseOptions::STRICT }
|
2012-08-14 04:22:53 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def check_audio_files(raw_dir,meeting_id)
|
|
|
|
#check every file that is in events.xml, it's in audio dir
|
|
|
|
doc = Nokogiri::XML(File.open("#{raw_dir}/#{meeting_id}/events.xml"))
|
|
|
|
|
|
|
|
doc.xpath("//event[@eventname='StartRecordingEvent']/filename/text()").each { |fs_audio_file|
|
|
|
|
audioname = fs_audio_file.content.split("/").last
|
|
|
|
raw_audio_file = "#{raw_dir}/#{meeting_id}/audio/#{audioname}"
|
|
|
|
#checking that the audio file exists in raw directory
|
2014-01-30 23:45:43 +08:00
|
|
|
raise Exception, "Audio file #{raw_audio_file} doesn't exist in raw directory." if not File.exists?(raw_audio_file)
|
2012-08-14 04:22:53 +08:00
|
|
|
|
|
|
|
#checking length
|
2014-01-30 23:45:43 +08:00
|
|
|
raise Exception, "Audio file #{raw_audio_file} length is zero." if BigBlueButton::AudioEvents.determine_length_of_audio_from_file(raw_audio_file) <= 0
|
2012-08-14 04:22:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2013-04-05 04:08:49 +08:00
|
|
|
def check_webcam_files(raw_dir, meeting_id)
|
2015-01-28 00:51:29 +08:00
|
|
|
meeting_dir = "#{raw_dir}/#{meeting_id}"
|
|
|
|
|
|
|
|
BigBlueButton.logger.info("Repairing red5 serialized streams")
|
|
|
|
cp="/usr/share/red5/red5-server.jar:/usr/share/red5/lib/*"
|
2015-01-30 23:11:44 +08:00
|
|
|
if File.directory?("#{meeting_dir}/video/#{meeting_id}")
|
|
|
|
FileUtils.cd("#{meeting_dir}/video/#{meeting_id}") do
|
|
|
|
Dir.glob("*.flv.ser").each do |ser|
|
|
|
|
BigBlueButton.logger.info("Repairing #{ser}")
|
|
|
|
ret = BigBlueButton.exec_ret('java', '-cp', cp, 'org.red5.io.flv.impl.FLVWriter', ser, '0', '7')
|
|
|
|
if ret != 0
|
|
|
|
BigBlueButton.logger.warn("Failed to repair #{ser}")
|
|
|
|
end
|
2015-01-28 00:51:29 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2013-07-16 04:22:39 +08:00
|
|
|
|
|
|
|
BigBlueButton.logger.info "Checking all webcam recorded streams from events were archived."
|
2013-04-05 04:08:49 +08:00
|
|
|
webcams = BigBlueButton::Events.get_start_video_events("#{raw_dir}/#{meeting_id}/events.xml")
|
|
|
|
webcams.each do |webcam|
|
|
|
|
raw_webcam_file = "#{raw_dir}/#{meeting_id}/video/#{meeting_id}/#{webcam[:stream]}.flv"
|
|
|
|
raise Exception, "Webcam file #{webcam[:stream]}.flv was not archived" if not File.exists? raw_webcam_file
|
|
|
|
end
|
2013-07-16 04:22:39 +08:00
|
|
|
|
|
|
|
BigBlueButton.logger.info "Checking the length of webcam streams is not zero."
|
|
|
|
events_file = "#{meeting_dir}/events.xml"
|
|
|
|
events_xml = Nokogiri::XML(File.open(events_file))
|
|
|
|
original_num_events = events_xml.xpath("//event").size
|
|
|
|
|
|
|
|
Dir.glob("#{meeting_dir}/video/#{meeting_id}/*").each do |video|
|
|
|
|
if FFMPEG::Movie.new(video).duration == 0.0
|
|
|
|
video_name = File.basename(video,File.extname(video))
|
|
|
|
removed_elements = events_xml.xpath("//event[contains(., '#{video_name}')]").remove
|
|
|
|
BigBlueButton.logger.info "Removed #{removed_elements.size} events for webcam stream '#{video_name}' ."
|
|
|
|
FileUtils.rm video
|
|
|
|
BigBlueButton.logger.info "Removing webcam file #{video} from raw dir due to length zero."
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if original_num_events > events_xml.xpath("//event").size
|
|
|
|
BigBlueButton.logger.info "Making backup of original events file #{events_file}."
|
|
|
|
FileUtils.cp(events_file, "#{meeting_dir}/events.xml.original")
|
|
|
|
|
|
|
|
BigBlueButton.logger.info "Saving changes in #{events_file}."
|
|
|
|
File.open("#{raw_dir}/#{meeting_id}/events.xml",'w') {|f| f.write(events_xml) }
|
|
|
|
else
|
|
|
|
BigBlueButton.logger.info "Webcam streams with length zero were not found."
|
|
|
|
end
|
|
|
|
|
2013-04-05 04:08:49 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def check_deskshare_files(raw_dir, meeting_id)
|
|
|
|
desktops = BigBlueButton::Events.get_start_deskshare_events("#{raw_dir}/#{meeting_id}/events.xml")
|
|
|
|
desktops.each do |desktop|
|
|
|
|
raw_desktop_file = "#{raw_dir}/#{meeting_id}/deskshare/#{desktop[:stream]}"
|
|
|
|
raise Exception, "Deskshare file #{desktop[:stream]} was not archived" if not File.exists? raw_desktop_file
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-08-16 08:10:29 +08:00
|
|
|
|
|
|
|
opts = Trollop::options do
|
|
|
|
opt :meeting_id, "Meeting id to archive", :default => '58f4a6b3-cd07-444d-8564-59116cb53974', :type => String
|
2012-08-14 04:22:53 +08:00
|
|
|
end
|
|
|
|
|
2012-08-16 08:10:29 +08:00
|
|
|
meeting_id = opts[:meeting_id]
|
|
|
|
|
|
|
|
# This script lives in scripts/archive/steps while bigbluebutton.yml lives in scripts/
|
|
|
|
props = YAML::load(File.open('bigbluebutton.yml'))
|
2014-04-04 04:23:49 +08:00
|
|
|
log_dir = props['log_dir']
|
2012-08-16 08:10:29 +08:00
|
|
|
audio_dir = props['raw_audio_src']
|
|
|
|
recording_dir = props['recording_dir']
|
|
|
|
raw_archive_dir = "#{recording_dir}/raw"
|
2012-08-21 07:12:58 +08:00
|
|
|
redis_host = props['redis_host']
|
|
|
|
redis_port = props['redis_port']
|
2012-08-16 08:10:29 +08:00
|
|
|
|
2014-04-04 04:23:49 +08:00
|
|
|
BigBlueButton.logger = Logger.new("#{log_dir}/sanity.log", 'daily' )
|
2014-04-08 03:14:47 +08:00
|
|
|
|
2012-08-16 08:10:29 +08:00
|
|
|
begin
|
2013-07-16 04:22:39 +08:00
|
|
|
BigBlueButton.logger.info("Starting sanity check for recording #{meeting_id}.")
|
|
|
|
BigBlueButton.logger.info("Checking events.xml")
|
2012-08-16 08:10:29 +08:00
|
|
|
check_events_xml(raw_archive_dir,meeting_id)
|
2013-07-16 04:22:39 +08:00
|
|
|
BigBlueButton.logger.info("Checking audio")
|
2012-08-16 08:10:29 +08:00
|
|
|
check_audio_files(raw_archive_dir,meeting_id)
|
2014-04-04 04:23:49 +08:00
|
|
|
BigBlueButton.logger.info("Checking webcam videos")
|
|
|
|
check_webcam_files(raw_archive_dir,meeting_id)
|
|
|
|
BigBlueButton.logger.info("Checking deskshare videos")
|
|
|
|
check_deskshare_files(raw_archive_dir,meeting_id)
|
2012-08-16 08:10:29 +08:00
|
|
|
#delete keys
|
2013-07-16 04:22:39 +08:00
|
|
|
BigBlueButton.logger.info("Deleting keys")
|
2012-08-16 08:10:29 +08:00
|
|
|
redis = BigBlueButton::RedisWrapper.new(redis_host, redis_port)
|
|
|
|
events_archiver = BigBlueButton::RedisEventsArchiver.new redis
|
2014-04-04 04:23:49 +08:00
|
|
|
events_archiver.delete_events(meeting_id)
|
2012-08-16 08:10:29 +08:00
|
|
|
|
|
|
|
#create done files for sanity
|
2012-08-21 07:12:58 +08:00
|
|
|
BigBlueButton.logger.info("creating sanity done files")
|
2012-08-16 08:10:29 +08:00
|
|
|
sanity_done = File.new("#{recording_dir}/status/sanity/#{meeting_id}.done", "w")
|
|
|
|
sanity_done.write("sanity check #{meeting_id}")
|
|
|
|
sanity_done.close
|
|
|
|
rescue Exception => e
|
|
|
|
BigBlueButton.logger.error("error in sanity check: " + e.message)
|
2012-08-22 05:55:41 +08:00
|
|
|
sanity_done = File.new("#{recording_dir}/status/sanity/#{meeting_id}.fail", "w")
|
|
|
|
sanity_done.write("error: " + e.message)
|
|
|
|
sanity_done.close
|
2012-08-16 08:10:29 +08:00
|
|
|
end
|
2012-08-14 04:22:53 +08:00
|
|
|
|
|
|
|
|