influxdb/canned/new_apps.sh

64 lines
1.2 KiB
Bash
Raw Normal View History

2016-10-11 00:34:05 +00:00
#!/bin/sh
measurement=
# Usage info
show_help() {
cat << EOF
Usage: ${0##*/} MEASUREMENT
Generate new layout for MEASUREMENT. File created will be named
2016-11-07 22:29:39 +00:00
MEASUREMENT.json with UUID being generated from the uuidgen command.
-h display this help and exit
EOF
}
while :; do
case $1 in
-h|-\?|--help) # Call a "show_help" function to display a synopsis, then exit.
show_help
exit
;;
*) # Default case: If no more options then break out of the loop.
measurement=$1
break
esac
shift
done
if [ -z "$measurement" ]; then
show_help
exit
fi
2016-11-03 18:03:26 +00:00
CELLID=$(uuidgen)
CELLID="$(tr [A-Z] [a-z] <<< "$CELLID")"
2016-10-11 00:34:05 +00:00
UUID=$(uuidgen)
UUID="$(tr [A-Z] [a-z] <<< "$UUID")"
APP_FILE="$measurement".json
echo Creating measurement file $APP_FILE
2016-10-11 00:34:05 +00:00
cat > $APP_FILE << EOF
{
"id": "$UUID",
"measurement": "$measurement",
2016-10-11 00:34:05 +00:00
"app": "User Facing Application Name",
"cells": [{
"x": 0,
"y": 0,
"w": 4,
"h": 4,
2016-11-03 18:03:26 +00:00
"i": "$CELLID",
"name": "User facing cell Name",
2016-10-11 00:34:05 +00:00
"queries": [{
"query": "select used_percent from disk",
"db": "telegraf",
2016-11-07 22:29:39 +00:00
"rp": "autogen",
"groupbys": [],
"wheres": []
2016-10-11 00:34:05 +00:00
}]
}]
}
EOF