Add an admin script to check if mumble's WebUI is currently in use.

This commit is contained in:
pitchum 2020-05-16 15:12:45 +02:00 committed by root
parent bd0ddcc899
commit c2930509fc

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