23
2
Fork 0

Add stats about MAM data: row count and total data size

This commit is contained in:
pitchum 2022-06-04 10:01:51 +02:00 committed by root
parent 27ed344758
commit 1b65fc9bdd
1 changed files with 14 additions and 0 deletions

View File

@ -27,6 +27,8 @@ ejabberdctl_stats() {
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 "PUTVAL \"${HOSTNAME}/xmpp_total_mam_rows/count\" interval=$INTERVAL $(date +%s):$(_count_mam_rows)"
echo "PUTVAL \"${HOSTNAME}/xmpp_total_mam_size/count\" interval=$INTERVAL $(date +%s):$(_estimate_mam_size)"
echo -n "PUTVAL \"${HOSTNAME}/xmpp_public_rooms_occupants/count\" interval=$INTERVAL $(date +%s):" ; _xmpp_public_rooms_total_occupants
}
@ -58,6 +60,18 @@ _count_accounts_created_lasthour() {
"
}
_count_mam_rows() {
_sql_ejabberd "SELECT reltuples::bigint AS estimate FROM pg_class WHERE relname = 'archive'"
}
_estimate_mam_size() {
_sql_ejabberd "
select pg_relation_size(relid) as mam_size
from pg_catalog.pg_statio_user_tables
where relname = 'archive'
"
}
_xmpp_public_rooms_total_occupants() {
# keep results in a cache file for 5 minutes
local cache_file=/var/tmp/cache_collectd_xmpp_rooms.data