Adds participant pair selection event.

main
Yasen Pramatarov 2024-05-30 20:19:24 +03:00
parent 2309252a91
commit f8a1b0d18c
1 changed files with 17 additions and 3 deletions

20
jilo
View File

@ -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_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_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_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=" db_drop="
DROP TABLE IF EXISTS conferences; DROP TABLE IF EXISTS conferences;
@ -69,7 +69,8 @@ CREATE TABLE participants (
event_time TEXT, event_time TEXT,
event_type TEXT, event_type TEXT,
endpoint_id TEXT, endpoint_id TEXT,
stats_id TEXT stats_id TEXT,
participant_ip TEXT
); );
CREATE TABLE state ( CREATE TABLE state (
id INTEGER PRIMARY_KEY, id INTEGER PRIMARY_KEY,
@ -201,10 +202,23 @@ jitsi_log_parse() {
participant_endpoint_id="${BASH_REMATCH[2]}" participant_endpoint_id="${BASH_REMATCH[2]}"
participant_stats_id="${BASH_REMATCH[3]}" participant_stats_id="${BASH_REMATCH[3]}"
if [[ -n "$conferenceId" ]]; then 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" db_query "$db_insert"
fi 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 # locate the corresponding conference ending event
elif [[ "$line" =~ ([0-9-]+\ [0-9:.]+)\ [A-Z]+:.*\[confId=([a-zA-Z0-9]+)\ .*conf_name=([^ ]+)@.*\]\ Conference\.expire ]]; then elif [[ "$line" =~ ([0-9-]+\ [0-9:.]+)\ [A-Z]+:.*\[confId=([a-zA-Z0-9]+)\ .*conf_name=([^ ]+)@.*\]\ Conference\.expire ]]; then
end_time="${BASH_REMATCH[1]}" end_time="${BASH_REMATCH[1]}"