From 2043f6bffb5f7e32e04e4b0ecb4db0c4c4a8ebc1 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Tue, 8 Dec 2020 12:32:01 +0100 Subject: [PATCH] Added STUN/TURN statistics --- rapport_activite/rapport_activites.sh | 45 ++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/rapport_activite/rapport_activites.sh b/rapport_activite/rapport_activites.sh index 31396e8..deb1474 100755 --- a/rapport_activite/rapport_activites.sh +++ b/rapport_activite/rapport_activites.sh @@ -21,6 +21,20 @@ main() { echo "* User quota: $(get_hard_quota)M" echo "* Total disk usage: $(du -sh ${STORAGE_DIR} | awk '{print $1}')" per_account_storage_usage + + echo "" + echo "h2. ## Audio/Video Call usage:" + # Dans la config actuelle de logrotate, le log du mois dernier est stocké en tete clair, et tous les autres sont compressés par gzip. Un cat ne sortira de texte lisible que pour les fichiers en clair soit forcément celui du mois précédent + echo "" + echo "* Number of calls relayed: $(cat /var/log/ejabberd/ejabberd.log* | grep "Offering STUN/TURN services" | wc -l)" + echo "* Average data relayed per protocol per call:" + echo "** UDP: $(get_avg_UDP_turn_relayed_data) KiB" + echo "** TCP: $(get_avg_TCP_turn_relayed_data) KiB" + echo "** TLS over TCP: $(get_avg_TLS_turn_relayed_data) KiB" + echo "* Total data relayed per protocol:" + echo "** UDP: $(get_total_UDP_turn_relayed_data) KiB" + echo "** TCP: $(get_total_TCP_turn_relayed_data) KiB" + echo "** TLS over TCP: $(get_total_TLS_turn_relayed_data) KiB" } get_hard_quota() { @@ -79,9 +93,38 @@ count_removable_accounts() { psql -U ejabberd -h localhost ejabberd -c "${sql}" -t | grep -v '^$' | awk '{print $1}' } - count_archived_messages() { psql -U ejabberd -h localhost ejabberd -c "select count(*) from archive where peer not like 'irc%' and username not in ('r.giskard', 'lisa.simpson', 'bart.simpson')" -t | grep -v '^$' | awk '{print $1}' } +get_total_UDP_turn_relayed_data() { + cat /var/log/ejabberd/ejabberd.log* |grep "Relayed" | grep "UDP" | cut -d" " -f6-6 | paste -sd+ - | bc +} + +get_total_TCP_turn_relayed_data() { + cat /var/log/ejabberd/ejabberd.log* |grep "Relayed" | grep "TCP" | cut -d" " -f6-6 | paste -sd+ - | bc +} + +get_total_TLS_turn_relayed_data() { + cat /var/log/ejabberd/ejabberd.log* |grep "Relayed" | grep "TLS" | cut -d" " -f6-6 | paste -sd+ - | bc +} + +get_avg_UDP_turn_relayed_data() { + num=$(cat /var/log/ejabberd/ejabberd.log* |grep "Relayed" | grep "UDP" | wc -l) + total=$(get_total_UDP_turn_relayed_data) + echo "scale=2; $total / $num" | bc -l +} + +get_avg_TCP_turn_relayed_data() { + num=$(cat /var/log/ejabberd/ejabberd.log* |grep "Relayed" | grep "TCP" | wc -l) + total=$(get_total_TCP_turn_relayed_data) + echo "scale=2; $total / $num" | bc -l +} + +get_avg_TLS_turn_relayed_data() { + num=$(cat /var/log/ejabberd/ejabberd.log* |grep "Relayed" | grep "TLS" | wc -l) + total=$(get_total_TLS_turn_relayed_data) + echo "scale=2; $total / $num" | bc -l +} + main