From 7e27bbb6966a3ffd2e93b86afbb2a0e555506b6e Mon Sep 17 00:00:00 2001 From: Rasha Malek Date: Tue, 10 Oct 2017 22:14:40 +0200 Subject: [PATCH 1/2] update git-audit log path --- updater/scripts/git-download.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/updater/scripts/git-download.sh b/updater/scripts/git-download.sh index a3a6da2a..0d0b46be 100644 --- a/updater/scripts/git-download.sh +++ b/updater/scripts/git-download.sh @@ -4,7 +4,7 @@ # echo -e "repository\tuser\tcloning?\trequests/day\tdownload/day [B]" -zcat -f /var/log/github/audit.log.1* | +zcat -f /var/log/github-audit.log.1* | perl -ne 'print if s/.*"program":"upload-pack".*"repo_name":"([^"]+).*"user_login":"([^"]+).*"cloning":([^,]+).*"uploaded_bytes":([^ ]+).*/\1\t\2\t\3\t\4/' | sort | perl -ne '$S{$1} += $2 and $C{$1} += 1 if (/^(.+)\t(\d+)$/);END{printf("%s\t%i\t%i\n",$_,$C{$_},$S{$_}) for ( keys %S );}' | From c5053fc07efbaf79bf1cdad384b547989eb58c1a Mon Sep 17 00:00:00 2001 From: Lars Schneider Date: Fri, 13 Oct 2017 07:52:34 -0700 Subject: [PATCH 2/2] add support for GHE 2.11 audit log location In GHE 2.11 the audit log location was changed. Check the GHE version to support pre 2.11 log location and the new log location --- updater/scripts/git-download.sh | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/updater/scripts/git-download.sh b/updater/scripts/git-download.sh index 0d0b46be..1c3ab125 100644 --- a/updater/scripts/git-download.sh +++ b/updater/scripts/git-download.sh @@ -2,9 +2,26 @@ # # Calculate download traffic per day # + +function ghe_greater_equal () { + cat /etc/github/enterprise-release | + perl -sne ' + use version; + my ($installed) = $_ =~ /RELEASE_VERSION="([0-9]+([.][0-9]+)+)"/; + exit (version->parse($installed) ge version->parse($required)); + ' -- -required="$1" + return $? +} + +if ghe_greater_equal "2.11" ; then + LOG_FILE="/var/log/github-audit.log" +else + LOG_FILE="/var/log/github/audit.log" +fi + echo -e "repository\tuser\tcloning?\trequests/day\tdownload/day [B]" -zcat -f /var/log/github-audit.log.1* | +zcat -f $LOG_FILE.1* | perl -ne 'print if s/.*"program":"upload-pack".*"repo_name":"([^"]+).*"user_login":"([^"]+).*"cloning":([^,]+).*"uploaded_bytes":([^ ]+).*/\1\t\2\t\3\t\4/' | sort | perl -ne '$S{$1} += $2 and $C{$1} += 1 if (/^(.+)\t(\d+)$/);END{printf("%s\t%i\t%i\n",$_,$C{$_},$S{$_}) for ( keys %S );}' |