diff --git a/jilo b/jilo index 9133aab..22c8a54 100755 --- a/jilo +++ b/jilo @@ -49,7 +49,7 @@ MYSQL_DB=${MYSQL_DB:-$DEFAULT_MYSQL_DB} db_get_state_template="SELECT filename, filetime, filesize, position, inode FROM state WHERE jitsi_component = '%s';" db_set_state_template="UPDATE state SET time=datetime('now'), filename='%s', filetime='%s', filesize='%s', position='%s', inode='%s' WHERE jitsi_component = '%s';" db_insert_conference_template="INSERT INTO conferences (jitsi_component, conference_name, conference_id, start, end) VALUES ('%s', '%s', '%s', '%s', '%s');" -db_insert_participant_template="INSERT INTO participants (conference_id, event_time, event_type, endpoint_id, stats_id) VALUES ('%s', '%s', '%s', '%s', '%s');" +db_insert_participant_template="INSERT INTO participants (conference_id, event_time, event_type, endpoint_id, stats_id, participant_ip) VALUES ('%s', '%s', '%s', '%s', '%s', '%s');" db_drop=" DROP TABLE IF EXISTS conferences; @@ -69,7 +69,8 @@ CREATE TABLE participants ( event_time TEXT, event_type TEXT, endpoint_id TEXT, - stats_id TEXT + stats_id TEXT, + participant_ip TEXT ); CREATE TABLE state ( id INTEGER PRIMARY_KEY, @@ -201,10 +202,23 @@ jitsi_log_parse() { participant_endpoint_id="${BASH_REMATCH[2]}" participant_stats_id="${BASH_REMATCH[3]}" if [[ -n "$conferenceId" ]]; then - db_insert=$(printf "$db_insert_participant_template" "$conferenceId" "$participant_join_time" "$event_type" "$participant_endpoint_id" "$participant_stats_id") + db_insert=$(printf "$db_insert_participant_template" "$conferenceId" "$participant_join_time" "$event_type" "$participant_endpoint_id" "$participant_stats_id" "") db_query "$db_insert" fi + # locate participant pair selection event + elif [[ "$line" =~ ([0-9-]+\ [0-9:.]+)\ [A-Z]+:.*\[confId=${conferenceId}\ .*epId=([a-zA-Z0-9-]+)\ stats_id=([a-zA-Z0-9-]+)\ .*Selected\ pair\ for\ stream\ .*([0-9.]+):10000/udp/srflx\ \-\>\ ([0-9.]+):[0-9]+/udp/prflx ]]; then + participant_join_time="${BASH_REMATCH[1]}" + event_type='pair selected' + participant_endpoint_id="${BASH_REMATCH[2]}" + participant_stats_id="${BASH_REMATCH[3]}" + participant_IP="${BASH_REMATCH[5]}" + if [[ -n "$conferenceId" ]]; then + db_insert=$(printf "$db_insert_participant_template" "$conferenceId" "$participant_join_time" "$event_type" "$participant_endpoint_id" "$participant_stats_id" "$participant_IP") + db_query "$db_insert" + fi + + # locate the corresponding conference ending event elif [[ "$line" =~ ([0-9-]+\ [0-9:.]+)\ [A-Z]+:.*\[confId=([a-zA-Z0-9]+)\ .*conf_name=([^ ]+)@.*\]\ Conference\.expire ]]; then end_time="${BASH_REMATCH[1]}"