Skip to content

Commit d655502

Browse files
committed
Add dashboard get ; add recipe to update dashboard
1 parent cdd8b4b commit d655502

File tree

7 files changed

+89
-8
lines changed

7 files changed

+89
-8
lines changed

USAGE.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,10 @@ Import and export custom dashboards in the AppDynamics controller
164164
| ------- | ----------- | ------- |
165165
| delete | Delete a dashboard. Provide a dashboard id (-i) as parameter | `act.sh dashboard delete -i 2` |
166166
| export | Export a dashboard. Provide a dashboard id (-i) as parameter | `act.sh dashboard export -i 2` |
167+
| get | Get a dashboard. Provide a dashboard id (-i) as parameter. | `act.sh dashboard get -i 2` |
167168
| import | Import a dashboard. Provide a dashboard file or json (-d) as parameter. | `act.sh dashboard import -d @examples/dashboard.json` |
168169
| list | List all dashboards. This command requires no further arguments. | `act.sh dashboard list ` |
169-
| update | Update a dashboard. Provide a dashboard file or json (-f) as parameter. Please not that the json you need to provide is not compatible with the export format. | `act.sh dashboard update -d @dashboardUpdate.json` |
170+
| update | Update a dashboard. Provide a dashboard file or json (-d) as parameter. Use the `dashboard get` command to retrieve the correct format for updating. | `act.sh dashboard update -d @dashboardUpdate.json` |
170171

171172

172173
## dbmon

act.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
ACT_VERSION="v0.4.0"
3-
ACT_LAST_COMMIT="375ea8f52adfb5b7d708ae8614103c7586fd519d"
3+
ACT_LAST_COMMIT="cdd8b4bff4df64e2eae56ccb4bc0eb1e5b7f0639"
44
USER_CONFIG="$HOME/.appdynamics/act/config.sh"
55
GLOBAL_CONFIG="/etc/appdynamics/act/config.sh"
66
CONFIG_CONTROLLER_COOKIE_LOCATION="/tmp/appdynamics-controller-cookie.txt"
@@ -162,12 +162,14 @@ function dashboard_delete { apiCall -X POST -d '[{{i:dashboard_id}}]' '/controll
162162
rde dashboard_delete "Delete a dashboard." "Provide a dashboard id (-i) as parameter" "-i 2"
163163
function dashboard_export { apiCall '/controller/CustomDashboardImportExportServlet?dashboardId={{i:dashboard_id}}' "$@" ; }
164164
rde dashboard_export "Export a dashboard." "Provide a dashboard id (-i) as parameter" "-i 2"
165+
function dashboard_get { apiCall '/controller/restui/dashboards/dashboardIfUpdated/{{i:dashboard_id}}/-1' "$@" ; }
166+
rde dashboard_get "Get a dashboard." "Provide a dashboard id (-i) as parameter." "-i 2"
165167
function dashboard_import { apiCallExpand -X POST -F 'file={{d:dashboard}}' '/controller/CustomDashboardImportExportServlet' "$@" ; }
166168
rde dashboard_import "Import a dashboard." "Provide a dashboard file or json (-d) as parameter." "-d @examples/dashboard.json"
167169
function dashboard_list { apiCall '/controller/restui/dashboards/getAllDashboardsByType/false' "$@" ; }
168170
rde dashboard_list "List all dashboards." "This command requires no further arguments." ""
169-
function dashboard_update { apiCall -X POST -d '{{f:dashboard_definition}}' '/controller/restui/dashboards/updateDashboard' "$@" ; }
170-
rde dashboard_update "Update a dashboard." "Provide a dashboard file or json (-f) as parameter. Please not that the json you need to provide is not compatible with the export format." "-d @dashboardUpdate.json"
171+
function dashboard_update { apiCall -X POST -d '{{d:dashboard_definition}}' '/controller/restui/dashboards/updateDashboard' "$@" ; }
172+
rde dashboard_update "Update a dashboard." "Provide a dashboard file or json (-d) as parameter. Use the \`dashboard get\` command to retrieve the correct format for updating." "-d @dashboardUpdate.json"
171173
doc dbmon << EOF
172174
Use the Database Visibility API to get, create, update, and delete Database Visibility Collectors.
173175
EOF

commands.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,11 +286,11 @@ dashboard:
286286
payload: [{{i:dashboard_id}}]
287287
update:
288288
title: Update a dashboard.
289-
description: Provide a dashboard file or json (-f) as parameter. Please not that the json you need to provide is not compatible with the export format.
289+
description: Provide a dashboard file or json (-d) as parameter. Use the \\\`dashboard get\\\` command to retrieve the correct format for updating.
290290
example: -d @dashboardUpdate.json
291291
method: POST
292292
endpoint: /controller/restui/dashboards/updateDashboard
293-
payload: {{f:dashboard_definition}}
293+
payload: {{d:dashboard_definition}}
294294
import:
295295
title: Import a dashboard.
296296
description: Provide a dashboard file or json (-d) as parameter.
@@ -299,6 +299,12 @@ dashboard:
299299
endpoint: /controller/CustomDashboardImportExportServlet
300300
form: file={{d:dashboard}}
301301
expand: true
302+
get:
303+
title: Get a dashboard.
304+
description: Provide a dashboard id (-i) as parameter.
305+
example: -i 2
306+
method: GET
307+
endpoint: /controller/restui/dashboards/dashboardIfUpdated/{{i:dashboard_id}}/-1
302308
event:
303309
title: Events
304310
description: Create and list events in your business applications.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"id" : 3166,
3+
"version" : 2,
4+
"name" : "Empty Dashboard",
5+
"nameUnique" : false,
6+
"builtIn" : false,
7+
"description" : null,
8+
"missingAssociatedEntities" : null,
9+
"widgets" : [ ],
10+
"securityToken" : null,
11+
"sharingRevoked" : false,
12+
"warRoom" : false,
13+
"template" : false,
14+
"templateEntityType" : "APPLICATION_COMPONENT_NODE",
15+
"minutesBeforeAnchorTime" : -1,
16+
"startTime" : -1,
17+
"endTime" : -1,
18+
"refreshInterval" : 120000,
19+
"backgroundColor" : 5856629,
20+
"color" : 15856629,
21+
"height" : 1024,
22+
"width" : 50,
23+
"disabled" : false,
24+
"canvasType" : "CANVAS_TYPE_GRID",
25+
"layoutType" : "",
26+
"properties" : [ ]
27+
}

postman-collection.json

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -958,6 +958,36 @@
958958
},
959959
"description": "Provide a dashboard id (-i) as parameter"
960960
}
961+
},{
962+
"name": "Get a dashboard.",
963+
"request": {
964+
"method": "GET",
965+
"header": [
966+
{
967+
"key": "Content-Type",
968+
"value": "application/json;charset=UTF-8",
969+
"type": "text"
970+
},
971+
{
972+
"key": "X-CSRF-TOKEN",
973+
"value": "{{X-CSRF-TOKEN}}",
974+
"type": "text"
975+
}
976+
],
977+
"body": {
978+
"mode": "raw",
979+
"raw": ""
980+
},
981+
"url": {
982+
"raw": "{{controller_host}}/controller/restui/dashboards/dashboardIfUpdated/{{i:dashboard_id}}/-1",
983+
"host": [
984+
"{{controller_host}}"
985+
],
986+
"path": ["controller","restui","dashboards","dashboardIfUpdated","{{dashboard_id}}","-1"],
987+
"query": []
988+
},
989+
"description": "Provide a dashboard id (-i) as parameter."
990+
}
961991
},{
962992
"name": "Import a dashboard.",
963993
"request": {
@@ -1046,7 +1076,7 @@
10461076
"path": ["controller","restui","dashboards","updateDashboard"],
10471077
"query": []
10481078
},
1049-
"description": "Provide a dashboard file or json (-f) as parameter. Please not that the json you need to provide is not compatible with the export format."
1079+
"description": "Provide a dashboard file or json (-d) as parameter. Use the \`dashboard get\` command to retrieve the correct format for updating."
10501080
}
10511081
}]},{"name": "dbmon","item": [{
10521082
"name": "Delete multiple collectors.",

recipes/.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

recipes/update_dashboard.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
# SINCE: yesterday, 0:00, UNTIL today, 0:00
3+
TODAY_MIDNIGHT=$(date -r $(((`date +%s`/86400*86400))) +%s)
4+
declare -i TODAY_MIDNIGHT
5+
DEFAULT_SINCE="$((${TODAY_MIDNIGHT}-86400))000"
6+
DEFAULT_UNTIL="${TODAY_MIDNIGHT}000"
7+
8+
ENVIRONMENT=$1
9+
DASHBOARD_ID=$2
10+
SINCE=${3:-${DEFAULT_SINCE}}
11+
UNTIL=${4:-${DEFAULT_UNTIL}}
12+
13+
14+
JSON=$(../act.sh -E ${ENVIRONMENT} dashboard get -i ${DASHBOARD_ID} | sed -e "s/SINCE[[:space:]]*[0-9]*[[:space:]]*UNTIL[[:space:]]*[0-9]*/SINCE ${SINCE} UNTIL ${UNTIL}/g")
15+
16+
../act.sh -E ${ENVIRONMENT} dashboard update -d "${JSON}"

0 commit comments

Comments
 (0)