Skip to content

Instantly share code, notes, and snippets.

@cransom
Created September 17, 2016 16:25
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 cransom/9772c0dd791aee06fb99907473e6f1f2 to your computer and use it in GitHub Desktop.
Save cransom/9772c0dd791aee06fb99907473e6f1f2 to your computer and use it in GitHub Desktop.
#!/usr/bin/env nix-shell
#!nix-shell -p fping -i bash
while true; do
arp -an | grep -v incomplete | cut -f2 -d" "| egrep -o '[0-9]+.[0-9]+.[0-9]+.[0-9]+' | sudo fping -C 30 -D -n -r 0 | tr -d '[]()' | awk '{ print $1, $2, $7 }' |
while read -e line; do
ts=$(echo $line | awk '{ print $1 }' | tr -d '.')000
host=$(echo $line | awk '{ print $2 }' | tr . _ )
ms=$(echo $line | awk '{ print $3 }' )
curl -X POST 'http://ogre.mad.hubns.net:8086/write?db=mad' \
--data-binary "latency,hostname=$(hostname),pingtarget=$host value=$ms $ts"
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment