Skip to content

Commit 43a2301

Browse files
committed
Add synthetic list/import and recipes to export/copy synthetic jobs
1 parent 05b09df commit 43a2301

File tree

8 files changed

+183
-5
lines changed

8 files changed

+183
-5
lines changed

USAGE.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ List APM snapshots.
320320

321321
| Command | Description | Example |
322322
| ------- | ----------- | ------- |
323-
| list | Retrieve a list of snapshots Provide an application (-a) as parameter, as well es a time range (-t), the duration in minutes (-d) or start (-b) and end time (-f) | `act.sh snapshot list -a 29 -t BEFORE_NOW -d 120` |
323+
| list | Retrieve a list of snapshots Provide an application (-a) as parameter, as well as a time range (-t), the duration in minutes (-d) or start (-b) and end time (-f) | `act.sh snapshot list -a 29 -t BEFORE_NOW -d 120` |
324324

325325

326326
## synthetic
@@ -329,6 +329,8 @@ Create synthetic snapshots or jobs
329329

330330
| Command | Description | Example |
331331
| ------- | ----------- | ------- |
332+
| import | Import a synthetic job. Provide an EUM application id (-a) as parameter and a json string or a file (with @ as prefix) as parameter (-d) | `act.sh synthetic import -a 41 -d @examples/syntheticjob.json` |
333+
| list | List all synthetic jobs. Provide an EUM application id (-a) as parameter, as well as an time range string (-t). | `act.sh synthetic list -a 41 -t last_1_hour.BEFORE_NOW.-1.-1.60` |
332334
| snapshot | Generate synthetic snapshot. Provide an EUM application (-a), a brower (-b) and an URL (-u) as parameter. | `act.sh synthetic snapshot -u http://www.appdynmics.com -l AMS -b Chrome -a 128` |
333335

334336

act.sh

Lines changed: 6 additions & 2 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="6da09b22d08b0abbcd200f4de671149b74a680ca"
3+
ACT_LAST_COMMIT="05b09dfd00a013c4ec108156661cd20e8218bde2"
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"
@@ -245,10 +245,14 @@ doc snapshot << EOF
245245
List APM snapshots.
246246
EOF
247247
function snapshot_list { apiCall '/controller/rest/applications/{{a:application}}/request-snapshots?time-range-type={{t:time_range_type}}&duration-in-mins={{d:duration_in_minutes?}}&start-time={{b:start_time?}}&end-time={{f:end_time?}}' "$@" ; }
248-
rde snapshot_list "Retrieve a list of snapshots" "Provide an application (-a) as parameter, as well es a time range (-t), the duration in minutes (-d) or start (-b) and end time (-f)" "-a 29 -t BEFORE_NOW -d 120"
248+
rde snapshot_list "Retrieve a list of snapshots" "Provide an application (-a) as parameter, as well as a time range (-t), the duration in minutes (-d) or start (-b) and end time (-f)" "-a 29 -t BEFORE_NOW -d 120"
249249
doc synthetic << EOF
250250
Create synthetic snapshots or jobs
251251
EOF
252+
function synthetic_import { apiCall -X POST -d '{{d:synthetic_job}}' '/controller/restui/synthetic/schedule/{{a:application}}/updateSchedule' "$@" ; }
253+
rde synthetic_import "Import a synthetic job." "Provide an EUM application id (-a) as parameter and a json string or a file (with @ as prefix) as parameter (-d)" "-a 41 -d @examples/syntheticjob.json"
254+
function synthetic_list { apiCall -X POST -d '{"applicationId":{{a:application}},"timeRangeString":"{{t:time_range}}"}' '/controller/restui/synthetic/schedule/getJobList' "$@" ; }
255+
rde synthetic_list "List all synthetic jobs." "Provide an EUM application id (-a) as parameter, as well as an time range string (-t)." "-a 41 -t last_1_hour.BEFORE_NOW.-1.-1.60"
252256
function synthetic_snapshot { apiCall -X POST -d '{"url":"{{u:url}}","location":"{{l:location}}","browser":"{{b:browser}}","applicationId":{{a:application}},"timeRangeString":null,"timeoutSeconds":30,"script":null}' '/controller/restui/synthetic/launch/generateLoad' "$@" ; }
253257
rde synthetic_snapshot "Generate synthetic snapshot." "Provide an EUM application (-a), a brower (-b) and an URL (-u) as parameter." "-u http://www.appdynmics.com -l AMS -b Chrome -a 128"
254258
doc tier << EOF

commands.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,13 +432,27 @@ snapshot:
432432
description: List APM snapshots.
433433
list:
434434
title: Retrieve a list of snapshots
435-
description: Provide an application (-a) as parameter, as well es a time range (-t), the duration in minutes (-d) or start (-b) and end time (-f)
435+
description: Provide an application (-a) as parameter, as well as a time range (-t), the duration in minutes (-d) or start (-b) and end time (-f)
436436
example: -a 29 -t BEFORE_NOW -d 120
437437
method: GET
438438
endpoint: /controller/rest/applications/{{a:application}}/request-snapshots?time-range-type={{t:time_range_type}}&duration-in-mins={{d:duration_in_minutes?}}&start-time={{b:start_time?}}&end-time={{f:end_time?}}
439439
synthetic:
440440
title: Synthetic
441441
description: Create synthetic snapshots or jobs
442+
list:
443+
title: List all synthetic jobs.
444+
description: Provide an EUM application id (-a) as parameter, as well as an time range string (-t).
445+
example: -a 41 -t last_1_hour.BEFORE_NOW.-1.-1.60
446+
method: POST
447+
endpoint: /controller/restui/synthetic/schedule/getJobList
448+
payload: {\"applicationId\":{{a:application}},\"timeRangeString\":\"{{t:time_range}}\"}
449+
import:
450+
title: Import a synthetic job.
451+
description: Provide an EUM application id (-a) as parameter and a json string or a file (with @ as prefix) as parameter (-d)
452+
example: -a 41 -d @examples/syntheticjob.json
453+
method: POST
454+
endpoint: /controller/restui/synthetic/schedule/{{a:application}}/updateSchedule
455+
payload: {{d:synthetic_job}}
442456
snapshot:
443457
title: Generate synthetic snapshot.
444458
description: Provide an EUM application (-a), a brower (-b) and an URL (-u) as parameter.

examples/syntheticjob.json

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"id": null,
3+
"rate": {
4+
"unit": "MINUTES",
5+
"value": 15
6+
},
7+
"daysOfWeek": ["SUN", "MON", "TUES", "WED", "THUR", "FRI", "SAT"],
8+
"timeRange": null,
9+
"timezone": null,
10+
"description": "test script",
11+
"userEnabled": true,
12+
"systemEnabled": true,
13+
"failOnPageError": true,
14+
"version": 0,
15+
"startTimeMillis": null,
16+
"endTimeMillis": null,
17+
"url": null,
18+
"script": {
19+
"script": "pageUrl = \"http://www.appdynamics.com\"\ndriver.get(pageUrl)\nassert \"AppDynamics\" in driver.title, \"Title should contain AppDynamics\"\n",
20+
"contentType": "INLINE_PYTHON"
21+
},
22+
"browserCodes": ["Chrome"],
23+
"locationCodes": ["YYZ", "MXP"],
24+
"scheduleMode": "NONE",
25+
"timeoutSeconds": 30,
26+
"appKey": null,
27+
"state": null,
28+
"projectedUsage": null,
29+
"networkProfile": {
30+
"name": "FIOS",
31+
"description": "",
32+
"downloadKbps": 5000,
33+
"uploadKbps": 1000,
34+
"roundtripTimeMillis": 28,
35+
"packetLossPercent": 0
36+
},
37+
"composableConfig": {
38+
"resourceErrorDetection": {
39+
"ignoreWhen": {
40+
"resourceUrlContains": [],
41+
"resourceMimeType": []
42+
},
43+
"onlyWhen": {
44+
"resourceUrlContains": [],
45+
"resourceMimeType": []
46+
},
47+
"sessionStatus": null
48+
}
49+
},
50+
"created": null,
51+
"updated": null,
52+
"performanceCriteria": {
53+
"retestOnWarning": false,
54+
"retestOnCritical": false,
55+
"warningCriterion": [],
56+
"criticalCriterion": []
57+
}
58+
}

postman-collection.json

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1766,9 +1766,69 @@
17661766
"path": ["controller","rest","applications","{{application}}","request-snapshots"],
17671767
"query": [{"key": "time-range-type","value": "{{time_range_type}}"},{"key":"duration-in-mins","value": "{{duration_in_minutes}}"},{"key":"start-time","value": "{{start_time}}"},{"key":"end-time","value": "{{end_time}}"}]
17681768
},
1769-
"description": "Provide an application (-a) as parameter, as well es a time range (-t), the duration in minutes (-d) or start (-b) and end time (-f)"
1769+
"description": "Provide an application (-a) as parameter, as well as a time range (-t), the duration in minutes (-d) or start (-b) and end time (-f)"
17701770
}
17711771
}]},{"name": "synthetic","item": [{
1772+
"name": "Import a synthetic job.",
1773+
"request": {
1774+
"method": "POST",
1775+
"header": [
1776+
{
1777+
"key": "Content-Type",
1778+
"value": "application/json;charset=UTF-8",
1779+
"type": "text"
1780+
},
1781+
{
1782+
"key": "X-CSRF-TOKEN",
1783+
"value": "{{X-CSRF-TOKEN}}",
1784+
"type": "text"
1785+
}
1786+
],
1787+
"body": {
1788+
"mode": "raw",
1789+
"raw": "{{synthetic_job}}"
1790+
},
1791+
"url": {
1792+
"raw": "{{controller_host}}/controller/restui/synthetic/schedule/{{a:application}}/updateSchedule",
1793+
"host": [
1794+
"{{controller_host}}"
1795+
],
1796+
"path": ["controller","restui","synthetic","schedule","{{application}}","updateSchedule"],
1797+
"query": []
1798+
},
1799+
"description": "Provide an EUM application id (-a) as parameter and a json string or a file (with @ as prefix) as parameter (-d)"
1800+
}
1801+
},{
1802+
"name": "List all synthetic jobs.",
1803+
"request": {
1804+
"method": "POST",
1805+
"header": [
1806+
{
1807+
"key": "Content-Type",
1808+
"value": "application/json;charset=UTF-8",
1809+
"type": "text"
1810+
},
1811+
{
1812+
"key": "X-CSRF-TOKEN",
1813+
"value": "{{X-CSRF-TOKEN}}",
1814+
"type": "text"
1815+
}
1816+
],
1817+
"body": {
1818+
"mode": "raw",
1819+
"raw": "{\"applicationId\":{{application}},\"timeRangeString\":\"{{time_range}}\"}"
1820+
},
1821+
"url": {
1822+
"raw": "{{controller_host}}/controller/restui/synthetic/schedule/getJobList",
1823+
"host": [
1824+
"{{controller_host}}"
1825+
],
1826+
"path": ["controller","restui","synthetic","schedule","getJobList"],
1827+
"query": []
1828+
},
1829+
"description": "Provide an EUM application id (-a) as parameter, as well as an time range string (-t)."
1830+
}
1831+
},{
17721832
"name": "Generate synthetic snapshot.",
17731833
"request": {
17741834
"method": "POST",

recipes/.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

recipes/synthetic_copy.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
ENVIRONMENT=$1
3+
APPLICATION=$2
4+
TARGET_ENVIRONMENT=$3
5+
TARGET_APPLICATION=$4
6+
7+
DATA=$(../act.sh -E ${ENVIRONMENT} synthetic list -a ${APPLICATION} -t last_1_hour.BEFORE_NOW.-1.-1.60)
8+
COUNT=$(echo $DATA | jq '.jobListDatas | length')
9+
declare -i COUNT
10+
11+
COUNT=${COUNT}-1
12+
13+
for i in `seq 0 ${COUNT}` ; do
14+
NAME=$(echo "$DATA" | jq -r ".jobListDatas | .[$i] | .config | .description")
15+
CONFIG=$(echo "$DATA" | jq -r ".jobListDatas | .[$i] | .config | setpath([\"id\"];null)")
16+
echo "Copying ${NAME}: "
17+
../act.sh -E "${TARGET_ENVIRONMENT}" synthetic import -a "${TARGET_APPLICATION}" -d "${CONFIG}"
18+
done;

recipes/synthetic_export.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
ENVIRONMENT=$1
3+
APPLICATION=$2
4+
OUTPUTDIRECTORY=$3
5+
6+
if [ ! -d "${OUTPUTDIRECTORY}" ] ;
7+
then
8+
echo "${OUTPUTDIRECTORY} is not a directory."
9+
exit
10+
fi;
11+
12+
DATA=$(../act.sh -E ${ENVIRONMENT} synthetic list -a ${APPLICATION} -t last_1_hour.BEFORE_NOW.-1.-1.60)
13+
COUNT=$(echo $DATA | jq '.jobListDatas | length')
14+
declare -i COUNT
15+
16+
COUNT=${COUNT}-1
17+
18+
for i in `seq 0 ${COUNT}` ; do
19+
NAME=$(echo "$DATA" | jq -r ".jobListDatas | .[$i] | .config | .description")
20+
echo "$DATA" | jq -r ".jobListDatas | .[$i] | .config | setpath([\"id\"];null)" > "${OUTPUTDIRECTORY}/${NAME}.json"
21+
done;

0 commit comments

Comments
 (0)