Merge pull request #1433 from brknkfr/synapse_fix
[synapse_] Ignore puppet users of bridges (last_seen_ts is null)
This commit is contained in:
commit
2328b39d28
|
@ -74,7 +74,7 @@ AUTH_TOKEN="${auth_token:-}"
|
|||
INTERVAL="${interval:-300}"
|
||||
PORT="${port:-443}"
|
||||
ADMIN_API_PATH="${admin_api_path:-/_synapse/admin}"
|
||||
QUERY_LIMIT="${query_limit:-1000}"
|
||||
QUERY_LIMIT="${query_limit:-10000}"
|
||||
HOMESERVER="${0##*synapse_}"
|
||||
SCHEME="${scheme:-https}://"
|
||||
TIMEOUT="${timeout:-2}"
|
||||
|
@ -175,11 +175,13 @@ REPORTS=$(fetch_url -H "Authorization: Bearer ${AUTH_TOKEN}" "${SCHEME}${HOMESER
|
|||
echo multigraph synapse_users_"${CLEANHOMESERVER}"
|
||||
if USERS="$(echo "$USERS" | jq -r)"; then
|
||||
total="$(echo "$USERS" | jq -r .total)"
|
||||
puppets="$(echo "$USERS" | grep -c '"last_seen_ts": null')"
|
||||
bots="$(echo "$USERS" | grep -c '"user_type": "bot"')"
|
||||
total_registered=$(( total - bots ))
|
||||
virtual_users=$(( puppets + bots ))
|
||||
total_registered=$(( total - virtual_users ))
|
||||
echo total_registered.value "$total_registered"
|
||||
active="$(echo "$USERS" | grep -c '"deactivated": 0')"
|
||||
active_users=$(( active - bots ))
|
||||
active_users=$(( active - virtual_users ))
|
||||
echo active_users.value "$active_users"
|
||||
echo bots.value "$bots"
|
||||
# Convert to miliseconds
|
||||
|
@ -189,7 +191,7 @@ if USERS="$(echo "$USERS" | jq -r)"; then
|
|||
last_seen_times_ms=$(echo "$USERS" | grep -E "\"last_seen_ts\": [0-9]+")
|
||||
online="$(echo "$last_seen_times_ms" | awk -v "count=0" -F": " '$2 > "'$time_interval_ago'" {count++} END {print count}')"
|
||||
online_users=$(( online - bots ))
|
||||
echo online_users.value "$bots"
|
||||
echo online_users.value "$online_users"
|
||||
echo deactivated_users.value "$(echo "$USERS" | grep -c '"deactivated": 1')"
|
||||
echo erased_users.value "$(echo "$USERS" | grep -c '"erased": true')"
|
||||
else
|
||||
|
@ -217,10 +219,9 @@ else
|
|||
echo "rooms_total.value U"
|
||||
fi
|
||||
echo multigraph synapse_reports_"${CLEANHOMESERVER}"
|
||||
if [ "$REPORTS" -eq "$REPORTS" ]; then
|
||||
echo event_reports.value "$REPORTS"
|
||||
if [ -n "$REPORTS" ] && [ "$REPORTS" -eq "$REPORTS" ]; then
|
||||
echo event_reports.value "$REPORTS"
|
||||
else
|
||||
echo "event_reports.value U"
|
||||
fi
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue