From bd8e9229c33b50e3385400651e3e80a74adf546c Mon Sep 17 00:00:00 2001 From: alyssadev Date: Tue, 19 Sep 2023 12:14:26 +1000 Subject: [PATCH] much better version of check-worker [skip ci] --- tools/check-worker | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/tools/check-worker b/tools/check-worker index 15c86ff..9ed8d39 100755 --- a/tools/check-worker +++ b/tools/check-worker @@ -18,21 +18,15 @@ read -r -d '' SQL <<- EOF asn != '8075' ORDER BY timestamp EOF -# yeah i know this looks dumb but isn't it easy to understand? read -r -d '' JQ <<- EOF -["ret","verb","xw","asn","timezone ","datetime ","referer"], -["---","----","--","---","-------- ","-------- ","-------"], -( - .data[] | - [ - if .status_code == "" then "200" else .status_code end, - .method, - .country, - .asn, - .timezone, - .timestamp, - .referer - ] -) | @tsv +.data[] | [ + if .status_code == "" then "200" else .status_code end, + .method, + .country, + .asn, + .timezone, + .timestamp, + .ip, + .referer ] | @tsv EOF -curl -X POST "https://api.cloudflare.com/client/v4/accounts/$CF_ACCOUNT_ID/analytics_engine/sql" -H "Authorization: Bearer $CF_API_TOKEN" -d "$SQL" 2>/dev/null | jq "$JQ" -r | grep -v '2023-09-18T05:20' +curl -X POST "https://api.cloudflare.com/client/v4/accounts/$CF_ACCOUNT_ID/analytics_engine/sql" -H "Authorization: Bearer $CF_API_TOKEN" -d "$SQL" 2>/dev/null | jq "$JQ" -r | grep -v '2023-09-18T05:20' | column -tN "ret,verb,xw,asn,tz,ts,ip,ref"