mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-22 02:51:03 +00:00
[synapse_] Ignore puppet users of bridges (last_seen_ms is null)
This commit is contained in:
parent
f165c625bf
commit
95a651ee63
1 changed files with 8 additions and 7 deletions
|
@ -74,7 +74,7 @@ AUTH_TOKEN="${auth_token:-}"
|
||||||
INTERVAL="${interval:-300}"
|
INTERVAL="${interval:-300}"
|
||||||
PORT="${port:-443}"
|
PORT="${port:-443}"
|
||||||
ADMIN_API_PATH="${admin_api_path:-/_synapse/admin}"
|
ADMIN_API_PATH="${admin_api_path:-/_synapse/admin}"
|
||||||
QUERY_LIMIT="${query_limit:-1000}"
|
QUERY_LIMIT="${query_limit:-10000}"
|
||||||
HOMESERVER="${0##*synapse_}"
|
HOMESERVER="${0##*synapse_}"
|
||||||
SCHEME="${scheme:-https}://"
|
SCHEME="${scheme:-https}://"
|
||||||
TIMEOUT="${timeout:-2}"
|
TIMEOUT="${timeout:-2}"
|
||||||
|
@ -175,11 +175,13 @@ REPORTS=$(fetch_url -H "Authorization: Bearer ${AUTH_TOKEN}" "${SCHEME}${HOMESER
|
||||||
echo multigraph synapse_users_"${CLEANHOMESERVER}"
|
echo multigraph synapse_users_"${CLEANHOMESERVER}"
|
||||||
if USERS="$(echo "$USERS" | jq -r)"; then
|
if USERS="$(echo "$USERS" | jq -r)"; then
|
||||||
total="$(echo "$USERS" | jq -r .total)"
|
total="$(echo "$USERS" | jq -r .total)"
|
||||||
|
puppets="$(echo "$USERS" | grep -c '"last_seen_ts": null')"
|
||||||
bots="$(echo "$USERS" | grep -c '"user_type": "bot"')"
|
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"
|
echo total_registered.value "$total_registered"
|
||||||
active="$(echo "$USERS" | grep -c '"deactivated": 0')"
|
active="$(echo "$USERS" | grep -c '"deactivated": 0')"
|
||||||
active_users=$(( active - bots ))
|
active_users=$(( active - virtual_users ))
|
||||||
echo active_users.value "$active_users"
|
echo active_users.value "$active_users"
|
||||||
echo bots.value "$bots"
|
echo bots.value "$bots"
|
||||||
# Convert to miliseconds
|
# 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]+")
|
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="$(echo "$last_seen_times_ms" | awk -v "count=0" -F": " '$2 > "'$time_interval_ago'" {count++} END {print count}')"
|
||||||
online_users=$(( online - bots ))
|
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 deactivated_users.value "$(echo "$USERS" | grep -c '"deactivated": 1')"
|
||||||
echo erased_users.value "$(echo "$USERS" | grep -c '"erased": true')"
|
echo erased_users.value "$(echo "$USERS" | grep -c '"erased": true')"
|
||||||
else
|
else
|
||||||
|
@ -217,10 +219,9 @@ else
|
||||||
echo "rooms_total.value U"
|
echo "rooms_total.value U"
|
||||||
fi
|
fi
|
||||||
echo multigraph synapse_reports_"${CLEANHOMESERVER}"
|
echo multigraph synapse_reports_"${CLEANHOMESERVER}"
|
||||||
if [ "$REPORTS" -eq "$REPORTS" ]; then
|
if [ -n "$REPORTS" ] && [ "$REPORTS" -eq "$REPORTS" ]; then
|
||||||
echo event_reports.value "$REPORTS"
|
echo event_reports.value "$REPORTS"
|
||||||
else
|
else
|
||||||
echo "event_reports.value U"
|
echo "event_reports.value U"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue