Skip to content

Instantly share code, notes, and snippets.

@olix0r
Last active May 8, 2018 02:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save olix0r/3b4c131183255fb1de4564c899275d05 to your computer and use it in GitHub Desktop.
Save olix0r/3b4c131183255fb1de4564c899275d05 to your computer and use it in GitHub Desktop.
#!/bin/sh
set -eu
DEFAULT_URL="http://localhost:4191/metrics"
DEFAULT_CURL="curl"
curl="${CURL:-$DEFAULT_CURL}"
url="${1:-$DEFAULT_URL}"
while true ; do
out="$($curl -s "$url" |sed -Ee '/^#/d' -e 's/} [0-9]+/\}/' |sort)"
lines=$(echo "$out" |wc -l)
sha=$(echo "$out" |shasum -a 256 |awk '{print $1}' |sed -E 's/(.{8}).*/\1/')
file="${sha}.debug"
if [ ! -f "$file" ]; then
echo "* $lines\t$sha"
echo "$out" >$file ;
else
echo " $lines\t$sha"
sleep 1
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment