@@ -185,7 +185,11 @@ function dbmon_create {
185185}
186186register dbmon_create Create a new database collector
187187function timerange_create {
188- while getopts " s:e:" opt " $@ " ;
188+ local START_TIME=-1
189+ local END_TIME=-1
190+ local DURATION_IN_MINUTES=0
191+ local TYPE=BETWEEN_TIMES
192+ while getopts " s:e:b:" opt " $@ " ;
189193 do
190194 case " ${opt} " in
191195 s)
@@ -194,14 +198,32 @@ function timerange_create {
194198 e)
195199 END_TIME=${OPTARG}
196200 ;;
201+ b)
202+ DURATION_IN_MINUTES=${OPTARG}
203+ TYPE=" BEFORE_NOW"
204+ ;;
197205 esac
198206 done ;
199207 shiftOptInd
200208 shift $SHIFTS
201209 TIMERANGE_NAME=$@
202- controller_call -X POST -d " {\" name\" :\" $TIMERANGE_NAME \" ,\" timeRange\" :{\" type\" :\" BETWEEN_TIMES \" ,\" durationInMinutes\" :0 ,\" startTime\" :$START_TIME ,\" endTime\" :$END_TIME }}" /controller/restui/user/createCustomRange
210+ controller_call -X POST -d " {\" name\" :\" $TIMERANGE_NAME \" ,\" timeRange\" :{\" type\" :\" $TYPE \" ,\" durationInMinutes\" :$DURATION_IN_MINUTES ,\" startTime\" :$START_TIME ,\" endTime\" :$END_TIME }}" /controller/restui/user/createCustomRange
203211}
204212register timerange_create Create a custom time range
213+ function timerange_list {
214+ controller_call -X GET /controller/restui/user/getAllCustomTimeRanges
215+ }
216+ register timerange_list List all custom timeranges available on the controller
217+ function timerange_delete {
218+ local TIMERANGE_ID=$@
219+ if [[ $TIMERANGE_ID =~ ^[0-9]+$ ]]; then
220+ controller_call -X POST -d " $TIMERANGE_ID " /controller/restui/user/deleteCustomRange
221+ else
222+ COMMAND_RESULT=" "
223+ error " This is not a number: '$TIMERANGE_ID '"
224+ fi
225+ }
226+ register timerange_delete Delete a specific time range by id
205227function dashboard_list {
206228 controller_call -X GET /controller/restui/dashboards/getAllDashboardsByType/false
207229}
0 commit comments