Compare commits

..

6 Commits

3 changed files with 56 additions and 44 deletions

View File

@ -2,7 +2,7 @@
file.class=service file.class=service
file.generator=StatoolInfos file.generator=StatoolInfos
file.datetime=__LAST_UPDATE__ file.datetime=__LAST_UPDATE__
file.protocol=StatoolInfos-0.1.0 file.protocol=StatoolInfos-0.3.0
# [Service] # [Service]
service.name=XMPP Chapril service.name=XMPP Chapril
@ -19,6 +19,7 @@ service.endDate=
service.status.level=OK service.status.level=OK
service.status.description=Nominal service.status.description=Nominal
service.registration=Free service.registration=Free
service.registration.load=OPEN
service.install.type=DISTRIBUTION service.install.type=DISTRIBUTION
# [Host] # [Host]
@ -47,3 +48,5 @@ metrics.accounts.active.lastyear = __ACTIVE_USER_YEAR__
metrics.accounts.active.lastmonth = __ACTIVE_USER_MONTH__ metrics.accounts.active.lastmonth = __ACTIVE_USER_MONTH__
metrics.accounts.active.lastweek = __ACTIVE_USER_WEEK__ metrics.accounts.active.lastweek = __ACTIVE_USER_WEEK__
subs.metrics-2020=https://xmpp.chapril.org/.well-known/chaprilinfos/xmppchaprilorg-metrics-2020.properties
subs.metrics-2021=https://xmpp.chapril.org/.well-known/chaprilinfos/xmppchaprilorg-metrics-2021.properties

View File

@ -25,7 +25,9 @@ ejabberdctl_stats() {
echo "PUTVAL \"${HOSTNAME}/xmpp_s2s_out/count\" interval=$INTERVAL $(date +%s):$(ejabberdctl outgoing_s2s_number)" echo "PUTVAL \"${HOSTNAME}/xmpp_s2s_out/count\" interval=$INTERVAL $(date +%s):$(ejabberdctl outgoing_s2s_number)"
echo "PUTVAL \"${HOSTNAME}/xmpp_muc_total/count\" interval=$INTERVAL $(date +%s):$(ejabberdctl muc_online_rooms muc.chapril.org | wc -l)" echo "PUTVAL \"${HOSTNAME}/xmpp_muc_total/count\" interval=$INTERVAL $(date +%s):$(ejabberdctl muc_online_rooms muc.chapril.org | wc -l)"
echo "PUTVAL \"${HOSTNAME}/xmpp_accounts_created_lastday/count\" interval=$INTERVAL $(date +%s):$(count_accounts_created_lastday)" echo "PUTVAL \"${HOSTNAME}/xmpp_accounts_created_lastday/count\" interval=$INTERVAL $(date +%s):$(_count_accounts_created_lastday)"
echo "PUTVAL \"${HOSTNAME}/xmpp_accounts_created_lasthour/count\" interval=$INTERVAL $(date +%s):$(_count_accounts_created_lasthour)"
echo -n "PUTVAL \"${HOSTNAME}/xmpp_public_rooms_occupants/count\" interval=$INTERVAL $(date +%s):" ; _xmpp_public_rooms_total_occupants
} }
http_upload_disk_usage() { http_upload_disk_usage() {
@ -38,15 +40,46 @@ http_upload_disk_usage() {
captcha_stats() { captcha_stats() {
echo "PUTVAL \"${HOSTNAME}/xmpp_captcha_lastday/count\" interval=$INTERVAL $(date +%s):$(find /var/lib/ejabberd/chapril_captchas/ -mindepth 1 -maxdepth 1 -type f -mtime -1 | grep -v EXPERIMENTAL | wc -l)" echo "PUTVAL \"${HOSTNAME}/xmpp_captcha_lastday/count\" interval=$INTERVAL $(date +%s):$(find /var/lib/ejabberd/chapril_captchas/ -mindepth 1 -maxdepth 1 -type f -mtime -1 | grep -v EXPERIMENTAL | wc -l)"
echo "PUTVAL \"${HOSTNAME}/xmpp_captcha_lasthour/count\" interval=$INTERVAL $(date +%s):$(find /var/lib/ejabberd/chapril_captchas/ -mindepth 1 -maxdepth 1 -type f -mmin -60 | grep -v EXPERIMENTAL | wc -l)"
} }
count_accounts_created_lastday() { _count_accounts_created_lastday() {
_sql_ejabberd " _sql_ejabberd "
select count(*) select count(*)
from users from users
where created_at > current_timestamp - interval '1 day' where created_at > current_timestamp - interval '1 day'
" "
} }
_count_accounts_created_lasthour() {
_sql_ejabberd "
select count(*)
from users
where created_at > current_timestamp - interval '1 hour'
"
}
_xmpp_public_rooms_total_occupants() {
# keep results in a cache file for 5 minutes
local cache_file=/var/tmp/cache_collectd_xmpp_rooms.data
if [ ! -f ${cache_file} -o "$(find ${cache_file} -mmin +5 2>/dev/null)" ]; then
_xmpp_list_public_rooms > ${cache_file}
fi
total_occupants=0
while read line; do
total_occupants=$((total_occupants+$(echo ${line} | awk '{print $2}')))
done < ${cache_file}
echo ${total_occupants}
}
_xmpp_list_public_rooms() {
for room in $(ejabberdctl muc_online_rooms muc.chapril.org | cut -d@ -f1) ; do
if ejabberdctl get_room_options ${room} muc.chapril.org | egrep -q '^public\s*true' ; then
echo -n "${room}: "
ejabberdctl get_room_occupants ${room} muc.chapril.org | cut -d@ -f1 | sort -u | wc -l
fi
done | sort -k 2 -nr
}
_sql_ejabberd() { _sql_ejabberd() {
# XXX the psql command can only works if file /var/lib/ejabberd/.pgpass exists # XXX the psql command can only works if file /var/lib/ejabberd/.pgpass exists

View File

@ -9,7 +9,7 @@ main() {
echo "** Active: $(count_active_accounts)" echo "** Active: $(count_active_accounts)"
echo "** Inactive: $(count_inactive_accounts '1 MONTH')" echo "** Inactive: $(count_inactive_accounts '1 MONTH')"
echo "** Removable: $(count_removable_accounts '6 MONTHS')" echo "** Removable: $(count_removable_accounts '6 MONTHS')"
echo "* Total messages stored (MAM): $(count_archived_messages) " # echo "* Total messages stored (MAM): $(count_archived_messages) "
echo "* Total rooms active: $(sudo -u ejabberd ejabberdctl muc_online_rooms global | wc -l)" echo "* Total rooms active: $(sudo -u ejabberd ejabberdctl muc_online_rooms global | wc -l)"
echo "" echo ""
echo "_* Inactive accounts:_ no connection during last month" echo "_* Inactive accounts:_ no connection during last month"
@ -26,20 +26,20 @@ main() {
echo "" echo ""
echo "h2. ## Audio/Video Call usage:" echo "h2. ## Audio/Video Call usage:"
echo "" echo ""
echo "* Total calls relayed: $(zgrep "$DATE" /var/log/ejabberd/ejabberd.log* | grep -i -e "Offering stun" | wc -l)" echo "* Total calls: $(zgrep "$DATE" /var/log/ejabberd/ejabberd.log* | grep -i -e "Offering stun" | wc -l)"
echo "* Data relayed per protocol per call:" 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 "** UDP: avg $(get_avg_UDP_turn_relayed_data) MiB, max $(get_max_UDP_turn_relayed_data) MiB, total $(get_total_UDP_turn_relayed_data) MiB"
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 "** TCP: avg $(get_avg_TCP_turn_relayed_data) MiB, max $(get_max_TCP_turn_relayed_data) MiB, total $(get_total_TCP_turn_relayed_data) MiB"
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" echo "** TLS: avg $(get_avg_TLS_turn_relayed_data) MiB, max $(get_max_TLS_turn_relayed_data) MiB, total $(get_total_TLS_turn_relayed_data) MiB"
echo "" echo ""
echo "h2. ## XMPP/IRC Bridge (Biboumi) usage:" echo "h2. ## XMPP/IRC Bridge (Biboumi) usage:"
echo "" echo ""
echo "* Total channels active: $(count_biboumi_active_chan)" echo "* Total channels active: $(count_biboumi_active_chan)"
echo "** through $(count_biboumi_active_servers) IRC server(s)" echo "** through $(count_biboumi_active_servers) IRC server(s)"
echo "* Total users: $(count_biboumi_users)" echo "* Total users: $(count_biboumi_users)"
echo "** Active: $(count_biboumi_active_users '1 MONTH') (External accounts: $(count_biboumi_active_external_users '1 MONTH'))" # echo "** Active: $(count_biboumi_active_users '1 MONTH') (External accounts: $(count_biboumi_active_external_users '1 MONTH'))"
echo "** Inactive: $(count_biboumi_inactive_users '1 MONTH') (External accounts: $(count_biboumi_inactive_external_users '1 MONTH'))" # echo "** Inactive: $(count_biboumi_inactive_users '1 MONTH') (External accounts: $(count_biboumi_inactive_external_users '1 MONTH'))"
echo "* Total messages stored (MAM): $(count_biboumi_archived_messages)" # echo "* Total messages stored (MAM): $(count_biboumi_archived_messages)"
} }
get_hard_quota() { get_hard_quota() {
@ -216,60 +216,36 @@ get_last_month() {
get_total_UDP_turn_relayed_data() { get_total_UDP_turn_relayed_data() {
n=$(zgrep "$DATE" /var/log/ejabberd/ejabberd.log* | 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 "scale=4; $n / 1024" | bc -l
echo 0
else
echo $n
fi
} }
get_total_TCP_turn_relayed_data() { get_total_TCP_turn_relayed_data() {
n=$(zgrep "$DATE" /var/log/ejabberd/ejabberd.log* | 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 "scale=4; $n / 1024" | bc -l
echo 0
else
echo $n
fi
} }
get_total_TLS_turn_relayed_data() { get_total_TLS_turn_relayed_data() {
n=$(zgrep "$DATE" /var/log/ejabberd/ejabberd.log* | 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 "scale=4; $n / 1024" | bc -l
echo 0
else
echo $n
fi
} }
get_max_UDP_turn_relayed_data() { 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 -g | tail -n 1) n=$(zgrep "$DATE" /var/log/ejabberd/ejabberd.log* | grep -i -e "Relayed" | grep "UDP" | cut -d" " -f6-6 | sort -g | tail -n 1)
if [ -z $n ]; then echo "scale=4; $n / 1024" | bc -l
echo 0
else
echo $n
fi
} }
get_max_TCP_turn_relayed_data() { 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 -g | tail -n 1) n=$(zgrep "$DATE" /var/log/ejabberd/ejabberd.log* | grep -i -e "Relayed" | grep "TCP" | cut -d" " -f6-6 | sort -g | tail -n 1)
if [ -z $n ]; then echo "scale=4; $n / 1024" | bc -l
echo 0
else
echo $n
fi
} }
get_max_TLS_turn_relayed_data() { 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 -g | tail -n 1) n=$(zgrep "$DATE" /var/log/ejabberd/ejabberd.log* | grep -i -e "Relayed" | grep "TLS" | cut -d" " -f6-6 | sort -g | tail -n 1)
if [ -z $n ]; then echo "scale=4; $n / 1024" | bc -l
echo 0
else
echo $n
fi
} }
get_avg_UDP_turn_relayed_data() { get_avg_UDP_turn_relayed_data() {
n=$(zgrep "$DATE" /var/log/ejabberd/ejabberd.log* | grep -i -e "Relayed" | grep "UDP" | wc -l) n=$(zgrep "$DATE" /var/log/ejabberd/ejabberd.log* | grep -i -e "Offering stun" | wc -l)
total=$(get_total_UDP_turn_relayed_data) total=$(get_total_UDP_turn_relayed_data)
if [ $n -eq 0 ]; then if [ $n -eq 0 ]; then
echo 0 echo 0
@ -279,7 +255,7 @@ get_avg_UDP_turn_relayed_data() {
} }
get_avg_TCP_turn_relayed_data() { get_avg_TCP_turn_relayed_data() {
n=$(zgrep "$DATE" /var/log/ejabberd/ejabberd.log* | grep -i -e "Relayed" | grep "TCP" | wc -l) n=$(zgrep "$DATE" /var/log/ejabberd/ejabberd.log* | grep -i -e "Offering stun" | wc -l)
total=$(get_total_TCP_turn_relayed_data) total=$(get_total_TCP_turn_relayed_data)
if [ $n -eq 0 ]; then if [ $n -eq 0 ]; then
echo 0 echo 0
@ -289,7 +265,7 @@ get_avg_TCP_turn_relayed_data() {
} }
get_avg_TLS_turn_relayed_data() { get_avg_TLS_turn_relayed_data() {
n=$(zgrep "$DATE" /var/log/ejabberd/ejabberd.log* | grep -i -e "Relayed" | grep "TLS" | wc -l) n=$(zgrep "$DATE" /var/log/ejabberd/ejabberd.log* | grep -i -e "Offering stun" | wc -l)
total=$(get_total_TLS_turn_relayed_data) total=$(get_total_TLS_turn_relayed_data)
if [ $n -eq 0 ]; then if [ $n -eq 0 ]; then
echo 0 echo 0