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.
This commit is contained in:
Laurent Poujoulat 2020-11-01 15:00:00 +01:00 committed by root
parent c2930509fc
commit db51aa24b8

View File

@ -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