From 3bf0e0c132e3f145c4043f0c2c630ea99a9a4e90 Mon Sep 17 00:00:00 2001 From: Brian Long Date: Mon, 14 Oct 2024 10:59:56 -0400 Subject: [PATCH 1/2] Fix git-requests, api-requests, api-requests-by-user for GHES 3.11+ --- updater/scripts/api-requests-by-user.sh | 4 ++-- updater/scripts/api-requests.sh | 2 +- updater/scripts/git-requests.sh | 6 +++++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/updater/scripts/api-requests-by-user.sh b/updater/scripts/api-requests-by-user.sh index bf55a751..3b9f0044 100755 --- a/updater/scripts/api-requests-by-user.sh +++ b/updater/scripts/api-requests-by-user.sh @@ -7,9 +7,9 @@ echo -e "user\trequests" zcat -f /var/log/github/unicorn.log.1* | - grep -F 'request_category=api' | + grep -F 'request_category="api"' | grep -Fv 'remote_address=127.0.0.1' | - grep -oP 'current_user=\K\S+' | + grep -oP 'gh.actor.login=\K\S+' | grep -Fvx 'nil' | sort | uniq -ic | diff --git a/updater/scripts/api-requests.sh b/updater/scripts/api-requests.sh index 79b3caf5..74056c16 100755 --- a/updater/scripts/api-requests.sh +++ b/updater/scripts/api-requests.sh @@ -5,7 +5,7 @@ echo -e "resource\ttype\tsource IP\trequests" zcat -f /var/log/haproxy.log.1* | - perl -ne 'print if s/.*haproxy\[\d+\]: ([^:]+).*\/api\/v3\/([^\/\? ]+)\/([^\/\? ]+?(\/[^\/\? ]+)).*/\1 \2 \3/' | + perl -ne 'print if s/.*haproxy-frontend\[\d+\]: ([^:]+).*\/api\/v3\/([^\/\? ]+)\/([^\/\? ]+?(\/[^\/\? ]+)).*/\1 \2 \3/' | grep -v '^127.0.0.1' | sort | uniq -ic | diff --git a/updater/scripts/git-requests.sh b/updater/scripts/git-requests.sh index 1dd75757..b5d1ad41 100755 --- a/updater/scripts/git-requests.sh +++ b/updater/scripts/git-requests.sh @@ -4,7 +4,9 @@ # echo -e "repository\tsource IP\trequests" -zcat -f /var/log/syslog.1* | +TMPDIR=`mktemp -d` +sudo cp -a /var/log/babeld/babeld.log.1.gz $TMPDIR +zcat -f $TMPDIR/babeld.log.1.gz | # Remove the leading time stamp cut --characters 17- | # Remove the host name @@ -16,3 +18,5 @@ zcat -f /var/log/syslog.1* | uniq -ic | sort -rn | awk '{printf("%s\t%s\t%s\n",$3,$2,$1)}' +sudo rm -f $TMPDIR/babeld.log.1.gz +rmdir $TMPDIR From e620149fa9ab6c9b6c4fa1f3f3453abaea8ee8d9 Mon Sep 17 00:00:00 2001 From: Brian Long Date: Tue, 15 Oct 2024 10:28:14 -0400 Subject: [PATCH 2/2] Fix git-protocol.sh for GHES 3.11+ babel log parsing --- updater/scripts/git-protocol.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/updater/scripts/git-protocol.sh b/updater/scripts/git-protocol.sh index 54267a0e..ddabf942 100755 --- a/updater/scripts/git-protocol.sh +++ b/updater/scripts/git-protocol.sh @@ -4,7 +4,9 @@ # echo -e "Git protocol\tconnections" -zcat -f /var/log/syslog.1* | +TMPDIR=`mktemp -d` +sudo cp -a /var/log/babeld/babeld.log.1.gz $TMPDIR +zcat -f $TMPDIR/babeld.log.1.gz | # Remove the leading time stamp cut --characters 17- | # Remove the host name @@ -15,3 +17,5 @@ zcat -f /var/log/syslog.1* | sort | uniq -c | awk '{printf("%s\t%s\n",$2,$1)}' +sudo rm -f $TMPDIR/babeld.log.1.gz +rmdir $TMPDIR