Skip to content

Commit

Permalink
Updated Healthrule list, added healthrule enable/disable
Browse files Browse the repository at this point in the history
Updated Healthrule list, added healthrule enable/disable.

Also added recipes for healthrule_enablebyname and healthrule_disablebyname
  • Loading branch information
EvanWetstone committed May 26, 2020
1 parent 50c26f2 commit ad9bd4e
Show file tree
Hide file tree
Showing 7 changed files with 3,183 additions and 205 deletions.
1,516 changes: 1,316 additions & 200 deletions USAGE.md

Large diffs are not rendered by default.

1,746 changes: 1,744 additions & 2 deletions act.sh

Large diffs are not rendered by default.

16 changes: 15 additions & 1 deletion commands.yml
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ healthrule:
description: Provide an application (-a) as parameter
example: -a 29
method: GET
endpoint: /controller/healthrules/{{a:application}}/
endpoint: /controller/alerting/rest/v1/applications/{{a:application}}/health-rules
get:
title: Get a healthrule.
description: Provide an application (-a) and a health rule name (-n) as parameters.
Expand All @@ -428,6 +428,20 @@ healthrule:
example: -a 29 -t BEFORE_NOW -d 120
method: GET
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?}}
enable:
title: Enable a healthrule.
description: Provide an application (-a) and a health rule id (-i) as parameters.
example: -a 29 -i 54
method: PUT
endpoint: /controller/alerting/rest/v1/applications/{{a:application}}/health-rules/{{i:healthrule_id}}/configuration
payload: {\"enabled\": \"true\"}
disable:
title: Disable a healthrule.
description: Provide an application (-a) and a health rule id (-i) as parameters.
example: -a 29 -i 54
method: PUT
endpoint: /controller/alerting/rest/v1/applications/{{a:application}}/health-rules/{{i:healthrule_id}}/configuration
payload: {\"enabled\": \"false\"}
licenserule:
title: License Rules API
list:
Expand Down
64 changes: 62 additions & 2 deletions postman-collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -1649,6 +1649,66 @@
"description": "Provide an component (tier, node, ...) id (-c) and a time range string (-t) as parameter"
}
}]},{"name": "healthrule","item": [{
"name": "Disable a healthrule.",
"request": {
"method": "PUT",
"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": "{\"enabled\": \"false\"}"
},
"url": {
"raw": "{{controller_host}}/controller/alerting/rest/v1/applications/{{a:application}}/health-rules/{{i:healthrule_id}}/configuration",
"host": [
"{{controller_host}}"
],
"path": ["controller","alerting","rest","v1","applications","{{application}}","health-rules","{{healthrule_id}}","configuration"],
"query": []
},
"description": "Provide an application (-a) and a health rule id (-i) as parameters."
}
},{
"name": "Enable a healthrule.",
"request": {
"method": "PUT",
"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": "{\"enabled\": \"true\"}"
},
"url": {
"raw": "{{controller_host}}/controller/alerting/rest/v1/applications/{{a:application}}/health-rules/{{i:healthrule_id}}/configuration",
"host": [
"{{controller_host}}"
],
"path": ["controller","alerting","rest","v1","applications","{{application}}","health-rules","{{healthrule_id}}","configuration"],
"query": []
},
"description": "Provide an application (-a) and a health rule id (-i) as parameters."
}
},{
"name": "Get a healthrule.",
"request": {
"method": "GET",
Expand Down Expand Up @@ -1699,11 +1759,11 @@
"raw": ""
},
"url": {
"raw": "{{controller_host}}/controller/healthrules/{{a:application}}/",
"raw": "{{controller_host}}/controller/alerting/rest/v1/applications/{{a:application}}/health-rules",
"host": [
"{{controller_host}}"
],
"path": ["controller","healthrules","{{application}}",""],
"path": ["controller","alerting","rest","v1","applications","{{application}}","health-rules"],
"query": []
},
"description": "Provide an application (-a) as parameter"
Expand Down
Binary file added recipes/.DS_Store
Binary file not shown.
23 changes: 23 additions & 0 deletions recipes/healthrule_disablebyname.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash
# {
# "enabled": true,
# "id": 35428,
# "name": "CPU utilization is too high"
# }

ENVIRONMENT=$1
APPLICATION_ID=$2
HR_NAME=$3

echo "${ENVIRONMENT} ---- ${APPLICATION_ID} ----- ${HR_NAME} -------"
# Get a list of healthrules that match the grep argument
# Format is [ID] [Name]
# 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).
# This way they get filtered out before we search on the HR name.
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}' - )

for HR in $HEALTHRULES
do
echo "Disable HR ${HR}"
../act.sh -E ${ENVIRONMENT} healthrule disable -a ${APPLICATION_ID} -i ${HR}
done;
23 changes: 23 additions & 0 deletions recipes/healthrule_enablebyname.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash
# {
# "enabled": true,
# "id": 35428,
# "name": "CPU utilization is too high"
# }

ENVIRONMENT=$1
APPLICATION_ID=$2
HR_NAME=$3

echo "${ENVIRONMENT} ---- ${APPLICATION_ID} ----- ${HR_NAME} -------"
# Get a list of healthrules that match the grep argument
# Format is [ID] [Name]
# 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).
# This way they get filtered out before we search on the HR name.
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}' - )

for HR in $HEALTHRULES
do
echo "Enable HR ${HR}"
../act.sh -E ${ENVIRONMENT} healthrule enable -a ${APPLICATION_ID} -i ${HR}
done;

0 comments on commit ad9bd4e

Please sign in to comment.