Created
April 11, 2019 17:54
-
-
Save krisclarkdev/f1a6df6bb0b3e38bc2f1d85f2934aa10 to your computer and use it in GitHub Desktop.
Sends a metric to Wavefront proxy from terminal
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
#!/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