Added STUN/TURN statistics

This commit is contained in:
Adrien Bourmault 2020-12-08 12:32:01 +01:00 committed by root
parent c467b2574b
commit 2043f6bffb

View File

@ -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