More precise time window for stats
This commit is contained in:
parent
81cf0d9fbe
commit
e951c34796
@ -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,11 +22,13 @@ 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: $(ls -1tr /var/log/ejabberd/ejabberd.log* | tail -n 5 | xargs zcat -f | grep -i -e "Offering stun" | wc -l)"
|
||||
echo "* Number of calls relayed: $(zgrep DATE /var/log/ejabberd/ejabberd.log* | grep -i -e "Offering stun" | wc -l)"
|
||||
get_avg_UDP_turn_relayed_data 12
|
||||
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"
|
||||
@ -93,49 +95,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_stunstats_from_log() {
|
||||
ls -1tr /var/log/ejabberd/ejabberd.log* | tail -n 5 | xargs zcat -f | grep -i -e "Offering stun"
|
||||
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() {
|
||||
ls -1tr /var/log/ejabberd/ejabberd.log* | tail -n 5 | xargs zcat -f | grep -i -e "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() {
|
||||
ls -1tr /var/log/ejabberd/ejabberd.log* | tail -n 5 | xargs zcat -f | grep -i -e "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() {
|
||||
ls -1tr /var/log/ejabberd/ejabberd.log* | tail -n 5 | xargs zcat -f | grep -i -e "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() {
|
||||
ls -1tr /var/log/ejabberd/ejabberd.log* | tail -n 5 | xargs zcat -f | grep -i -e "Relayed" | grep "UDP" | cut -d" " -f6-6 | sort | tail -n 1
|
||||
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() {
|
||||
ls -1tr /var/log/ejabberd/ejabberd.log* | tail -n 5 | xargs zcat -f | grep -i -e "Relayed" | grep "TCP" | cut -d" " -f6-6 | sort | tail -n 1
|
||||
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() {
|
||||
ls -1tr /var/log/ejabberd/ejabberd.log* | tail -n 5 | xargs zcat -f | grep -i -e "Relayed" | grep "TLS" | cut -d" " -f6-6 | paste -sd+ - | sort | tail -n 1
|
||||
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=$(ls -1tr /var/log/ejabberd/ejabberd.log* | tail -n 5 | xargs zcat -f | grep -i -e "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=$(ls -1tr /var/log/ejabberd/ejabberd.log* | tail -n 5 | xargs zcat -f | grep -i -e "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=$(ls -1tr /var/log/ejabberd/ejabberd.log* | tail -n 5 | xargs zcat -f | grep -i -e "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