From 41855188a97028bcf0c3c5c15020b57840facecf Mon Sep 17 00:00:00 2001 From: pitchum Date: Sun, 18 Apr 2021 12:35:05 +0200 Subject: [PATCH] Metrology: increase frequency of accounts and captchas measures --- metrology/collectd_exec_xmpp.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/metrology/collectd_exec_xmpp.sh b/metrology/collectd_exec_xmpp.sh index 511635f..37c8153 100755 --- a/metrology/collectd_exec_xmpp.sh +++ b/metrology/collectd_exec_xmpp.sh @@ -25,7 +25,8 @@ ejabberdctl_stats() { 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_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 } @@ -39,15 +40,23 @@ http_upload_disk_usage() { 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_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 " select count(*) from users 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