From dd3a70f5482862ffb83a0334178643bdbabcc619 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 8 Feb 2021 20:31:02 +0100 Subject: [PATCH] New metrics for XMPP IRC Bridge (Biboumi) --- rapport_activite/rapport_activites.sh | 68 ++++++++++++++++++++++++++- 1 file changed, 67 insertions(+), 1 deletion(-) diff --git a/rapport_activite/rapport_activites.sh b/rapport_activite/rapport_activites.sh index 17646a5..aa27be5 100755 --- a/rapport_activite/rapport_activites.sh +++ b/rapport_activite/rapport_activites.sh @@ -31,6 +31,15 @@ main() { 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" 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 "" + echo "h2. ## XMPP/IRC Bridge (Biboumi) usage:" + echo "" + echo "* Total users: $(count_biboumi_users)" + echo "** Active: $(count_biboumi_active_users '1 MONTH')" + echo "** Inactive: $(count_biboumi_inactive_users '1 MONTH')" + echo "* Total messages stored (MAM): $(count_biboumi_archived_messages)" + echo "* Total channels active: $(count_biboumi_active_chan)" + echo "** through $(count_biboumi_active_servers) IRC server(s)" } get_hard_quota() { @@ -90,7 +99,64 @@ count_removable_accounts() { } 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}' + sudo -Hiu postgres psql biboumi -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}' +} + +count_biboumi_users() { + # Accounts inactive *and* who never read the welcome message. + sql="select count(distinct owner_) + from muclogline_" + + sudo -Hiu postgres psql biboumi -c "${sql}" -t | grep -v '^$' | awk '{print $1}' +} + +count_biboumi_active_users() { + # Accounts inactive *and* who never read the welcome message. + since=${1:-'1 MONTH'} + sql="select count(distinct owner_) + from muclogline_ + where to_timestamp(date_) > current_timestamp - interval '${since}'" + + sudo -Hiu postgres psql biboumi -c "${sql}" -t | grep -v '^$' | awk '{print $1}' +} + +count_biboumi_inactive_users() { + # Accounts inactive *and* who never read the welcome message. + since=${1:-'1 MONTH'} + sql="select count(distinct owner_) + from muclogline_ + where to_timestamp(date_) < current_timestamp - interval '${since}'" + + sudo -Hiu postgres psql biboumi -c "${sql}" -t | grep -v '^$' | awk '{print $1}' +} + +count_biboumi_archived_messages() { + # Accounts inactive *and* who never read the welcome message. + since=${1:-'1 MONTH'} + sql="select count(distinct body_) + from muclogline_" + + sudo -Hiu postgres psql biboumi -c "${sql}" -t | grep -v '^$' | awk '{print $1}' +} + +count_biboumi_active_servers() { + # Accounts inactive *and* who never read the welcome message. + since=${1:-'1 MONTH'} + sql="select count(distinct ircservername_) + from muclogline_ + where to_timestamp(date_) > current_timestamp - interval '${since}'" + + sudo -Hiu postgres psql biboumi -c "${sql}" -t | grep -v '^$' | awk '{print $1}' +} + +count_biboumi_active_chan() { + # Accounts inactive *and* who never read the welcome message. + since=${1:-'1 MONTH'} + sql="select count(distinct ircchanname_) + from muclogline_ + where to_timestamp(date_) > current_timestamp - interval '${since}'" + + sudo -Hiu postgres psql biboumi -c "${sql}" -t | grep -v '^$' | awk '{print $1}' } get_last_month() {