From 9563be75d1467258138e1fa141f5937688086bc4 Mon Sep 17 00:00:00 2001 From: pitchum Date: Wed, 24 Mar 2021 09:29:51 +0100 Subject: [PATCH] Add metrology for new accounts created --- metrology/collectd_exec_xmpp.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/metrology/collectd_exec_xmpp.sh b/metrology/collectd_exec_xmpp.sh index 7e8afb4..a69350a 100755 --- a/metrology/collectd_exec_xmpp.sh +++ b/metrology/collectd_exec_xmpp.sh @@ -24,6 +24,8 @@ ejabberdctl_stats() { 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)" + + echo "PUTVAL \"${HOSTNAME}/xmpp_accounts_created_lastday/count\" interval=$INTERVAL $(date +%s):$(count_accounts_created_lastday)" } http_upload_disk_usage() { @@ -38,6 +40,19 @@ 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)" } +count_accounts_created_lastday() { + _sql_ejabberd " + select count(*) + from users + where created_at > current_timestamp - interval '1 day' +" +} + +_sql_ejabberd() { + # XXX the psql command can only works if file /var/lib/ejabberd/.pgpass exists + psql -U ejabberd -h localhost ejabberd -c "${1}" -t | grep -v '^$' | awk '{print $1}' +} + # XXX la syntaxe de la boucle while ci-dessous fait échouer le démarrage de collectd. # exec plugin: exec_read_one: error = /srv/xmpp.chapril.org/tools/metrology/collectd_exec_xmpp.sh: 44: /srv/xmpp.chapril.org/tools/metrology/collectd_exec_xmpp.sh: Syntax error: redirection unexpected #client_stats(){