2021-03-14 15:16:39 +01:00
|
|
|
HOSTNAME="${COLLECTD_HOSTNAME:-localhost}"
|
|
|
|
INTERVAL="${COLLECTD_INTERVAL:-60}"
|
|
|
|
|
|
|
|
# required by some ejabberdctl commands
|
|
|
|
export HOME=/var/lib/ejabberd
|
2021-03-15 20:18:49 +01:00
|
|
|
export HTTP_UPLOAD_DATADIR="/var/www/xmpp.chapril.org/upload/"
|
2021-03-14 15:16:39 +01:00
|
|
|
|
2021-03-15 20:18:49 +01:00
|
|
|
|
|
|
|
main() {
|
|
|
|
# do-while hack found here: https://stackoverflow.com/questions/24420342/is-there-a-do-while-loop-in-bash#24421013
|
|
|
|
while
|
|
|
|
ejabberdctl_stats
|
|
|
|
http_upload_disk_usage
|
|
|
|
sleep "$INTERVAL"
|
|
|
|
do true; done
|
|
|
|
}
|
|
|
|
|
|
|
|
ejabberdctl_stats() {
|
2021-03-14 15:16:39 +01:00
|
|
|
echo "PUTVAL \"${HOSTNAME}/xmpp_registered_users/count\" interval=$INTERVAL $(date +%s):$(ejabberdctl registered_users chapril.org | wc -l)"
|
|
|
|
echo "PUTVAL \"${HOSTNAME}/xmpp_active_users/count\" interval=$INTERVAL $(date +%s):$(ejabberdctl connected_users_number)"
|
2021-03-16 08:40:41 +01:00
|
|
|
echo "PUTVAL \"${HOSTNAME}/xmpp_active_distinct_users/count\" interval=$INTERVAL $(date +%s):$(ejabberdctl connected_users | cut -d@ -f1 | sort -u | wc -l)"
|
2021-03-14 15:16:39 +01:00
|
|
|
echo "PUTVAL \"${HOSTNAME}/xmpp_s2s_in/count\" interval=$INTERVAL $(date +%s):$(ejabberdctl incoming_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)"
|
2021-03-15 20:18:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
http_upload_disk_usage() {
|
|
|
|
subfolders_count=$(find ${HTTP_UPLOAD_DATADIR} -mindepth 1 -maxdepth 1 -type d | wc -l)
|
|
|
|
total_size=$(du -s ${HTTP_UPLOAD_DATADIR} | awk '{print $1}')
|
|
|
|
avg=$(( ${total_size} / ${subfolders_count} ))
|
|
|
|
echo "PUTVAL \"${HOSTNAME}/xmpp_upload_data_total/count\" interval=$INTERVAL $(date +%s):${total_size}"
|
|
|
|
echo "PUTVAL \"${HOSTNAME}/xmpp_upload_data_avg/count\" interval=$INTERVAL $(date +%s):${avg}"
|
|
|
|
}
|
2021-03-14 15:16:39 +01:00
|
|
|
|
2021-03-15 20:18:49 +01:00
|
|
|
main
|