Skip to content

Commit

Permalink
Add dashboard get ; add recipe to update dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
svrnm committed Mar 26, 2019
1 parent cdd8b4b commit d655502
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 8 deletions.
3 changes: 2 additions & 1 deletion USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,10 @@ Import and export custom dashboards in the AppDynamics controller
| ------- | ----------- | ------- |
| delete | Delete a dashboard. Provide a dashboard id (-i) as parameter | `act.sh dashboard delete -i 2` |
| export | Export a dashboard. Provide a dashboard id (-i) as parameter | `act.sh dashboard export -i 2` |
| get | Get a dashboard. Provide a dashboard id (-i) as parameter. | `act.sh dashboard get -i 2` |
| import | Import a dashboard. Provide a dashboard file or json (-d) as parameter. | `act.sh dashboard import -d @examples/dashboard.json` |
| list | List all dashboards. This command requires no further arguments. | `act.sh dashboard list ` |
| 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` |
| 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` |


## dbmon
Expand Down
8 changes: 5 additions & 3 deletions act.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
ACT_VERSION="v0.4.0"
ACT_LAST_COMMIT="375ea8f52adfb5b7d708ae8614103c7586fd519d"
ACT_LAST_COMMIT="cdd8b4bff4df64e2eae56ccb4bc0eb1e5b7f0639"
USER_CONFIG="$HOME/.appdynamics/act/config.sh"
GLOBAL_CONFIG="/etc/appdynamics/act/config.sh"
CONFIG_CONTROLLER_COOKIE_LOCATION="/tmp/appdynamics-controller-cookie.txt"
Expand Down Expand Up @@ -162,12 +162,14 @@ function dashboard_delete { apiCall -X POST -d '[{{i:dashboard_id}}]' '/controll
rde dashboard_delete "Delete a dashboard." "Provide a dashboard id (-i) as parameter" "-i 2"
function dashboard_export { apiCall '/controller/CustomDashboardImportExportServlet?dashboardId={{i:dashboard_id}}' "$@" ; }
rde dashboard_export "Export a dashboard." "Provide a dashboard id (-i) as parameter" "-i 2"
function dashboard_get { apiCall '/controller/restui/dashboards/dashboardIfUpdated/{{i:dashboard_id}}/-1' "$@" ; }
rde dashboard_get "Get a dashboard." "Provide a dashboard id (-i) as parameter." "-i 2"
function dashboard_import { apiCallExpand -X POST -F 'file={{d:dashboard}}' '/controller/CustomDashboardImportExportServlet' "$@" ; }
rde dashboard_import "Import a dashboard." "Provide a dashboard file or json (-d) as parameter." "-d @examples/dashboard.json"
function dashboard_list { apiCall '/controller/restui/dashboards/getAllDashboardsByType/false' "$@" ; }
rde dashboard_list "List all dashboards." "This command requires no further arguments." ""
function dashboard_update { apiCall -X POST -d '{{f:dashboard_definition}}' '/controller/restui/dashboards/updateDashboard' "$@" ; }
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"
function dashboard_update { apiCall -X POST -d '{{d:dashboard_definition}}' '/controller/restui/dashboards/updateDashboard' "$@" ; }
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"
doc dbmon << EOF
Use the Database Visibility API to get, create, update, and delete Database Visibility Collectors.
EOF
Expand Down
10 changes: 8 additions & 2 deletions commands.yml
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,11 @@ dashboard:
payload: [{{i:dashboard_id}}]
update:
title: Update a dashboard.
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.
description: Provide a dashboard file or json (-d) as parameter. Use the \\\`dashboard get\\\` command to retrieve the correct format for updating.
example: -d @dashboardUpdate.json
method: POST
endpoint: /controller/restui/dashboards/updateDashboard
payload: {{f:dashboard_definition}}
payload: {{d:dashboard_definition}}
import:
title: Import a dashboard.
description: Provide a dashboard file or json (-d) as parameter.
Expand All @@ -299,6 +299,12 @@ dashboard:
endpoint: /controller/CustomDashboardImportExportServlet
form: file={{d:dashboard}}
expand: true
get:
title: Get a dashboard.
description: Provide a dashboard id (-i) as parameter.
example: -i 2
method: GET
endpoint: /controller/restui/dashboards/dashboardIfUpdated/{{i:dashboard_id}}/-1
event:
title: Events
description: Create and list events in your business applications.
Expand Down
27 changes: 27 additions & 0 deletions examples/dashboard_empty_update_format.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"id" : 3166,
"version" : 2,
"name" : "Empty Dashboard",
"nameUnique" : false,
"builtIn" : false,
"description" : null,
"missingAssociatedEntities" : null,
"widgets" : [ ],
"securityToken" : null,
"sharingRevoked" : false,
"warRoom" : false,
"template" : false,
"templateEntityType" : "APPLICATION_COMPONENT_NODE",
"minutesBeforeAnchorTime" : -1,
"startTime" : -1,
"endTime" : -1,
"refreshInterval" : 120000,
"backgroundColor" : 5856629,
"color" : 15856629,
"height" : 1024,
"width" : 50,
"disabled" : false,
"canvasType" : "CANVAS_TYPE_GRID",
"layoutType" : "",
"properties" : [ ]
}
32 changes: 31 additions & 1 deletion postman-collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -958,6 +958,36 @@
},
"description": "Provide a dashboard id (-i) as parameter"
}
},{
"name": "Get a dashboard.",
"request": {
"method": "GET",
"header": [
{
"key": "Content-Type",
"value": "application/json;charset=UTF-8",
"type": "text"
},
{
"key": "X-CSRF-TOKEN",
"value": "{{X-CSRF-TOKEN}}",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": ""
},
"url": {
"raw": "{{controller_host}}/controller/restui/dashboards/dashboardIfUpdated/{{i:dashboard_id}}/-1",
"host": [
"{{controller_host}}"
],
"path": ["controller","restui","dashboards","dashboardIfUpdated","{{dashboard_id}}","-1"],
"query": []
},
"description": "Provide a dashboard id (-i) as parameter."
}
},{
"name": "Import a dashboard.",
"request": {
Expand Down Expand Up @@ -1046,7 +1076,7 @@
"path": ["controller","restui","dashboards","updateDashboard"],
"query": []
},
"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."
"description": "Provide a dashboard file or json (-d) as parameter. Use the \`dashboard get\` command to retrieve the correct format for updating."
}
}]},{"name": "dbmon","item": [{
"name": "Delete multiple collectors.",
Expand Down
1 change: 0 additions & 1 deletion recipes/.json

This file was deleted.

16 changes: 16 additions & 0 deletions recipes/update_dashboard.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
# SINCE: yesterday, 0:00, UNTIL today, 0:00
TODAY_MIDNIGHT=$(date -r $(((`date +%s`/86400*86400))) +%s)
declare -i TODAY_MIDNIGHT
DEFAULT_SINCE="$((${TODAY_MIDNIGHT}-86400))000"
DEFAULT_UNTIL="${TODAY_MIDNIGHT}000"

ENVIRONMENT=$1
DASHBOARD_ID=$2
SINCE=${3:-${DEFAULT_SINCE}}
UNTIL=${4:-${DEFAULT_UNTIL}}


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")

../act.sh -E ${ENVIRONMENT} dashboard update -d "${JSON}"

0 comments on commit d655502

Please sign in to comment.