Compare commits
3 Commits
e591ef175b
...
bd878b6cc2
Author | SHA1 | Date | |
---|---|---|---|
|
bd878b6cc2 | ||
|
e951c34796 | ||
|
81cf0d9fbe |
@ -2,7 +2,7 @@
|
||||
|
||||
STORAGE_DIR="/var/www/xmpp.chapril.org/upload/"
|
||||
|
||||
main() {
|
||||
main() {
|
||||
echo "h2. ## Global info"
|
||||
echo ""
|
||||
echo "* Total accounts: $(sudo -u ejabberd ejabberdctl registered_users chapril.org | egrep -v -e 'r\.giskard' -e '(lisa|bart)\.simpson' | wc -l)"
|
||||
@ -22,19 +22,16 @@ main() {
|
||||
echo "* Total disk usage: $(du -sh ${STORAGE_DIR} | awk '{print $1}')"
|
||||
per_account_storage_usage
|
||||
|
||||
DATE=$(get_last_month)
|
||||
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"
|
||||
echo "* Number of calls relayed: $(zgrep DATE /var/log/ejabberd/ejabberd.log* | grep -i -e "Offering stun" | wc -l)"
|
||||
echo "* Data relayed per protocol per call:"
|
||||
echo "** UDP: avg $(get_avg_UDP_turn_relayed_data) KiB, max $(get_max_UDP_turn_relayed_data) KiB, total $(get_total_UDP_turn_relayed_data) KiB"
|
||||
echo "** TCP: avg $(get_avg_TCP_turn_relayed_data) KiB, max $(get_max_TCP_turn_relayed_data) KiB, total $(get_total_TCP_turn_relayed_data) KiB"
|
||||
echo "** TLS: avg $(get_avg_TLS_turn_relayed_data) KiB, max $(get_max_TLS_turn_relayed_data) KiB, total $(get_total_TLS_turn_relayed_data) KiB"
|
||||
}
|
||||
|
||||
get_hard_quota() {
|
||||
@ -97,34 +94,105 @@ 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_last_month() {
|
||||
if [ "$(date +%m)" -gt 1 ]; then
|
||||
precedingMonth="$((10#$(date +%m)-1))"
|
||||
year="$(date +%Y)"
|
||||
if [ $precedingMonth -lt 10 ]; then
|
||||
yearMonth="$year-0$precedingMonth"
|
||||
else
|
||||
yearMonth="$year-$precedingMonth"
|
||||
fi
|
||||
else [ "$(date +%m)" -eq 1 ]
|
||||
precedingMonth=12
|
||||
year="$(($(date +%Y)-1))"
|
||||
yearMonth="$year-$precedingMonth"
|
||||
fi
|
||||
echo "$year-$precedingMonth"
|
||||
}
|
||||
|
||||
get_total_UDP_turn_relayed_data() {
|
||||
cat /var/log/ejabberd/ejabberd.log* |grep "Relayed" | grep "UDP" | cut -d" " -f6-6 | paste -sd+ - | bc
|
||||
n=$(zgrep $DATE /var/log/ejabberd/ejabberd.log* | grep -i -e "Relayed" | grep "UDP" | cut -d" " -f6-6 | paste -sd+ - | bc)
|
||||
if [ -z $n ]; then
|
||||
echo 0
|
||||
else
|
||||
echo $n
|
||||
fi
|
||||
}
|
||||
|
||||
get_total_TCP_turn_relayed_data() {
|
||||
cat /var/log/ejabberd/ejabberd.log* |grep "Relayed" | grep "TCP" | cut -d" " -f6-6 | paste -sd+ - | bc
|
||||
n=$(zgrep $DATE /var/log/ejabberd/ejabberd.log* | grep -i -e "Relayed" | grep "TCP" | cut -d" " -f6-6 | paste -sd+ - | bc)
|
||||
if [ -z $n ]; then
|
||||
echo 0
|
||||
else
|
||||
echo $n
|
||||
fi
|
||||
}
|
||||
|
||||
get_total_TLS_turn_relayed_data() {
|
||||
cat /var/log/ejabberd/ejabberd.log* |grep "Relayed" | grep "TLS" | cut -d" " -f6-6 | paste -sd+ - | bc
|
||||
n=$(zgrep $DATE /var/log/ejabberd/ejabberd.log* | grep -i -e "Relayed" | grep "TLS" | cut -d" " -f6-6 | paste -sd+ - | bc)
|
||||
if [ -z $n ]; then
|
||||
echo 0
|
||||
else
|
||||
echo $n
|
||||
fi
|
||||
}
|
||||
|
||||
get_max_UDP_turn_relayed_data() {
|
||||
n=$(zgrep $DATE /var/log/ejabberd/ejabberd.log* | grep -i -e "Relayed" | grep "UDP" | cut -d" " -f6-6 | sort | tail -n 1)
|
||||
if [ -z $n ]; then
|
||||
echo 0
|
||||
else
|
||||
echo $n
|
||||
fi
|
||||
}
|
||||
|
||||
get_max_TCP_turn_relayed_data() {
|
||||
n=$(zgrep $DATE /var/log/ejabberd/ejabberd.log* | grep -i -e "Relayed" | grep "TCP" | cut -d" " -f6-6 | sort | tail -n 1)
|
||||
if [ -z $n ]; then
|
||||
echo 0
|
||||
else
|
||||
echo $n
|
||||
fi
|
||||
}
|
||||
|
||||
get_max_TLS_turn_relayed_data() {
|
||||
n=$(zgrep $DATE /var/log/ejabberd/ejabberd.log* | grep -i -e "Relayed" | grep "TLS" | cut -d" " -f6-6 | sort | tail -n 1)
|
||||
if [ -z $n ]; then
|
||||
echo 0
|
||||
else
|
||||
echo $n
|
||||
fi
|
||||
}
|
||||
|
||||
get_avg_UDP_turn_relayed_data() {
|
||||
num=$(cat /var/log/ejabberd/ejabberd.log* |grep "Relayed" | grep "UDP" | wc -l)
|
||||
n=$(zgrep "$DATE" /var/log/ejabberd/ejabberd.log* | grep -i -e "Relayed" | grep "UDP" | wc -l)
|
||||
total=$(get_total_UDP_turn_relayed_data)
|
||||
echo "scale=2; $total / $num" | bc -l
|
||||
if [ $n -eq 0 ]; then
|
||||
echo 0
|
||||
else
|
||||
echo "scale=2; $total / $n" | bc -l
|
||||
fi
|
||||
}
|
||||
|
||||
get_avg_TCP_turn_relayed_data() {
|
||||
num=$(cat /var/log/ejabberd/ejabberd.log* |grep "Relayed" | grep "TCP" | wc -l)
|
||||
n=$(zgrep "$DATE" /var/log/ejabberd/ejabberd.log* | grep -i -e "Relayed" | grep "TCP" | wc -l)
|
||||
total=$(get_total_TCP_turn_relayed_data)
|
||||
echo "scale=2; $total / $num" | bc -l
|
||||
if [ $n -eq 0 ]; then
|
||||
echo 0
|
||||
else
|
||||
echo "scale=2; $total / $n" | bc -l
|
||||
fi
|
||||
}
|
||||
|
||||
get_avg_TLS_turn_relayed_data() {
|
||||
num=$(cat /var/log/ejabberd/ejabberd.log* |grep "Relayed" | grep "TLS" | wc -l)
|
||||
n=$(zgrep "$DATE" /var/log/ejabberd/ejabberd.log* | grep -i -e "Relayed" | grep "TLS" | wc -l)
|
||||
total=$(get_total_TLS_turn_relayed_data)
|
||||
echo "scale=2; $total / $num" | bc -l
|
||||
if [ $n -eq 0 ]; then
|
||||
echo 0
|
||||
else
|
||||
echo "scale=2; $total / $n" | bc -l
|
||||
fi
|
||||
}
|
||||
|
||||
main
|
||||
|
Loading…
Reference in New Issue
Block a user