Skip to content

Commit ad9bd4e

Browse files
committed
Updated Healthrule list, added healthrule enable/disable
Updated Healthrule list, added healthrule enable/disable. Also added recipes for healthrule_enablebyname and healthrule_disablebyname
1 parent 50c26f2 commit ad9bd4e

7 files changed

+3183
-205
lines changed

USAGE.md

+1,316-200
Large diffs are not rendered by default.

act.sh

+1,744-2
Large diffs are not rendered by default.

commands.yml

+15-1
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ healthrule:
415415
description: Provide an application (-a) as parameter
416416
example: -a 29
417417
method: GET
418-
endpoint: /controller/healthrules/{{a:application}}/
418+
endpoint: /controller/alerting/rest/v1/applications/{{a:application}}/health-rules
419419
get:
420420
title: Get a healthrule.
421421
description: Provide an application (-a) and a health rule name (-n) as parameters.
@@ -428,6 +428,20 @@ healthrule:
428428
example: -a 29 -t BEFORE_NOW -d 120
429429
method: GET
430430
endpoint: /controller/rest/applications/{{a:application}}/problems/healthrule-violations?time-range-type={{t:time_range_type}}&duration-in-mins={{d:duration_in_minutes?}}&start-time={{b:start_time?}}&end-time={{e:end_time?}}
431+
enable:
432+
title: Enable a healthrule.
433+
description: Provide an application (-a) and a health rule id (-i) as parameters.
434+
example: -a 29 -i 54
435+
method: PUT
436+
endpoint: /controller/alerting/rest/v1/applications/{{a:application}}/health-rules/{{i:healthrule_id}}/configuration
437+
payload: {\"enabled\": \"true\"}
438+
disable:
439+
title: Disable a healthrule.
440+
description: Provide an application (-a) and a health rule id (-i) as parameters.
441+
example: -a 29 -i 54
442+
method: PUT
443+
endpoint: /controller/alerting/rest/v1/applications/{{a:application}}/health-rules/{{i:healthrule_id}}/configuration
444+
payload: {\"enabled\": \"false\"}
431445
licenserule:
432446
title: License Rules API
433447
list:

postman-collection.json

+62-2
Original file line numberDiff line numberDiff line change
@@ -1649,6 +1649,66 @@
16491649
"description": "Provide an component (tier, node, ...) id (-c) and a time range string (-t) as parameter"
16501650
}
16511651
}]},{"name": "healthrule","item": [{
1652+
"name": "Disable a healthrule.",
1653+
"request": {
1654+
"method": "PUT",
1655+
"header": [
1656+
{
1657+
"key": "Content-Type",
1658+
"value": "application/json;charset=UTF-8",
1659+
"type": "text"
1660+
},
1661+
{
1662+
"key": "X-CSRF-TOKEN",
1663+
"value": "{{X-CSRF-TOKEN}}",
1664+
"type": "text"
1665+
}
1666+
],
1667+
"body": {
1668+
"mode": "raw",
1669+
"raw": "{\"enabled\": \"false\"}"
1670+
},
1671+
"url": {
1672+
"raw": "{{controller_host}}/controller/alerting/rest/v1/applications/{{a:application}}/health-rules/{{i:healthrule_id}}/configuration",
1673+
"host": [
1674+
"{{controller_host}}"
1675+
],
1676+
"path": ["controller","alerting","rest","v1","applications","{{application}}","health-rules","{{healthrule_id}}","configuration"],
1677+
"query": []
1678+
},
1679+
"description": "Provide an application (-a) and a health rule id (-i) as parameters."
1680+
}
1681+
},{
1682+
"name": "Enable a healthrule.",
1683+
"request": {
1684+
"method": "PUT",
1685+
"header": [
1686+
{
1687+
"key": "Content-Type",
1688+
"value": "application/json;charset=UTF-8",
1689+
"type": "text"
1690+
},
1691+
{
1692+
"key": "X-CSRF-TOKEN",
1693+
"value": "{{X-CSRF-TOKEN}}",
1694+
"type": "text"
1695+
}
1696+
],
1697+
"body": {
1698+
"mode": "raw",
1699+
"raw": "{\"enabled\": \"true\"}"
1700+
},
1701+
"url": {
1702+
"raw": "{{controller_host}}/controller/alerting/rest/v1/applications/{{a:application}}/health-rules/{{i:healthrule_id}}/configuration",
1703+
"host": [
1704+
"{{controller_host}}"
1705+
],
1706+
"path": ["controller","alerting","rest","v1","applications","{{application}}","health-rules","{{healthrule_id}}","configuration"],
1707+
"query": []
1708+
},
1709+
"description": "Provide an application (-a) and a health rule id (-i) as parameters."
1710+
}
1711+
},{
16521712
"name": "Get a healthrule.",
16531713
"request": {
16541714
"method": "GET",
@@ -1699,11 +1759,11 @@
16991759
"raw": ""
17001760
},
17011761
"url": {
1702-
"raw": "{{controller_host}}/controller/healthrules/{{a:application}}/",
1762+
"raw": "{{controller_host}}/controller/alerting/rest/v1/applications/{{a:application}}/health-rules",
17031763
"host": [
17041764
"{{controller_host}}"
17051765
],
1706-
"path": ["controller","healthrules","{{application}}",""],
1766+
"path": ["controller","alerting","rest","v1","applications","{{application}}","health-rules"],
17071767
"query": []
17081768
},
17091769
"description": "Provide an application (-a) as parameter"

recipes/.DS_Store

6 KB
Binary file not shown.

recipes/healthrule_disablebyname.sh

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
# {
3+
# "enabled": true,
4+
# "id": 35428,
5+
# "name": "CPU utilization is too high"
6+
# }
7+
8+
ENVIRONMENT=$1
9+
APPLICATION_ID=$2
10+
HR_NAME=$3
11+
12+
echo "${ENVIRONMENT} ---- ${APPLICATION_ID} ----- ${HR_NAME} -------"
13+
# Get a list of healthrules that match the grep argument
14+
# Format is [ID] [Name]
15+
# In case anyone cares - we do the grep after the sed and awk commands to handle the potential edge case of the grep regex matching one of our keywords (id, name).
16+
# This way they get filtered out before we search on the HR name.
17+
HEALTHRULES=$(../act.sh -E ${ENVIRONMENT} healthrule list -a ${APPLICATION_ID} | sed 's/},{/\'$'\n'/g | awk -F "\"" '/"id":([[:digit:]]+)/ {print $3" "$6}' - | sed 's/^://'g | sed 's/, / /' | grep "${HR_NAME}" | awk '{print $1}' - )
18+
19+
for HR in $HEALTHRULES
20+
do
21+
echo "Disable HR ${HR}"
22+
../act.sh -E ${ENVIRONMENT} healthrule disable -a ${APPLICATION_ID} -i ${HR}
23+
done;

recipes/healthrule_enablebyname.sh

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
# {
3+
# "enabled": true,
4+
# "id": 35428,
5+
# "name": "CPU utilization is too high"
6+
# }
7+
8+
ENVIRONMENT=$1
9+
APPLICATION_ID=$2
10+
HR_NAME=$3
11+
12+
echo "${ENVIRONMENT} ---- ${APPLICATION_ID} ----- ${HR_NAME} -------"
13+
# Get a list of healthrules that match the grep argument
14+
# Format is [ID] [Name]
15+
# In case anyone cares - we do the grep after the sed and awk commands to handle the potential edge case of the grep regex matching one of our keywords (id, name).
16+
# This way they get filtered out before we search on the HR name.
17+
HEALTHRULES=$(../act.sh -E ${ENVIRONMENT} healthrule list -a ${APPLICATION_ID} | sed 's/},{/\'$'\n'/g | awk -F "\"" '/"id":([[:digit:]]+)/ {print $3" "$6}' - | sed 's/^://'g | sed 's/, / /' | grep "${HR_NAME}" | awk '{print $1}' - )
18+
19+
for HR in $HEALTHRULES
20+
do
21+
echo "Enable HR ${HR}"
22+
../act.sh -E ${ENVIRONMENT} healthrule enable -a ${APPLICATION_ID} -i ${HR}
23+
done;

0 commit comments

Comments
 (0)