#!/bin/bash set -e # ------------------------------------------------------------------------------ # jicofo-log-analyzer # ------------------------------------------------------------------------------ # Analyzes the Jicofo log and generates a report. # Copy to the /usr/local/bin folder and give the execute permission. # # cp jicofo-log-analyzer /usr/local/bin/ # chmod 755 /usr/local/bin/jicofo-log-analyzer # # usage: # jicofo-log-analyzer /var/log/jitsi/jicofo.log > myreport.txt # zcat /var/log/jitsi/jicofo.log.2.gz | jicofo-log-analyzer # tail -f /var/log/jitsi/jicofo.log | jicofo-log-analyzer # ------------------------------------------------------------------------------ LIST_MEMBERS=true LIST_ACTIONS=true MIN_DURATION="00:02:00" MCOL=8 if [[ -n "$1" ]]; then LOG=$1 [[ ! -f "$LOG" ]] && exit 1 fi declare -A created_at declare -A stopped_at declare -A members declare -A actions # ------------------------------------------------------------------------------ # elapsed time # ------------------------------------------------------------------------------ function elapsed { local t0=$(date -u -d "$1" +"%s") local t1=$(date -u -d "$2" +"%s") echo $(date -u -d "0 $t1 sec - $t0 sec" +"%H:%M:%S") } # ------------------------------------------------------------------------------ # list members # ------------------------------------------------------------------------------ function list-members { echo "participants:" i=1 for m in $msorted; do if [[ "$i" == 1 ]]; then echo -n " $m" (( i+=1 )) elif [[ "$i" == "$MCOL" ]]; then echo ", $m" i=1 else echo -n ", $m" (( i+=1 )) fi done [[ "$i" != "1" ]] && echo || true } # ------------------------------------------------------------------------------ # list actions # ------------------------------------------------------------------------------ function list-actions { echo "actions:" while read act; do echo " $act" done < <(echo -e "${actions[$_room_]}") } # ------------------------------------------------------------------------------ # room created # ------------------------------------------------------------------------------ function created { created_at[$_room_]=$cdatetime stopped_at[$_room_]= actions[$_room_]="$ctime +++ [$_room_]" members[$_room_]= } # ------------------------------------------------------------------------------ # room stopped # ------------------------------------------------------------------------------ function stopped { stopped_at[$_room_]=$cdatetime actions[$_room_]+="\n$ctime --- [$_room_]" duration=$(elapsed "${created_at[$_room_]}" "${stopped_at[$_room_]}") [[ "$MIN_DURATION" > "$duration" ]] && return msorted=$(echo ${members[$_room_]} | xargs -n1 | sort -u | xargs) cat <