Compare commits
No commits in common. "c467b2574b2b26a9474c263f540eb1d763778afe" and "a5e45d737ecde183d95c0fafec92bfff09051a03" have entirely different histories.
c467b2574b
...
a5e45d737e
|
@ -6,21 +6,17 @@ main() {
|
|||
echo "h2. ## Global info"
|
||||
echo ""
|
||||
echo "* Total accounts: $(sudo -u ejabberd ejabberdctl registered_users chapril.org | egrep -v -e 'r\.giskard' -e '(lisa|bart)\.simpson' | wc -l)"
|
||||
echo "** Active: $(count_active_accounts)"
|
||||
echo "** Inactive: $(count_inactive_accounts '1 MONTH')"
|
||||
echo "** Removable: $(count_removable_accounts '6 MONTHS')"
|
||||
echo "* Total messages stored (MAM): $(count_archived_messages) "
|
||||
echo "* Total rooms active: $(sudo -u ejabberd ejabberdctl muc_online_rooms global | wc -l)"
|
||||
echo ""
|
||||
echo "_* Inactive accounts:_ no connection during last month"
|
||||
echo "_* Removable accounts:_ no connection in the last 6 months *and* didn't read the welcome message"
|
||||
|
||||
# echo "Active users: $(sudo -u ejabberd ejabberdctl connected_users_number)"
|
||||
echo ""
|
||||
echo "h2. ## HTTP upload storage:"
|
||||
echo ""
|
||||
echo "* User quota: $(get_hard_quota)M"
|
||||
echo "* Total disk usage: $(du -sh ${STORAGE_DIR} | awk '{print $1}')"
|
||||
per_account_storage_usage
|
||||
# echo "s2s outgoing connections: $(sudo -u ejabberd ejabberdctl incoming_s2s_number)"
|
||||
# echo "s2s incoming connections: $(sudo -u ejabberd ejabberdctl outgoing_s2s_number)"
|
||||
}
|
||||
|
||||
get_hard_quota() {
|
||||
|
@ -42,44 +38,6 @@ per_account_storage_usage() {
|
|||
echo "** Avg: ${avg}M"
|
||||
}
|
||||
|
||||
count_active_accounts() {
|
||||
since=${1:-'1 MONTH'}
|
||||
sql="select count(distinct l.username)
|
||||
from last l
|
||||
join users u on l.username = u.username
|
||||
where to_timestamp(cast(l.seconds as int)) > current_timestamp - interval '${since}'
|
||||
and l.username not in ('r.giskard', 'lisa.simpson', 'bart.simpson')"
|
||||
|
||||
psql -U ejabberd -h localhost ejabberd -c "${sql}" -t | grep -v '^$' | awk '{print $1}'
|
||||
}
|
||||
|
||||
count_inactive_accounts() {
|
||||
since=${1:-'1 MONTH'}
|
||||
sql="select count(distinct l.username)
|
||||
from last l
|
||||
join users u on l.username = u.username
|
||||
where to_timestamp(cast(l.seconds as int)) < current_timestamp - interval '${since}'
|
||||
and l.username not in ('r.giskard', 'lisa.simpson', 'bart.simpson')"
|
||||
|
||||
psql -U ejabberd -h localhost ejabberd -c "${sql}" -t | grep -v '^$' | awk '{print $1}'
|
||||
}
|
||||
|
||||
|
||||
count_removable_accounts() {
|
||||
# Accounts inactive *and* who never read the welcome message.
|
||||
since=${1:-'6 MONTHS'}
|
||||
sql="select count(distinct l.username)
|
||||
from last l
|
||||
join users u on l.username = u.username
|
||||
join spool s on l.username = s.username
|
||||
where to_timestamp(cast(l.seconds as int)) < current_timestamp - interval '${since}'
|
||||
and s.xml like '%from=''chapril.org'' xmlns=''jabber:client''%Bienvenue sur le serveur%'
|
||||
and s.username not in ('r.giskard', 'lisa.simpson', 'bart.simpson')"
|
||||
|
||||
psql -U ejabberd -h localhost ejabberd -c "${sql}" -t | grep -v '^$' | awk '{print $1}'
|
||||
}
|
||||
|
||||
|
||||
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}'
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#! /bin/bash
|
||||
|
||||
TEMPLATE=/srv/xmpp.chapril.org/tools/serviceinfo/template-serviceinfo.json
|
||||
TARGET_FILE=/srv/xmpp.chapril.org/experimental/serviceinfo.json
|
||||
TARGET_FILE=/srv/serviceinfo.json
|
||||
|
||||
main() {
|
||||
cat "${TEMPLATE}" \
|
||||
|
@ -56,9 +56,11 @@ starttime() {
|
|||
|
||||
user_activity() {
|
||||
days_back=${1:-30}
|
||||
sql="select count(distinct l.username)
|
||||
from last l
|
||||
where to_timestamp(cast(l.seconds as int)) > current_timestamp - interval '${days_back} days'
|
||||
sql="select count(distinct username)
|
||||
from archive
|
||||
where peer not like 'irc%'
|
||||
and kind = 'chat'
|
||||
and created_at > current_timestamp - interval '${days_back} days'
|
||||
and username not in ('r.giskard', 'lisa.simpson', 'bart.simpson')"
|
||||
|
||||
psql -U ejabberd -h localhost ejabberd -c "${sql}" -t | grep -v '^$' | awk '{print $1}'
|
||||
|
|
Loading…
Reference in New Issue