Script: Jicofo log analyzer

I wrote a Bash script to generate a simple report from the Jicofo log.
This is the code.

To download

wget -O /usr/local/bin/jicofo-log-analyzer https://raw.githubusercontent.com/emrahcom/emrah-bullseye-templates/main/machines/eb-jitsi/usr/local/bin/jicofo-log-analyzer

chmod 755 /usr/local/bin/jicofo-log-analyzer

usage 1

jicofo-log-analyzer /var/log/jitsi/jicofo.log

usage 2

zcat /var/log/jitsi/jicofo.log.2.gz | jicofo-log-analyzer

usage 3

tail -f /var/log/jitsi/jicofo.log | jicofo-log-analyzer

sample output

myroom
======
created at: 2020-09-19 13:38:59
disposed at: 2020-09-19 13:42:03
duration: 00:03:04
number of participants: 5
participants:
    1795f1f6, 2b916120, 7a52ca50, d406a26e, f4e07baa
actions:
    13:38:59 +++ [myroom]
    13:38:59  *  2b916120
    13:38:59 ->  2b916120
    13:39:08 ->  1795f1f6
    13:39:15 ->  f4e07baa
    13:39:27  *  f4e07baa
    13:39:27  <- 2b916120
    13:39:48 ->  d406a26e
    13:40:41  *  d406a26e
    13:40:41  <- f4e07baa
    13:41:06 ->  7a52ca50
    13:41:29  <- d406a26e
    13:42:02  <- 7a52ca50
    13:42:03  <- 1795f1f6
    13:42:03 --- [myroom]
8 Likes

great, what i was looking for.

any way to export it? I mean, can I download it to a file for reading? or can it be displayed on a frontend?

thanks!

Add “> filename” to save the output into a file. For example

jicofo-log-analyzer /var/log/jitsi/jicofo.log > /tmp/report-file.log

or

jicofo-log-analyzer /var/log/jitsi/jicofo.log.1 > /tmp/report-$(date --date=yesterday +'%Y%m%d').log
1 Like

Hello, why are users with a record number displayed, example: 7659341D and not with the created profile (Name and email)

For the privacy reasons, they are recorded in the jicofo logs with their IDs

EDIT: Nevermind… i was too excited and my internet was not following my wishes, i opened now :smiley: :rofl: :rofl:
I trying to access https://github.com/emrahcom/emrah-buster-templates/blob/master/machines/eb-jitsi/usr/local/bin/jicofo-log-analyzer

Looks like a broken link, can you update it please @emrah emrah?

to sum up all participants :slight_smile:
more report-file.log | grep “number of participants:” | awk ‘{s+=$4} END {print s}’

@emrah Hello! I wanted to ask you, is there any way to add this script to jitsi meet main web page like a button? I mean when you push a button, the script works and shows the information

Theoretically, yes… But I think this is not a good idea

  • the script reports only completed sessions, not the current one

  • this will cause a privacy problem without authentication

  • you should add some kind of trigger to the server side to start the script

i made your wonderful statistic script compatible to the new jitsi stable version; additionally, it shows on what bridge users were, who the admin has been (if secure domain enabled), and counts the number of members/ conferences in total.

    #!/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

    # count
    declare -i count_confs count_users

    if [[ -n "$1" ]]; then
        LOG=$1
        [[ ! -f "$LOG" ]] && exit 1
    fi

    declare -A created_at
    declare -A disposed_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
        disposed_at[$room]=
        actions[$room]="$ctime +++ [$room]"
        members[$room]=
    }

    # -----------------------------------------------------------------------------
    # room disposed
    # -----------------------------------------------------------------------------

    function disposed {
        disposed_at[$room]=$cdatetime
        actions[$room]+="\n$ctime --- [$room]"
        duration=$(elapsed "${created_at[$room]}" "${disposed_at[$room]}")

        [[ "$MIN_DURATION" > "$duration" ]] && return

        msorted=$(echo ${members[$room]} | xargs -n1 | sort -u | xargs)
        count_users+=`echo $msorted | wc -w`
        count_confs+=1

        # csv:
        #$room;${created_at[$room]};${disposed_at[$room]};$duration;$(echo $msorted | wc -w);


        cat <<EOF

    $room
    $(echo $room | sed 's/./=/g')

    created at: ${created_at[$room]}
    disposed at: ${disposed_at[$room]}
    duration: $duration
    number of participants: $(echo $msorted | wc -w)

    EOF

        [[ "$LIST_MEMBERS" == true ]] && list-members || true
        [[ "$LIST_ACTIONS" == true ]] && list-actions || true

    }

    # -----------------------------------------------------------------------------
    # main
    # -----------------------------------------------------------------------------

    while read l; do

        cdatetime=$(echo $l | egrep -o '[0-9]+-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+')
        ctime=$(echo $cdatetime | cut -d ' ' -f2)
        room=$(echo $l | egrep -o 'room=[^[:space:]]*@' | cut -d '=' -f2 | cut -d '@' -f1)

        if (echo $l | egrep -qs 'Member joined:'); then

            member=$(echo $l | egrep -o 'joined:[^[:space:]]*' | cut -d':' -f2)

            members[$room]+="$member "
            actions[$room]+="\n$ctime ->  $member"

        elif (echo $l | egrep -qs 'bridge=jvbbrew.*@.*'); then

            bridge=$(echo $l |  egrep -o 'bridge=[^[:space:]]*@*' | cut -d '/' -f2)
    	actions[$room]+="\nBridge: $bridge"

        elif (echo $l | egrep -qs 'AuthSession\[ID=.*@.*'); then

            room2=$(echo $l | egrep -o 'R\=[^[:space:]]*@' | cut -d '=' -f2 | cut -d '@' -f1)
            mod=$(echo $l | egrep -o 'AuthSession\[ID=[^[:space:]]*@[^[:space:]]*' | \
                     cut -d'=' -f2)
    	actions[$room2]+="\nAdmin: $mod"

        elif (echo $l | egrep -qs 'Member .*@.* leaving'); then

            member=$(echo $l | egrep -o '[^[:space:]]*@[^[:space:]]*' | \
                     cut -d'/' -f2)

            members[$room]+="$member "
            actions[$room]+="\n$ctime  <- $member"

        elif (echo $l | egrep -qs 'Granted owner to .*@.*'); then

            member=$(echo $l | egrep -o '[^[:space:]]*@[^[:space:]]*' | \
                     cut -d'/' -f2)
            actions[$room]+="\n$ctime  *  $member"
        elif (echo $l | egrep -qs 'Created new conference,'); then
            created

        elif (echo $l | egrep -qs 'Stopped.'); then
            disposed

        fi

    done < <(cat $LOG | egrep --line-buffered -s \
             '(Member|Created|Stopped.|AuthSession|bridge=jvbbrew)')

    echo
    echo number of all participants: $count_users
    echo number of all conferences: $count_confs
    echo
    echo created at $(date +'%Y-%m-%d %H:%M:%S')
4 Likes

Hi!,

I tested your analyzer, but I only get the first room in the log file, is there a way to have a full analysis of the full log to get the output for all the rooms?

It reports the finished sessions. It should report all finished sessions

Maybe I have something wrong in my settings because I see in the log several sessions finished also one that I made as test and the output prompts only the first one. Any idea? Or what is a finished session really?

In my test I opened my meet and created a room, copied the invitation and opened in another browser to enter as guest, I texted in the chat from the guest to the host and pressed log out button. Then I pressed log out button as guest and ran the script. The session isn’t shown; but it is in /var/log/jitsi/jicofo.log as stopped

Did you run the script after both the host and the guest leave the room?

Yes, both were out and closed and later I ran the script

Can you send me your jicofo log?

Fixed.

The script doesn’t print the report of short meetings (2 min by default). It’s possible to change the minimum duration using MIN_DURATION

2 Likes

Dear @emrah,
for some reason, I ran the script with the command “./jicofo-log-analyzer-v2 /var/log/jitsi/jicofo.log”
(your script is in the file jicofo-log-analyzer-v2)
and I got the following error:
: invalid optionlyzer-v2: line 2: set: -
set: usage: set [-abefhkmnptuvxBCHP] [-o option-name] [–] [arg …]
‘: not a valid identifier line 22: declare: count_users ./jicofo-log-analyzer-v2: line 34: syntax error near unexpected token $’{\r’’
'/jicofo-log-analyzer-v2: line 34: ` function elapsed {

What is the problem here ?
Many thanks

I set the MIN_DURATION to less time and yes, it shows it all now. I totally was blind about that part, sorry for the misunderstanding

1 Like

How do you get the script?
It seems there is a copy-paste error