Merge branch 'master' of github.com:pstadler/metrics.sh

This commit is contained in:
Patrick Stadler 2015-11-17 00:32:34 +01:00
commit b21a7c1269
2 changed files with 6 additions and 14 deletions

View File

@ -15,7 +15,7 @@ esac)
is_solaris () { [ $OS_TYPE = 'solaris' ]; }
is_osx () { [ $OS_TYPE = 'osx' ]; }
is_linux () { [ $OS_TYPE = 'solaris' ]; }
is_linux () { [ $OS_TYPE = 'linux' ]; }
is_bsd () { [ $OS_TYPE = 'bsd']; }
is_unknown () { [ $OS_TYPE = 'unknown' ]; }
@ -28,4 +28,4 @@ else
make_temp_dir () {
mktemp -d
}
fi
fi

View File

@ -13,10 +13,7 @@ start () {
fi
if [ "$INFLUXDB_SEND_HOSTNAME" = true ]; then
__influxdb_columns="[\"value\",\"host\"]"
__influxdb_hostname=$(hostname)
else
__influxdb_columns="[\"value\"]"
__influxdb_hostname="host=$(hostname)"
fi
}
@ -24,17 +21,12 @@ report () {
local metric=$1
local value=$2
local points
if [ "$INFLUXDB_SEND_HOSTNAME" = true ]; then
points="[$value,\"$__influxdb_hostname\"]"
else
points="[$value]"
fi
local data="[{\"name\":\"$metric\",\"columns\":$__influxdb_columns,\"points\":[$points]}]"
curl -s -X POST $INFLUXDB_API_ENDPOINT -d $data
local data="$metric,$__influxdb_hostname value=$value"
curl -s -X POST $INFLUXDB_API_ENDPOINT --data-binary "$data"
}
docs () {
echo "Send data to InfluxDB."
echo "INFLUXDB_API_ENDPOINT=$INFLUXDB_API_ENDPOINT"
echo "INFLUXDB_SEND_HOSTNAME=$INFLUXDB_SEND_HOSTNAME"
}
}