Compare commits
2 Commits
bd0ddcc899
...
db51aa24b8
Author | SHA1 | Date | |
---|---|---|---|
db51aa24b8 | |||
c2930509fc |
31
active_web_users
Executable file
31
active_web_users
Executable 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
|
@ -52,18 +52,22 @@ writeStatValue()
|
|||||||
|
|
||||||
# Extraction mumble important values
|
# Extraction mumble important values
|
||||||
NB_OF_USERS=0
|
NB_OF_USERS=0
|
||||||
|
NB_OF_WEB_CONNECTIONS=0
|
||||||
NB_OF_CONNECTIONS=0
|
NB_OF_CONNECTIONS=0
|
||||||
NB_OF_ROOMS=0
|
NB_OF_ROOMS=0
|
||||||
|
|
||||||
# Work out iso date match for prev month
|
# Work out iso date match for prev month
|
||||||
PREV_MONTH_MATCH=$(date +%Y-%m -d "1 month ago")
|
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_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)
|
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
|
# Get previous values
|
||||||
NB_OF_USERS_P=0
|
NB_OF_USERS_P=0
|
||||||
|
NB_OF_WEB_CONNECTIONS_P=0
|
||||||
NB_OF_CONNECTIONS_P=0
|
NB_OF_CONNECTIONS_P=0
|
||||||
NB_OF_ROOMS_P=0
|
NB_OF_ROOMS_P=0
|
||||||
|
|
||||||
@ -75,6 +79,7 @@ fi
|
|||||||
# Save current values for the next run
|
# Save current values for the next run
|
||||||
mkdir -p ${MUMBLE_STATS_DIR}
|
mkdir -p ${MUMBLE_STATS_DIR}
|
||||||
echo "NB_OF_USERS_P="${NB_OF_USERS} >> ${MUMBLE_STATS_FILE}
|
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_CONNECTIONS_P="${NB_OF_CONNECTIONS} >> ${MUMBLE_STATS_FILE}
|
||||||
echo "NB_OF_ROOMS_P="${NB_OF_ROOMS} >> ${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 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 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" "" ${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
|
# Addition des infos HTTP
|
||||||
/srv/mumble.chapril.org/tools/rapports_activites/rapport_activites_http.sh -p
|
/srv/mumble.chapril.org/tools/rapports_activites/rapport_activites_http.sh -p
|
||||||
|
Loading…
Reference in New Issue
Block a user