add defaults() fn. add --print-config. config loader now fails on error

This commit is contained in:
Patrick Stadler
2015-03-21 21:19:08 +01:00
parent e0a528859f
commit b518c807d1
16 changed files with 232 additions and 125 deletions

View File

@@ -1,6 +1,6 @@
#!/bin/sh
init () {
start () {
if [ -z $FILE_LOCATION ]; then
echo "Error: file reporter requires \$FILE_LOCATION to be specified"
exit 1
@@ -20,5 +20,5 @@ report () {
docs () {
echo "Write to a file or named pipe."
echo "\$FILE_LOCATION="
echo "FILE_LOCATION=$FILE_LOCATION"
}

View File

@@ -1,15 +1,17 @@
#!/bin/sh
init () {
defaults () {
if [ -z $INFLUXDB_SEND_HOSTNAME ]; then
INFLUXDB_SEND_HOSTNAME=true
fi
}
start () {
if [ -z $INFLUXDB_API_ENDPOINT ]; then
echo "Error: influxdb requires \$INFLUXDB_API_ENDPOINT to be specified"
exit 1
fi
if [ -z $INFLUXDB_SEND_HOSTNAME ]; then
INFLUXDB_SEND_HOSTNAME=true
fi
if [ "$INFLUXDB_SEND_HOSTNAME" = true ]; then
__influxdb_columns="[\"value\",\"host\"]"
__influxdb_hostname=$(hostname)
@@ -34,6 +36,6 @@ report () {
docs () {
echo "Send data to InfluxDB."
echo "\$INFLUXDB_API_ENDPOINT="
echo "\$INFLUXDB_SEND_HOSTNAME=true"
echo "INFLUXDB_API_ENDPOINT=$INFLUXDB_API_ENDPOINT"
echo "INFLUXDB_SEND_HOSTNAME=$INFLUXDB_SEND_HOSTNAME"
}

View File

@@ -1,6 +1,12 @@
#!/bin/sh
init() {
defaults () {
if [ -z $KEEN_IO_EVENT_COLLECTION ]; then
KEEN_IO_EVENT_COLLECTION=$(hostname)
fi
}
start() {
if [ -z $KEEN_IO_PROJECT_ID ]; then
echo "Error: keen_io requires \$KEEN_IO_PROJECT_ID to be specified"
exit 1
@@ -11,10 +17,6 @@ init() {
exit 1
fi
if [ -z $KEEN_IO_EVENT_COLLECTION ]; then
KEEN_IO_EVENT_COLLECTION=$(hostname)
fi
__keen_io_api_url="https://api.keen.io/3.0"
__keen_io_api_url="$__keen_io_api_url/projects/$KEEN_IO_PROJECT_ID"
__keen_io_api_url="$__keen_io_api_url/events/$KEEN_IO_EVENT_COLLECTION"
@@ -31,7 +33,7 @@ report () {
docs () {
echo "Send data to Keen IO (https://keen.io)."
echo "\$KEEN_IO_WRITE_KEY=<write_key>"
echo "\$KEEN_IO_PROJECT_ID=<project_id>"
echo "\$KEEN_IO_EVENT_COLLECTION=$(hostname)"
echo "KEEN_IO_WRITE_KEY=$KEEN_IO_WRITE_KEY"
echo "KEEN_IO_PROJECT_ID=$KEEN_IO_PROJECT_ID"
echo "KEEN_IO_EVENT_COLLECTION=$KEEN_IO_EVENT_COLLECTION"
}

View File

@@ -1,6 +1,6 @@
#!/bin/sh
init () {
start () {
if [ -z $STATHAT_API_KEY ]; then
echo "Error: stathat requires \$STATHAT_API_KEY to be specified"
exit 1
@@ -17,5 +17,5 @@ report () {
docs () {
echo "Send data to StatHat (https://www.stathat.com)."
echo "\$STATHAT_API_KEY=<ez_key>"
echo "STATHAT_API_KEY=$STATHAT_API_KEY"
}

View File

@@ -8,5 +8,5 @@ report () {
}
docs () {
echo "Print to standard output (e.g. the TTY you're running the script in)"
echo "Print to standard output, e.g. the TTY you're running the script in."
}