Skip to content

Instantly share code, notes, and snippets.

@krisclarkdev
Created April 11, 2019 17:54
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 krisclarkdev/f1a6df6bb0b3e38bc2f1d85f2934aa10 to your computer and use it in GitHub Desktop.
Save krisclarkdev/f1a6df6bb0b3e38bc2f1d85f2934aa10 to your computer and use it in GitHub Desktop.
Sends a metric to Wavefront proxy from terminal
#!/bin/bash
while test $# -gt 0; do
case "$1" in
-h|--help)
echo "sendMetric.sh - send a single metric to Wavefront proxy"
echo " "
echo "sendMetric.sh [arguments]"
echo " "
echo "arguments:"
echo "-n specify the hostname/ip of the Wavefront proxy"
echo "-p specify the port of the Wavefront proxy"
echo "-m specify the metric to send e.g. system.cpu.loadavg.1m 0.03 1382754475 source=test1.wavefront.com"
exit 0
;;
-p)
shift
if test $# -gt 0; then
PORT=$1
else
echo "no port specified"
exit 1
fi
shift
;;
-n)
shift
if test $# -gt 0; then
HOSTNAME=$1
else
echo "no output dir specified"
exit 1
fi
shift
;;
-m*)
export METRIC=`echo $1 | sed -e 's/^[^=]*=//g'`
shift
;;
*)
break
;;
esac
done
echo -e "$METRIC\n" | nc $HOSTNAME $PORT -q 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment