From f4d464e2769ac89a2323d26a109a01e537683ca4 Mon Sep 17 00:00:00 2001 From: Patrick Stadler Date: Sat, 14 Mar 2015 14:46:17 +0100 Subject: [PATCH] add cli option for interval --- metrics.sh | 9 ++++++--- reporters/influxdb.sh | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/metrics.sh b/metrics.sh index 58e0ef0..5a2ce7d 100755 --- a/metrics.sh +++ b/metrics.sh @@ -1,7 +1,7 @@ #!/bin/sh # config -INTERVAL=1 +INTERVAL=5 REPORTER=stdout # TODO: handle multiple reporters # env @@ -10,12 +10,12 @@ LANG=en_US.UTF-8 LANGUAGE=en_US.UTF-8 # handle opts -opts_spec=":dhvr:" +opts_spec=":dhvri:" opt_docs=false opt_verbose=false usage () { - echo "usage: $0 [-d] [-h] [-v] [-r]" + echo "Usage: $0 [-d] [-h] [-v] [-r] [-i]" } help () { @@ -37,6 +37,9 @@ while getopts "$opts_spec" opt; do r) REPORTER=$OPTARG ;; + i) + INTERVAL=$OPTARG + ;; *) usage exit 1 diff --git a/reporters/influxdb.sh b/reporters/influxdb.sh index b7583ad..a14d0df 100644 --- a/reporters/influxdb.sh +++ b/reporters/influxdb.sh @@ -10,7 +10,8 @@ init () { report () { local METRIC=$1 local VALUE=$2 - curl -X POST -d "[{\"name\":\"$METRIC\",\"columns\":[\"value\"],\"points\":[[$VALUE]]}]" $INFLUXDB_API_ENDPOINT + curl -X POST $INFLUXDB_API_ENDPOINT \ + -d "[{\"name\":\"$METRIC\",\"columns\":[\"value\"],\"points\":[[$VALUE]]}]" } docs () {