mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-22 14:16:00 +00:00
[synapse_] Added bots to graph
This commit is contained in:
parent
cf9a6da4df
commit
d45777ce6e
1 changed files with 16 additions and 4 deletions
|
@ -116,6 +116,9 @@ total_registered.min 0
|
||||||
active_users.label active users
|
active_users.label active users
|
||||||
active_users.info active users
|
active_users.info active users
|
||||||
active_users.min 0
|
active_users.min 0
|
||||||
|
bots.label active bots
|
||||||
|
bots.info active bots
|
||||||
|
bots.min 0
|
||||||
online_users.label online users
|
online_users.label online users
|
||||||
online_users.info online users
|
online_users.info online users
|
||||||
online_users.min 0
|
online_users.min 0
|
||||||
|
@ -165,25 +168,34 @@ EOM
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
USERS=$(fetch_url -H "Authorization: Bearer ${AUTH_TOKEN}" "${SCHEME}${HOMESERVER}:${PORT}${ADMIN_API_PATH}/v2/users?deactivated=true¬_user_type=bot&limit=${QUERY_LIMIT}")
|
USERS=$(fetch_url -H "Authorization: Bearer ${AUTH_TOKEN}" "${SCHEME}${HOMESERVER}:${PORT}${ADMIN_API_PATH}/v2/users?deactivated=true&limit=${QUERY_LIMIT}")
|
||||||
ROOMS=$(fetch_url -H "Authorization: Bearer ${AUTH_TOKEN}" "${SCHEME}${HOMESERVER}:${PORT}${ADMIN_API_PATH}/v1/rooms?limit=${QUERY_LIMIT}")
|
ROOMS=$(fetch_url -H "Authorization: Bearer ${AUTH_TOKEN}" "${SCHEME}${HOMESERVER}:${PORT}${ADMIN_API_PATH}/v1/rooms?limit=${QUERY_LIMIT}")
|
||||||
REPORTS=$(fetch_url -H "Authorization: Bearer ${AUTH_TOKEN}" "${SCHEME}${HOMESERVER}:${PORT}${ADMIN_API_PATH}/v1/event_reports" | jq .total)
|
REPORTS=$(fetch_url -H "Authorization: Bearer ${AUTH_TOKEN}" "${SCHEME}${HOMESERVER}:${PORT}${ADMIN_API_PATH}/v1/event_reports" | jq .total)
|
||||||
|
|
||||||
echo multigraph synapse_users_"${CLEANHOMESERVER}"
|
echo multigraph synapse_users_"${CLEANHOMESERVER}"
|
||||||
if USERS="$(echo "$USERS" | jq -r)"; then
|
if USERS="$(echo "$USERS" | jq -r)"; then
|
||||||
echo total_registered.value "$(echo "$USERS" | jq -r .total)"
|
total="$(echo "$USERS" | jq -r .total)"
|
||||||
echo active_users.value "$(echo "$USERS" | grep -c '"deactivated": 0')"
|
bots="$(echo "$USERS" | grep -c '"user_type": "bot"')"
|
||||||
|
total_registered=$(( total - bots ))
|
||||||
|
echo total_registered.value "$total_registered"
|
||||||
|
active="$(echo "$USERS" | grep -c '"deactivated": 0')"
|
||||||
|
active_users=$(( active - bots ))
|
||||||
|
echo active_users.value "$active_users"
|
||||||
|
echo bots.value "$bots"
|
||||||
# Convert to miliseconds
|
# Convert to miliseconds
|
||||||
time_ms=$(($(date +%s) * 1000))
|
time_ms=$(($(date +%s) * 1000))
|
||||||
interval_ms=$((INTERVAL * 1000))
|
interval_ms=$((INTERVAL * 1000))
|
||||||
time_interval_ago=$(( time_ms - interval_ms ))
|
time_interval_ago=$(( time_ms - interval_ms ))
|
||||||
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]+")
|
||||||
echo online_users.value "$(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 ))
|
||||||
|
echo online_users.value "$bots"
|
||||||
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
|
||||||
echo "total_registered.value U"
|
echo "total_registered.value U"
|
||||||
echo "active_users.value U"
|
echo "active_users.value U"
|
||||||
|
echo "bots.value U"
|
||||||
echo "online_users.value U"
|
echo "online_users.value U"
|
||||||
echo "deactivated_users.value U"
|
echo "deactivated_users.value U"
|
||||||
echo "erased_users.value U"
|
echo "erased_users.value U"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue