Compare commits

...

2 Commits

Author SHA1 Message Date
db51aa24b8 Better mumble statistics:
- The number of connections was simply useless as it was not accounting
actual connections, but all TCP scans from bots. Now it counts only
connections from mumble clients
- The number of connections made by the mumble-web frontend is also
accounted by counting connections from localhost.
2020-11-01 15:00:00 +01:00
c2930509fc Add an admin script to check if mumble's WebUI is currently in use. 2020-05-16 15:12:45 +02:00
2 changed files with 38 additions and 1 deletions

31
active_web_users Executable file
View File

@ -0,0 +1,31 @@
#! /bin/bash
# Parse mumble logs in order to determine if someone is currently accessing
# mumble through the WebUI. If not it means we can safely restart nginx
# on the reverse-proxy side without bothering anyone :)
MUMBLE_LOG=/var/log/mumble-server/mumble-server.log
main() {
candidates=$(last_connections)
for candidate in ${candidates}; do
grep "<${candidate}:" "${MUMBLE_LOG}" | tail -n 1 | grep -q 'Connection closed'
if [ $? -ne 0 ]; then
echo "At least one person is currently using mumble's Web interface."
grep "<${candidate}:" "${MUMBLE_LOG}" | tail -n 5
exit 1
fi
done
echo "It looks like nobody is currently using mumble's Web interface. You may restart nginx if you want ;)"
exit 0
}
last_connections() {
grep 'Client.*Node.js' "${MUMBLE_LOG}" \
| tail -n 10 \
| sed -r 's/^.*=> <([0-9]+):\(-1\)>.*$/\1/' \
| tac
}
main

View File

@ -52,18 +52,22 @@ writeStatValue()
# Extraction mumble important values
NB_OF_USERS=0
NB_OF_WEB_CONNECTIONS=0
NB_OF_CONNECTIONS=0
NB_OF_ROOMS=0
# Work out iso date match for prev month
PREV_MONTH_MATCH=$(date +%Y-%m -d "1 month ago")
NB_OF_CONNECTIONS=$(grep -hE "<W>${PREV_MONTH_MATCH}.*New connection" /var/log/mumble-server/*.log.*|wc -l)
NB_OF_CONNECTIONS=$(grep -hE "<W>${PREV_MONTH_MATCH}.*Client version" /var/log/mumble-server/*.log.*|wc -l)
NB_OF_USERS=$(grep -hE "<W>${PREV_MONTH_MATCH}.*Authenticated" /var/log/mumble-server/*.log.*|grep -hEo "<[0-9]+\:.*\(-1\)"|grep -hEo "\:.*"|sort|uniq|wc -l)
NB_OF_WEB_CONNECTIONS=$(grep -hE "<W>${PREV_MONTH_MATCH}.*New connection\: 127\.0\.0\.1" /var/log/mumble-server/*.log.*|wc -l)
NB_OF_ROOMS=$(grep -hE "<W>${PREV_MONTH_MATCH}.*Moved" /var/log/mumble-server/*.log.*|grep -hEo "to [^[]+"|sort|uniq|wc -l)
# Get previous values
NB_OF_USERS_P=0
NB_OF_WEB_CONNECTIONS_P=0
NB_OF_CONNECTIONS_P=0
NB_OF_ROOMS_P=0
@ -75,6 +79,7 @@ fi
# Save current values for the next run
mkdir -p ${MUMBLE_STATS_DIR}
echo "NB_OF_USERS_P="${NB_OF_USERS} >> ${MUMBLE_STATS_FILE}
echo "NB_OF_WEB_CONNECTIONS_P="${NB_OF_WEB_CONNECTIONS} >> ${MUMBLE_STATS_FILE}
echo "NB_OF_CONNECTIONS_P="${NB_OF_CONNECTIONS} >> ${MUMBLE_STATS_FILE}
echo "NB_OF_ROOMS_P="${NB_OF_ROOMS} >> ${MUMBLE_STATS_FILE}
@ -87,6 +92,7 @@ echo
writeStatValue "Nombre d'utilisateurs" "" ${NB_OF_USERS} ${NB_OF_USERS_P}
writeStatValue "Nombre de salons utilisés" "" ${NB_OF_ROOMS} ${NB_OF_ROOMS_P}
writeStatValue "Nombre de connexions" "" ${NB_OF_CONNECTIONS} ${NB_OF_CONNECTIONS_P}
writeStatValue "Nombre de connexions web" "" ${NB_OF_WEB_CONNECTIONS} ${NB_OF_WEB_CONNECTIONS_P}
# Addition des infos HTTP
/srv/mumble.chapril.org/tools/rapports_activites/rapport_activites_http.sh -p