2015-03-12 15:59:09 -04:00
|
|
|
#!/bin/sh
|
|
|
|
|
2015-03-21 16:19:08 -04:00
|
|
|
defaults () {
|
|
|
|
if [ -z $KEEN_IO_EVENT_COLLECTION ]; then
|
|
|
|
KEEN_IO_EVENT_COLLECTION=$(hostname)
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
start() {
|
2015-03-12 15:59:09 -04:00
|
|
|
if [ -z $KEEN_IO_PROJECT_ID ]; then
|
2015-03-14 16:44:06 -04:00
|
|
|
echo "Error: keen_io requires \$KEEN_IO_PROJECT_ID to be specified"
|
2015-03-22 13:01:27 -04:00
|
|
|
return 1
|
2015-03-12 15:59:09 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z $KEEN_IO_WRITE_KEY ]; then
|
2015-03-14 16:44:06 -04:00
|
|
|
echo "Error: keen_io requires \$KEEN_IO_WRITE_KEY to be specified"
|
2015-03-22 13:01:27 -04:00
|
|
|
return 1
|
2015-03-12 15:59:09 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
__keen_io_api_url="https://api.keen.io/3.0"
|
2015-03-15 12:18:27 -04:00
|
|
|
__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"
|
|
|
|
__keen_io_api_url="$__keen_io_api_url?api_key=$KEEN_IO_WRITE_KEY"
|
2015-03-12 15:59:09 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
report () {
|
2015-03-14 16:44:06 -04:00
|
|
|
local metric=$1
|
|
|
|
local value=$2
|
|
|
|
|
2015-03-12 15:59:09 -04:00
|
|
|
curl -s $__keen_io_api_url -H "Content-Type: application/json" \
|
2015-03-22 13:01:27 -04:00
|
|
|
-d "{\"metric\":\"$metric\",\"value\":$value}"
|
2015-03-12 15:59:09 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
docs () {
|
|
|
|
echo "Send data to Keen IO (https://keen.io)."
|
2015-03-21 16:19:08 -04:00
|
|
|
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"
|
2015-03-12 15:59:09 -04:00
|
|
|
}
|