influxdb/chronograf/canned/new_apps.sh

59 lines
1.1 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-11 16:37:14 +00:00
CELLID=$(uuidgen | tr A-Z a-z)
UUID=$(uuidgen | tr A-Z a-z)
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",
"app": "$measurement",
"cells": [{
"x": 0,
"y": 0,
"w": 4,
"h": 4,
"i": "$CELLID",
"name": "User facing cell Name",
"queries": [{
2017-01-27 17:31:02 +00:00
"query": "select mean(\"used_percent\") from disk",
"groupbys": [],
"wheres": []
}]
}]
}
2016-10-11 00:34:05 +00:00
EOF