Skip to content

Instantly share code, notes, and snippets.

@krisclarkdev
Created April 11, 2019 17:54
Show Gist options
  • Save krisclarkdev/f1a6df6bb0b3e38bc2f1d85f2934aa10 to your computer and use it in GitHub Desktop.
Save krisclarkdev/f1a6df6bb0b3e38bc2f1d85f2934aa10 to your computer and use it in GitHub Desktop.

Revisions

  1. Kristopher Clark created this gist Apr 11, 2019.
    47 changes: 47 additions & 0 deletions sendMetric.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,47 @@
    #!/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