Compare commits
6 Commits
0c75469fec
...
1499ed5612
Author | SHA1 | Date | |
---|---|---|---|
1499ed5612 | |||
302d2303c7 | |||
3e30a986bc | |||
9f6b588083 | |||
4c8d0de5ba | |||
f8c31523c9 |
@ -33,11 +33,13 @@ IPV6_PATTERN="[0-9a-f]{0,4}(:[0-9a-f]{0,4}){2,7}"
|
|||||||
#
|
#
|
||||||
help()
|
help()
|
||||||
{
|
{
|
||||||
|
local prog
|
||||||
|
prog=$(basename "$0")
|
||||||
echo "Usage:"
|
echo "Usage:"
|
||||||
echo " $(basename "$0") -h display help"
|
echo " $prog -h display help"
|
||||||
echo " $(basename "$0") analyse current month"
|
echo " $prog analyse current month"
|
||||||
echo " $(basename "$0") -p analyse preceding month"
|
echo " $prog -p analyse preceding month"
|
||||||
echo " $(basename "$0") month_number year analyse this month"
|
echo " $prog month_number year analyse this month"
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -50,22 +52,28 @@ generateHTTPReport()
|
|||||||
echo "=§= Rapport d'activité HTTP"
|
echo "=§= Rapport d'activité HTTP"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
local httpRequestCount=$(zgrep "$monthEnglish" $LOG_PREFIX-access.log*|grep $year|wc -l)
|
local httpRequestCount
|
||||||
|
httpRequestCount=$(zgrep "$monthEnglish" $LOG_PREFIX-access.log*|grep -c "$year")
|
||||||
echo "Nombre total de requêtes http = $httpRequestCount"
|
echo "Nombre total de requêtes http = $httpRequestCount"
|
||||||
|
|
||||||
local trueHttpRequestCount=$(zgrep "$monthEnglish" $LOG_PREFIX-access.log*|grep $year|grep -vi bot|grep -v check_http|wc -l)
|
local trueHttpRequestCount
|
||||||
|
trueHttpRequestCount=$(zgrep "$monthEnglish" $LOG_PREFIX-access.log*|grep "$year"|grep -vi bot|grep -c -v check_http)
|
||||||
echo "Nombre de vraies requêtes http = $trueHttpRequestCount"
|
echo "Nombre de vraies requêtes http = $trueHttpRequestCount"
|
||||||
|
|
||||||
local botRequestCount=$(zgrep "$monthEnglish" $LOG_PREFIX-access.log*|grep "$year"|grep -i bot|grep -c -v check_http)
|
local botRequestCount
|
||||||
|
botRequestCount=$(zgrep "$monthEnglish" $LOG_PREFIX-access.log*|grep "$year"|grep -i bot|grep -c -v check_http)
|
||||||
echo "Nombre de requêtes bot = $botRequestCount"
|
echo "Nombre de requêtes bot = $botRequestCount"
|
||||||
|
|
||||||
local errorRequestCount=$(zgrep "$monthEnglish" $LOG_PREFIX-error.log*|grep -c "$year")
|
local errorRequestCount
|
||||||
|
errorRequestCount=$(zgrep "$monthEnglish" "$LOG_PREFIX-error.log*"|grep -c "$year")
|
||||||
echo "Nombre de requêtes http en erreur = $errorRequestCount"
|
echo "Nombre de requêtes http en erreur = $errorRequestCount"
|
||||||
|
|
||||||
local ipv4VisitorCount=$(zgrep -h "$monthEnglish" $LOG_PREFIX-access.log*|grep "$year"|grep -vi bot|grep -v check_http|egrep "^$IPV4_PATTERN "|cut -d' ' -f1|sort|uniq|wc -l )
|
local ipv4VisitorCount
|
||||||
|
ipv4VisitorCount=$(zgrep -h "$monthEnglish" $LOG_PREFIX-access.log*|grep "$year"|grep -vi bot|grep -v check_http|grep -E "^$IPV4_PATTERN "|cut -d' ' -f1|sort|uniq|wc -l )
|
||||||
echo "Nombre d'ipv4 ayant visité le service = $ipv4VisitorCount"
|
echo "Nombre d'ipv4 ayant visité le service = $ipv4VisitorCount"
|
||||||
|
|
||||||
local ipv6VisitorCount=$(zgrep -h "$monthEnglish" $LOG_PREFIX-access.log*|grep "$year"|grep -vi bot|grep -v check_http|egrep "^$IPV6_PATTERN "|cut -d' ' -f1|sort|uniq|wc -l )
|
local ipv6VisitorCount
|
||||||
|
ipv6VisitorCount=$(zgrep -h "$monthEnglish" $LOG_PREFIX-access.log*|grep "$year"|grep -vi bot|grep -v check_http|grep -E "^$IPV6_PATTERN "|cut -d' ' -f1|sort|uniq|wc -l )
|
||||||
echo "Nombre d'ipv6 ayant visité le service = $ipv6VisitorCount"
|
echo "Nombre d'ipv6 ayant visité le service = $ipv6VisitorCount"
|
||||||
|
|
||||||
echo "Nombre total d'ip ayant visité le service = $((ipv4VisitorCount+ipv6VisitorCount))"
|
echo "Nombre total d'ip ayant visité le service = $((ipv4VisitorCount+ipv6VisitorCount))"
|
||||||
@ -83,10 +91,10 @@ generateSpecificReport()
|
|||||||
echo "=§= Rapport d'activité spécifique"
|
echo "=§= Rapport d'activité spécifique"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
ipv4UserCount=$(zgrep -h "$monthEnglish" $LOG_PREFIX-access.log*|grep "$year"|grep -vi bot|grep -v check_http|egrep "^$IPV4_PATTERN " | cut -d' ' -f 1|sort|uniq|wc -l )
|
ipv4UserCount=$(zgrep -h "$monthEnglish" $LOG_PREFIX-access.log*|grep "$year"|grep -vi bot|grep -v check_http|grep -E "^$IPV4_PATTERN " | cut -d' ' -f 1|sort|uniq|wc -l )
|
||||||
echo "Nombre d'ipv4 utilisatrices du service = $ipv4UserCount"
|
echo "Nombre d'ipv4 utilisatrices du service = $ipv4UserCount"
|
||||||
|
|
||||||
ipv6UserCount=$(zgrep -h "$monthEnglish" $LOG_PREFIX-access.log*|grep "$year"|grep -vi bot|gre\p -v check_http|egrep "^$IPV6_PATTERN " | cut -d' ' -f 1|sort|uniq|wc -l )
|
ipv6UserCount=$(zgrep -h "$monthEnglish" $LOG_PREFIX-access.log*|grep "$year"|grep -vi bot|grep -v check_http|grep -E "^$IPV6_PATTERN " | cut -d' ' -f 1|sort|uniq|wc -l )
|
||||||
echo "Nombre d'ipv6 utilisatrices du service = $ipv6UserCount"
|
echo "Nombre d'ipv6 utilisatrices du service = $ipv6UserCount"
|
||||||
|
|
||||||
echo "Nombre total d'ip utilisatrices du service = $((ipv4UserCount+ipv6UserCount))"
|
echo "Nombre total d'ip utilisatrices du service = $((ipv4UserCount+ipv6UserCount))"
|
||||||
@ -95,45 +103,56 @@ generateSpecificReport()
|
|||||||
# https://forge.chapril.org/api/swagger
|
# https://forge.chapril.org/api/swagger
|
||||||
#$(curl -s --dump-header - "https://forge.chapril.org/api/v1/admin/orgs?limit=1&page1&token=$GITEA_API_KEY" > t)
|
#$(curl -s --dump-header - "https://forge.chapril.org/api/v1/admin/orgs?limit=1&page1&token=$GITEA_API_KEY" > t)
|
||||||
#$(curl -s "https://forge.chapril.org/api/v1/users/search?limit=1&token=$GITEA_API_KEY" | jq '. | length' > t)
|
#$(curl -s "https://forge.chapril.org/api/v1/users/search?limit=1&token=$GITEA_API_KEY" | jq '. | length' > t)
|
||||||
local accountCount=$(curl -s "https://forge.chapril.org/api/v1/users/search?limit=100000&token=$GITEA_API_KEY" | jq '.data | length')
|
local accountCount
|
||||||
|
accountCount=$(curl -s "https://forge.chapril.org/api/v1/users/search?limit=100000&token=$GITEA_API_KEY" | jq '.data | length')
|
||||||
echo "Nombre de comptes = $accountCount"
|
echo "Nombre de comptes = $accountCount"
|
||||||
|
|
||||||
local connectedAccountCount=$(curl -s "https://forge.chapril.org/api/v1/users/search?limit=100000&token=$GITEA_API_KEY" | jq '.data[].last_login' | grep -cv "1970")
|
local connectedAccountCount
|
||||||
|
connectedAccountCount=$(curl -s "https://forge.chapril.org/api/v1/users/search?limit=100000&token=$GITEA_API_KEY" | jq '.data[].last_login' | grep -cv "1970")
|
||||||
echo "Nombre de comptes connectés au moins une fois = $connectedAccountCount"
|
echo "Nombre de comptes connectés au moins une fois = $connectedAccountCount"
|
||||||
|
|
||||||
local unconnectedAccountCount=$(curl -s "https://forge.chapril.org/api/v1/users/search?limit=100000&token=$GITEA_API_KEY" | jq '.data[].last_login' | grep -c "1970")
|
local unconnectedAccountCount
|
||||||
|
unconnectedAccountCount=$(curl -s "https://forge.chapril.org/api/v1/users/search?limit=100000&token=$GITEA_API_KEY" | jq '.data[].last_login' | grep -c "1970")
|
||||||
echo "Nombre de comptes jamais connectés = $unconnectedAccountCount"
|
echo "Nombre de comptes jamais connectés = $unconnectedAccountCount"
|
||||||
|
|
||||||
#$(curl -s "https://forge.chapril.org/api/v1/admin/orgs?limit=100000&token=$GITEA_API_KEY" | jq '. | length' > t)
|
#$(curl -s "https://forge.chapril.org/api/v1/admin/orgs?limit=100000&token=$GITEA_API_KEY" | jq '. | length' > t)
|
||||||
local organizationCount=$(curl -s "https://forge.chapril.org/api/v1/admin/orgs?limit=100000&token=$GITEA_API_KEY" | jq '. | length')
|
local organizationCount
|
||||||
|
organizationCount=$(curl -s "https://forge.chapril.org/api/v1/admin/orgs?limit=100000&token=$GITEA_API_KEY" | jq '. | length')
|
||||||
if [[ -z "$organizationCount" ]]; then
|
if [[ -z "$organizationCount" ]]; then
|
||||||
organizationCount=0
|
organizationCount=0
|
||||||
fi
|
fi
|
||||||
echo "Nombre d'organisations = $organizationCount"
|
echo "Nombre d'organisations = $organizationCount"
|
||||||
|
|
||||||
#$(curl -s "https://forge.chapril.org/api/v1/orgs?limit=100000" > t)
|
#$(curl -s "https://forge.chapril.org/api/v1/orgs?limit=100000" > t)
|
||||||
local publicOrganizationCount=$(curl -s "https://forge.chapril.org/api/v1/orgs?limit=100000" | jq '. | length')
|
local publicOrganizationCount
|
||||||
|
publicOrganizationCount=$(curl -s "https://forge.chapril.org/api/v1/orgs?limit=100000" | jq '. | length')
|
||||||
if [[ -z "$publicOrganizationCount" ]]; then
|
if [[ -z "$publicOrganizationCount" ]]; then
|
||||||
publicOrganizationCount=0
|
publicOrganizationCount=0
|
||||||
fi
|
fi
|
||||||
echo "Nombre d'organisations publiques = $publicOrganizationCount"
|
echo "Nombre d'organisations publiques = $publicOrganizationCount"
|
||||||
|
|
||||||
local repositoryCount=$(curl -s --dump-header - "https://forge.chapril.org/api/v1/repos/search?limit=1&token=$GITEA_API_KEY" | grep "X-Total-Count\:" | awk '{ print $2 }' | jq '.')
|
local repositoryCount
|
||||||
|
repositoryCount=$(curl -s --dump-header - "https://forge.chapril.org/api/v1/repos/search?limit=1&token=$GITEA_API_KEY" | grep "X-Total-Count\:" | awk '{ print $2 }' | jq '.')
|
||||||
echo "Nombre de dépôts = $repositoryCount"
|
echo "Nombre de dépôts = $repositoryCount"
|
||||||
|
|
||||||
local publicRepositoryCount=$(curl -s --dump-header - "https://forge.chapril.org/api/v1/repos/search?limit=1" | grep "X-Total-Count\:" | awk '{ print $2 }' | jq '.')
|
local publicRepositoryCount
|
||||||
|
publicRepositoryCount=$(curl -s --dump-header - "https://forge.chapril.org/api/v1/repos/search?limit=1" | grep "X-Total-Count\:" | awk '{ print $2 }' | jq '.')
|
||||||
echo "Nombre de dépôts publics = $publicRepositoryCount"
|
echo "Nombre de dépôts publics = $publicRepositoryCount"
|
||||||
|
|
||||||
local repositorySpaceDisk=$(du -sh "$GITEA_REPO_HOME" | head -1 | awk '{ print $1 } ')
|
local repositorySpaceDisk
|
||||||
|
repositorySpaceDisk=$(du -sh "$GITEA_REPO_HOME" | head -1 | awk '{ print $1 } ')
|
||||||
echo "Espace disque occupé par les dépôts = $repositorySpaceDisk"
|
echo "Espace disque occupé par les dépôts = $repositorySpaceDisk"
|
||||||
|
|
||||||
local directoryCount=$(find "$GITEA_REPO_HOME" -type d | wc -l )
|
local directoryCount
|
||||||
|
directoryCount=$(find "$GITEA_REPO_HOME" -type d | wc -l )
|
||||||
echo "Nombre de dossiers de l'espace disque = $directoryCount"
|
echo "Nombre de dossiers de l'espace disque = $directoryCount"
|
||||||
|
|
||||||
local fileCount=$(find "$GITEA_REPO_HOME" -type f | wc -l )
|
local fileCount
|
||||||
|
fileCount=$(find "$GITEA_REPO_HOME" -type f | wc -l )
|
||||||
echo "Nombre de fichiers de l'espace disque = $fileCount"
|
echo "Nombre de fichiers de l'espace disque = $fileCount"
|
||||||
|
|
||||||
local totalFileCount=$(find "$GITEA_REPO_HOME" | wc -l )
|
local totalFileCount
|
||||||
|
totalFileCount=$(find "$GITEA_REPO_HOME" | wc -l )
|
||||||
echo "Nombre total de fichiers de l'espace disque = $totalFileCount"
|
echo "Nombre total de fichiers de l'espace disque = $totalFileCount"
|
||||||
|
|
||||||
echo
|
echo
|
||||||
@ -169,13 +188,13 @@ elif [ "$#" = 1 ] && [ "$1" = "-p" ]; then
|
|||||||
year="$(($(date +%Y)-1))"
|
year="$(($(date +%Y)-1))"
|
||||||
yearMonth="$year-$precedingMonth"
|
yearMonth="$year-$precedingMonth"
|
||||||
fi
|
fi
|
||||||
monthEnglish=$(LANG=en_EN.UTF-8;date -d $year-$precedingMonth-01 +%b)
|
monthEnglish=$(LANG=en_EN.UTF-8;date -d "$year-$precedingMonth-01" +%b)
|
||||||
generateReport "$monthEnglish" "$year" "$yearMonth"
|
generateReport "$monthEnglish" "$year" "$yearMonth"
|
||||||
elif [ "$#" -eq 2 ]; then
|
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."
|
echo -e "Le mois doit être numérique."
|
||||||
help
|
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."
|
echo -e "Numéro du mois non valable $1."
|
||||||
help
|
help
|
||||||
elif ! (let "$2") 2>/dev/null; then
|
elif ! (let "$2") 2>/dev/null; then
|
||||||
|
Loading…
Reference in New Issue
Block a user