Compare commits

..

No commits in common. "db51aa24b84487549ceeaa2312a159f8e15e307d" and "bd0ddcc899e545cc03a2959c267ac57f51dd38b7" have entirely different histories.

2 changed files with 1 additions and 38 deletions

View File

@ -1,31 +0,0 @@
#! /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,22 +52,18 @@ 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}.*Client version" /var/log/mumble-server/*.log.*|wc -l)
NB_OF_CONNECTIONS=$(grep -hE "<W>${PREV_MONTH_MATCH}.*New connection" /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
@ -79,7 +75,6 @@ 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}
@ -92,7 +87,6 @@ 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