Last active
April 10, 2019 15:21
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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