@@ -120,14 +120,14 @@ function apiCall {
120120 OLDIFS=$IFS
121121 IFS=" \$ "
122122 for MATCH in $PAYLOAD ; do
123- if [ " ${MATCH:: 1} " = " {" ] ; then
123+ if [ " ${MATCH:: 1} " = " {" ] && [ " ${MATCH : 2 : 1} " = " } " ] ; then
124124 MATCH=${MATCH: 1}
125125 OPT=${MATCH%% \} * } :
126126 OPTS=" ${OPTS}${OPT} "
127127 fi
128128 done ;
129129 for MATCH in $ENDPOINT ; do
130- if [ " ${MATCH:: 1} " = " {" ] ; then
130+ if [ " ${MATCH:: 1} " = " {" ] && [ " ${MATCH : 2 : 1} " = " } " ] ; then
131131 MATCH=${MATCH: 1}
132132 OPT=${MATCH%% \} * } :
133133 OPTS=" ${OPTS}${OPT} "
@@ -143,6 +143,14 @@ function apiCall {
143143 shiftOptInd
144144 shift $SHIFTS
145145 fi
146+ while [[ $PAYLOAD =~ \$ {[^}]* } ]] ; do
147+ if [ -z " $1 " ] ; then
148+ error " Please provide an argument for paramater -${BASH_REMATCH: 2: 1} "
149+ return ;
150+ fi
151+ PAYLOAD=${PAYLOAD// ${BASH_REMATCH[0]} / $1 }
152+ shift
153+ done
146154 while [[ $ENDPOINT =~ \$ {[^}]* } ]] ; do
147155 if [ -z " $1 " ] ; then
148156 error " Please provide an argument for paramater -${BASH_REMATCH: 2: 1} "
@@ -153,9 +161,9 @@ function apiCall {
153161 done
154162 debug " Call Controller: -X $METHOD -d $PAYLOAD $ENDPOINT "
155163 if [ -n " $PAYLOAD " ] ; then
156- controller_call -X $METHOD -d $PAYLOAD $ENDPOINT
164+ echo -X $METHOD -d $PAYLOAD $ENDPOINT
157165 else
158- controller_call -X $METHOD $ENDPOINT
166+ echo -X $METHOD $ENDPOINT
159167 fi
160168}
161169# __call GET "/controller/rest/applications/\${a}/business-transactions" -a ECommerce
@@ -644,48 +652,12 @@ describe metric_tree << EOF
644652Create a metric tree for the given application (-a). Note that this will create a lot of requests towards your controller.
645653EOF
646654function dbmon_create {
647- local DB_USER=" "
648- local DB_HOSTNAME=" "
649- local DB_AGENT=" "
650- local DB_TYPE=" "
651- local DB_COLLECTOR_NAME=" "
652- local DB_NAME=" "
653- local DB_PORT=" "
654- local DB_PASSWORD=" "
655- while getopts " u:h:a:t:n:p:s:" opt " $@ " ;
656- do
657- case " ${opt} " in
658- u)
659- DB_USER=${OPTARG}
660- ;;
661- h)
662- DB_HOSTNAME=${OPTARG}
663- ;;
664- a)
665- DB_AGENT=${OPTARG}
666- ;;
667- t)
668- DB_TYPE=${OPTARG}
669- ;;
670- n)
671- DB_NAME=${OPTARG}
672- ;;
673- p)
674- DB_PORT=${OPTARG}
675- ;;
676- s)
677- DB_PASSWORD=${OPTARG}
678- ;;
679- esac
680- done ;
681- shiftOptInd
682- shift $SHIFTS
683- DB_COLLECTOR_NAME=" $* "
684- controller_call -X POST -d " { \
685- \" username\" : \" $DB_USER \" ,\
686- \" hostname\" : \" $DB_HOSTNAME \" ,\
687- \" agentName\" : \" $DB_AGENT \" ,\
688- \" type\" : \" $DB_TYPE \" ,\
655+ apiCall -X POST -d " { \
656+ \" name\" : \"\$ {i}\" ,\
657+ \" username\" : \"\$ {u}\" ,\
658+ \" hostname\" : \"\$ {h}\" ,\
659+ \" agentName\" : \"\$ {a}\" ,\
660+ \" type\" : \"\$ {t}\" ,\
689661 \" orapkiSslEnabled\" : false,\
690662 \" orasslTruststoreLoc\" : null,\
691663 \" orasslTruststoreType\" : null,\
@@ -694,17 +666,24 @@ function dbmon_create {
694666 \" orasslKeystoreLoc\" : null,\
695667 \" orasslKeystoreType\" : null,\
696668 \" orasslKeystorePassword\" : null,\
697- \" name\" : \" $DB_COLLECTOR_NAME \" ,\
698- \" databaseName\" : \" $DB_NAME \" ,\
699- \" port\" : \" $DB_PORT \" ,\
700- \" password\" : \" $DB_PASSWORD \" ,\
669+ \" databaseName\" : \"\$ {n}\" ,\
670+ \" port\" : \"\$ {p}\" ,\
671+ \" password\" : \"\$ {s}\" ,\
701672 \" excludedSchemas\" : [],\
702673 \" enabled\" : true\
703- }" /controller/restui/databases/collectors/createConfiguration
674+ }" /controller/restui/databases/collectors/createConfiguration " $@ "
704675}
705676register dbmon_create Create a new database collector
706677describe dbmon_create << EOF
707- Create a new database collector
678+ Create a new database collector. You need to provide the following parameters:
679+ -i name
680+ -u user name
681+ -h host name
682+ -a agent name
683+ -t type
684+ -d database name
685+ -p port
686+ -s password
708687EOF
709688function dbmon_list {
710689 controller_call /controller/restui/databases/collectors/
0 commit comments