Skip to content

Commit

Permalink
Fix scan stats script for macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
ghostwords committed Sep 12, 2024
1 parent 5cc2689 commit ec58061
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion stats.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
#!/usr/bin/env bash

if date --version >/dev/null 2>&1; then
DATE_TO_EPOCH() {
read -r datestr
date +%s -d "$datestr" # GNU
}
else
DATE_TO_EPOCH() {
read -r datestr
date -j -f "%Y-%m-%d %T" "+%s" "$datestr" # BSD
}
fi

tmp_dir=$(mktemp -d "${TMPDIR:-/tmp}/badger_sett_stats.XXXXXXXXX")
trap 'rm -rf "$tmp_dir"' EXIT

Expand All @@ -18,6 +30,6 @@ for rev in $(git rev-list HEAD -- log.txt); do
"$(grep 'errored on' "$log_txt" | rev | cut -d ' ' -f -2 | rev | cut -d ' ' -f 2- | sed 's/[()]//g')" \
" ($(echo "$(grep -c 'Timed out loading ' "$log_txt") * 100 / $num_domains" | bc -l | xargs printf "%.1f")%, $(echo "$(grep -c 'security page' "$log_txt") * 100 / $num_domains" | bc -l | xargs printf "%.1f")%)" \
"$(grep -c 'restarted' "$log_txt")" \
"$((($(grep 'Finished scan' "$log_txt" | cut -d " " -f "1,2" | xargs -0 date +%s -d) - $(head -n1 "$log_txt" | cut -d " " -f "1,2" | xargs -0 date +%s -d)) / 3600)) hours" \
"$((($(grep 'Finished scan' "$log_txt" | cut -d " " -f "1,2" | cut -d "," -f 1 | tr -d "\n" | DATE_TO_EPOCH) - $(head -n1 "$log_txt" | cut -d " " -f "1,2" | cut -d "," -f 1 | tr -d "\n" | DATE_TO_EPOCH)) / 3600)) hours" \
"$(git show -s --format="%h %ci" "$rev")"
done

0 comments on commit ec58061

Please sign in to comment.