Skip to content

Commit

Permalink
add support for GHE 2.11 audit log location (#11)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
larsxschneider authored Oct 15, 2017
1 parent 205aa11 commit 1e26b94
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion updater/scripts/git-download.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 );}' |
Expand Down

0 comments on commit 1e26b94

Please sign in to comment.