@@ -57,6 +57,7 @@ function output {
5757 fi
5858}
5959function httpClient {
60+ debug " $* "
6061 curl -L --connect-timeout 10 " $@ "
6162}
6263SHIFTS=0
243244function controller_call {
244245 debug " Calling $CONFIG_CONTROLLER_HOST "
245246 local METHOD=" GET"
246- while getopts " X:d:" opt " $@ " ;
247+ local FORM=" "
248+ while getopts " X:d:F:" opt " $@ " ;
247249 do
248250 case " ${opt} " in
249251 X)
@@ -252,6 +254,9 @@ function controller_call {
252254 d)
253255 PAYLOAD=${OPTARG}
254256 ;;
257+ F)
258+ FORM=${OPTARG}
259+ ;;
255260 esac
256261 done
257262 shiftOptInd
@@ -264,9 +269,10 @@ function controller_call {
264269 COMMAND_RESULT=$( httpClient -s -b $CONFIG_CONTROLLER_COOKIE_LOCATION \
265270 -X $METHOD \
266271 -H " X-CSRF-TOKEN: $XCSRFTOKEN " \
267- - H " Content-Type: application/json;charset=UTF-8" \
272+ " ` [ -z " $FORM " ] && echo - H " Content-Type: application/json;charset=UTF-8" ` " \
268273 -H " Accept: application/json, text/plain, */*" \
269- -d " $PAYLOAD " \
274+ " ` [ -n " $PAYLOAD " ] && echo -d ${PAYLOAD} ` " \
275+ " ` [ -n " $FORM " ] && echo -F ${FORM} ` " \
270276 $CONFIG_CONTROLLER_HOST$ENDPOINT )
271277 else
272278 COMMAND_RESULT=" Controller Login Error! Please check hostname and credentials"
@@ -424,6 +430,19 @@ register application_list List all applications available on the controller
424430describe application_list << EOF
425431List all applications available on the controller. This command requires no further arguments.
426432EOF
433+ function application_export {
434+ local APPLICATION_ID=$*
435+ if [[ $APPLICATION_ID =~ ^[0-9]+$ ]]; then
436+ controller_call /controller/ConfigObjectImportExportServlet? applicationId=97
437+ else
438+ COMMAND_RESULT=" "
439+ error " This is not a number: '$APPLICATION_ID '"
440+ fi
441+ }
442+ register application_export Export an application from the controller
443+ describe application_export << EOF
444+ Export a application from the controller. Specifiy the application id as parameter.
445+ EOF
427446function metric_list {
428447 local APPLICATION=${CONFIG_CONTROLLER_DEFAULT_APPLICATION}
429448 local METRIC_PATH=" "
@@ -600,6 +619,26 @@ register dbmon_create Create a new database collector
600619describe dbmon_create << EOF
601620Create a new database collector
602621EOF
622+ function dbmon_list {
623+ controller_call /controller/restui/databases/collectors/
624+ }
625+ register dbmon_list List all database collectors
626+ describe dbmon_list << EOF
627+ List all database collectors
628+ EOF
629+ function dbmon_delete {
630+ local COLLECTOR_ID=$*
631+ if [[ $COLLECTOR_ID =~ ^[0-9]+$ ]]; then
632+ controller_call -X POST -d " [$COLLECTOR_ID ]" /controller/restui/databases/collectors/configuration/batchDelete
633+ else
634+ COMMAND_RESULT=" "
635+ error " This is not a number: '$COLLECTOR_ID '"
636+ fi
637+ }
638+ register dbmon_delete Delete a database collector
639+ describe dbmon_delete << EOF
640+ Delete a database collector. Provide the collector id as parameter.
641+ EOF
603642function event_create {
604643 local APPLICATION=${CONFIG_CONTROLLER_DEFAULT_APPLICATION}
605644 local NODE
@@ -713,6 +752,19 @@ register dashboard_export Export a specific dashboard
713752describe dashboard_export << EOF
714753Export a specific dashboard
715754EOF
755+ function dashboard_import {
756+ FILE=" $* "
757+ if [ -r $FILE ] ; then
758+ controller_call -X POST -F file=@$FILE /controller/CustomDashboardImportExportServlet
759+ else
760+ COMMAND_RESULT=" "
761+ error " File not found or not readable: $FILE "
762+ fi
763+ }
764+ register dashboard_import Import a dashboard
765+ describe dashboard_import << EOF
766+ Import a dashboard from a given file
767+ EOF
716768function dashboard_delete {
717769 local DASHBOARD_ID=$*
718770 if [[ $DASHBOARD_ID =~ ^[0-9]+$ ]]; then
0 commit comments