Improved script rapport_activite.sh according with shellCheck
This commit is contained in:
parent
a08d603b49
commit
3d24b74754
|
@ -36,31 +36,31 @@ generateReport()
|
|||
local yearMonth="$3"
|
||||
echo -e "================================================================="
|
||||
echo
|
||||
httpRequestCount=$(zgrep "$monthEnglish" /var/log/apache2/paste.chapril.org/paste.chapril.org-acces.log*|grep $year|wc -l)
|
||||
httpRequestCount=$(zgrep "$monthEnglish" /var/log/apache2/paste.chapril.org/paste.chapril.org-acces.log*|grep -c "$year")
|
||||
echo "Nombre total de requêtes http = $httpRequestCount"
|
||||
|
||||
trueHttpRequestCount=$(zgrep "$monthEnglish" /var/log/apache2/paste.chapril.org/paste.chapril.org-acces.log*|grep $year|grep -vi bot|grep -v check|wc -l)
|
||||
trueHttpRequestCount=$(zgrep "$monthEnglish" /var/log/apache2/paste.chapril.org/paste.chapril.org-acces.log*|grep "$year"|grep -vi bot|grep -c -v check)
|
||||
echo "Nombre de vraies requêtes http = $trueHttpRequestCount"
|
||||
|
||||
botRequestCount=$(zgrep "$monthEnglish" /var/log/apache2/paste.chapril.org/paste.chapril.org-acces.log*|grep $year|grep -i bot|grep -v check|wc -l)
|
||||
botRequestCount=$(zgrep "$monthEnglish" /var/log/apache2/paste.chapril.org/paste.chapril.org-acces.log*|grep "$year"|grep -i bot|grep -c -v check)
|
||||
echo "Nombre de requêtes bot = $botRequestCount"
|
||||
|
||||
errorsRequestCount=$(zgrep "$monthEnglish" /var/log/apache2/paste.chapril.org/paste.chapril.org-error.log*|grep $year|wc -l)
|
||||
errorsRequestCount=$(zgrep "$monthEnglish" /var/log/apache2/paste.chapril.org/paste.chapril.org-error.log*|grep -c "$year")
|
||||
echo "Nombre de requêtes http en erreur = $errorsRequestCount"
|
||||
|
||||
createdPasteCount=$(grep "$yearMonth" /var/www/paste.chapril.org/paste.log | grep CREATE|wc -l)
|
||||
createdPasteCount=$(grep "$yearMonth" /var/www/paste.chapril.org/paste.log | grep -c CREATE)
|
||||
echo "Nombre de pastes créés ce mois = $createdPasteCount"
|
||||
|
||||
deletedPasteCount=$(grep "$yearMonth" /var/www/paste.chapril.org/paste.log | grep DELETE|wc -l)
|
||||
deletedPasteCount=$(grep "$yearMonth" /var/www/paste.chapril.org/paste.log | grep -c DELETE)
|
||||
echo "Nombre de pastes supprimés ce mois = $deletedPasteCount"
|
||||
|
||||
commentCount=$(grep "$yearMonth" /var/www/paste.chapril.org/paste.log | grep COMMENT|wc -l)
|
||||
commentCount=$(grep "$yearMonth" /var/www/paste.chapril.org/paste.log | grep -c COMMENT)
|
||||
echo "Nombre de commentaires ce mois = $commentCount"
|
||||
|
||||
readPasteCount=$(grep "$yearMonth" /var/www/paste.chapril.org/paste.log | grep READ|wc -l)
|
||||
readPasteCount=$(grep "$yearMonth" /var/www/paste.chapril.org/paste.log | grep -c READ)
|
||||
echo "Nombre de lectures ce mois = $readPasteCount"
|
||||
|
||||
echo "Nombre de lectures ce mois - les commentaires = $(($readPasteCount-$commentCount))"
|
||||
echo "Nombre de lectures ce mois - les commentaires = $((readPasteCount-commentCount))"
|
||||
echo
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ echo
|
|||
if [ "$#" = 1 ] && [ "$1" = "-h" ]; then
|
||||
help
|
||||
elif [ "$#" = 1 ] && [ "$1" = "-p" ]; then
|
||||
if [ $(date +%m) -gt 1 ]; then
|
||||
if [ "$(date +%m)" -gt 1 ]; then
|
||||
precedingMonth="$(($(date +%m)-1))"
|
||||
year="$(date +%Y)"
|
||||
if [ $precedingMonth -lt 10 ]; then
|
||||
|
@ -78,37 +78,35 @@ elif [ "$#" = 1 ] && [ "$1" = "-p" ]; then
|
|||
else
|
||||
yearMonth="$year-$precedingMonth"
|
||||
fi
|
||||
else [ $(date +%m) -eq 1 ]
|
||||
else [ "$(date +%m)" -eq 1 ]
|
||||
precedingMonth=12
|
||||
year="$(($(date +%Y)-1))"
|
||||
fi
|
||||
mois="$year$precedingMonth"
|
||||
monthEnglish=$(LANG=en_EN.UTF-8;date -d $year-$precedingMonth-01 +%b)
|
||||
echo -e "Rapport d'activité du service paste.chapril.org du mois $monthEnglish $year"
|
||||
generateReport "$monthEnglish" "$year" "$yearMonth"
|
||||
elif [ "$#" -eq 2 ]; then
|
||||
if !(let "$1") 2>/dev/null; then
|
||||
if ! (let "$1") 2>/dev/null; then
|
||||
echo -e "Le mois doit être numérique."
|
||||
help
|
||||
elif ([ $1 -lt 1 ] || [ $1 -gt 12 ]); then
|
||||
elif ([ "$1" -lt 1 ] || [ "$1" -gt 12 ]); then
|
||||
echo -e "Numéro du mois non valable $1."
|
||||
help
|
||||
elif !(let "$2") 2>/dev/null; then
|
||||
elif ! (let "$2") 2>/dev/null; then
|
||||
echo -e "L'année doit être numérique."
|
||||
help
|
||||
elif [ $2 -lt 2018 ] || [ $2 -gt $(date +%Y) ]; then
|
||||
elif [ "$2" -lt 2018 ] || [ "$2" -gt "$(date +%Y)" ]; then
|
||||
echo -e "Année non valable $2."
|
||||
help
|
||||
elif [ $2 -le 2017 ] || [ $2 -ge $(($(date +%Y)+1)) ] ; then
|
||||
elif [ "$2" -le 2017 ] || [ "$2" -ge $(($(date +%Y)+1)) ] ; then
|
||||
echo -e "Pas de données pour ce mois."
|
||||
help
|
||||
else
|
||||
if [ $1 -lt 10 ]; then
|
||||
if [ "$1" -lt 10 ]; then
|
||||
yearMonth="$2-0$1"
|
||||
else
|
||||
yearMonth="$2-$1"
|
||||
fi
|
||||
month="$2$1"
|
||||
monthEnglish=$(LANG=en_EN.UTF-8;date -d "$2-$1-01" +%b)
|
||||
year="$2"
|
||||
echo -e "Rapport d'activité du service paste.chapril.org du mois $monthEnglish $2"
|
||||
|
@ -116,7 +114,6 @@ elif [ "$#" -eq 2 ]; then
|
|||
fi
|
||||
elif [ "$#" -eq 0 ]; then
|
||||
yearMonth="$(date +%Y-%m)"
|
||||
month="$(date +%Y%m)"
|
||||
monthEnglish=$(LANG=en_EN.UTF-8;date +%b)
|
||||
year="$(date +%Y)"
|
||||
echo -e "Rapport d'activité du service paste.chapril.org du mois $(date +%b) 20$(date +%y)"
|
||||
|
|
Loading…
Reference in New Issue