-
-
Save laem/99c4565bd33be58996af to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Cet ensemble de scripts pour obtenir les stats du simulateur d'embauche est complètement archaïque... | |
# mais on le fait tourner seulement tous les 2-3 mois... | |
# Sur le serveur | |
mkdir logs-DATE | |
sudo su | |
cp /var/log/nginx/openfisca.* /home/pousse/logs-10juillet2017/ | |
# on compresse les logs pour les transférer sur un autre ordi... | |
tar -czvf logs-DATE.tar.gz logs-DATE | |
# ...sur un autre ordi assez puissant, pour éviter de bouffer le CPU / mémoire du serveur de prod | |
scp pb:/home/pousse/logs-DATE OÙ/TU/VEUX | |
# dans le dir avec tous les fichiers de log tournants openfisca.log.N fraichement extraits. | |
# Attention : plusieurs gigas ! Pour analyser les derniers mois seulement, il suffirt d'exclure les vieux logs | |
# total request count | |
sort openfisca.log* | uniq | wc -l | |
# count by month | |
sort openfisca.log* | uniq | awk '{print $4}' | cut -c 5-12 | sort | uniq -c | |
# per day | |
sort openfisca.log* | uniq | awk '{print $4}' | cut -c 5-12 | sort | uniq -c | |
# per integration | |
sort openfisca.log* | uniq | awk '{print $11}' | sort | uniq -c | |
# per specific integration | |
sort openfisca.log* | uniq | awk '{print $11}' | grep 'sgmap.github.io' | sort | wc -l | |
# Get the requests of a specific month | |
cat openfisca.log* | awk ' $4 ~ /Apr\/2016/' | sort | uniq > month | |
cat april | awk '{print $1 "\t" $7 $11}' | sort | uniq | awk '{print $1}' | sort | uniq -c > month_uniq | |
# Get all log files | Only select IP, GET url, integration url | remove duplicates | select IP in order to count the number of different requests by IP | |
# To count : | |
wc -l month_uniq | |
cat month_uniq | awk '$1 >= 10 {print $1}' | awk '{s+=$1} END {print s}' | |
# Get the total number of requests for which the user did more than x request | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment