Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

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 gangsta/eeda404448485bf77d88efaa513ba006 to your computer and use it in GitHub Desktop.
Save gangsta/eeda404448485bf77d88efaa513ba006 to your computer and use it in GitHub Desktop.
Bash Script to Fetching Node_Exporter Data Size and Time for Consuming Metrics
#!/usr/bin/env bash
set -e
bytesToHuman() {
b=${1:-0}; d=''; s=0; S=(Bytes {K,M,G,T,E,P,Y,Z}iB)
while ((b > 1024)); do
d="$(printf ".%02d" $((b % 1024 * 100 / 1024)))"
b=$((b / 1024))
let s++
done
echo "$b$d ${S[$s]}"
}
compare() {
echo "Target: ${1}"
SIZE=$(time curl -so /dev/null "${1}" -w '%{size_download}')
SIZE_HUMAN=$(bytesToHuman "$SIZE")
echo "Uncompressed size : $SIZE_HUMAN"
SIZE=$(curl --compressed -so /dev/null "${1}" -w '%{size_download}')
SIZE_HUMAN=$(bytesToHuman "$SIZE")
echo "Compressed size : $SIZE_HUMAN"
}
compare http://myserver.domain.com:9100/metrics
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment