-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Features/health rules only #38
Merged
Merged
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
92c2794
refactor app health rules (#27)
iogbole e962d68
Feature/containerHealthRules (#28)
iogbole b1330d8
Feature/disable node hr (#29)
iogbole b2e95d5
microservice health rules
iogbole 5dbd28b
Merge action-suppression and port-bugfix to develop from feature b;
AlexJov e128179
Add action suppression upload from file; Typos;
AlexJov f5be5fc
Add suppress action config;
AlexJov 1bfc989
Add actions folder and example file;
AlexJov ecc6ac0
Dash layout
iogbole 336ff65
Adding detele action suppression;
AlexJov def5434
Controller port as parameter takes precedence;
AlexJov cffd16c
Port controller;
AlexJov 90f13e3
Merge branch 'develop' of https://github.com/Appdynamics/ConfigMyApp …
AlexJov 308c94b
Update create and delete action suppression; Update config;
AlexJov 33fcad5
Merge branch 'develop' into features/suppress-action-files
AlexJov c8d6e75
Merge branch 'develop' of https://github.com/Appdynamics/ConfigMyApp …
AlexJov e421441
Action suppression bugfix missing functions and folders; Save uploade…
AlexJov d3136b0
Action suppression adding proxy; Fix empty proxy; Backup only uploade…
AlexJov 29c1ba7
Update action suppression help;
AlexJov c6f4781
Merge branch 'develop' of https://github.com/Appdynamics/ConfigMyApp …
AlexJov c920f16
Rename dir healthrules to health_rules;
AlexJov 853d630
Add modules dir; Add health rule update / delete sh;
AlexJov ddff3ac
Add health rule only and delete options;
AlexJov 7f6cc03
Update refs to HRs; Add debug echo;
AlexJov a876e58
Add delete health rule func; Remove debug from HR modules;
AlexJov 35ed039
Add health rule vars to docker env and k8s configMap;
AlexJov dd5496e
Remove health rule function from configMyApp; Update readme with argb…
AlexJov 212a931
Delete HR from comma separated list;
AlexJov 1e3ff7a
HR override, support previous version of env. var;
AlexJov f677851
Add git actions for health rules;
AlexJov 279f3ed
Update delete HR test case - delete multiple;
AlexJov 3064daa
Update folder name in test case;
AlexJov 3f18b6a
Add SIM HR to test case;
AlexJov 159e1ae
Test case update include sim flag;
AlexJov e049352
Remove feature branch from actions;
AlexJov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#!/bin/bash | ||
|
||
# 1. INPUT PARAMETERS | ||
_controller_url=${1} # hostname + /controller | ||
_user_credentials=${2} # ${username}:${password} | ||
|
||
_application_name=${3} | ||
_proxy_details=${4} | ||
|
||
_health_rules_delete=${5} | ||
|
||
# 2. FUNCTIONS | ||
function func_check_http_status() { | ||
local http_code=$1 | ||
local message_on_failure=$2 | ||
#echo "HTTP status code: $http_code" | ||
if [[ $http_code -lt 200 ]] || [[ $http_code -gt 299 ]]; then | ||
echo "${dt} ERROR "{$http_code: $message_on_failure}"" >> error.log | ||
echo "$http_code: $message_on_failure" | ||
func_cleanup | ||
exit 1 | ||
fi | ||
} | ||
|
||
function func_delete_health_rules(){ | ||
local appId=$1 | ||
local healthRulesToDelete="$2" | ||
|
||
# get all current health rules for application | ||
allHealthRules=$(curl -s --user ${_user_credentials} ${_controller_url}/alerting/rest/v1/applications/${appId}/health-rules ${_proxy_details}) | ||
|
||
echo $healthRulesToDelete | sed -n 1'p' | tr ',' '\n' | while read hrName; do | ||
echo "Deleting '$hrName' health rule..." | ||
|
||
# get health rule id (if exists) | ||
healthRuleId=$(jq --arg hrName "$hrName" '.[] | select(.name == $hrName) | .id' <<<$allHealthRules) | ||
|
||
# delete if health rule exists | ||
if [ ! -z "${healthRuleId// }" ]; then | ||
httpCode=$(curl -s -o /dev/null -w "%{http_code}" -X DELETE --user ${_user_credentials} ${_controller_url}/alerting/rest/v1/applications/${appId}/health-rules/${healthRuleId} ${_proxy_details}) | ||
func_check_http_status $httpCode "Error occured while deleting health rule '${hrName}'." | ||
echo "done" | ||
else | ||
echo "Health rule '$hrName' not found. No action performed." | ||
fi | ||
|
||
done | ||
} | ||
|
||
# 3. PREPARE | ||
# check if App exist | ||
allApplications=$(curl -s --user ${_user_credentials} ${_controller_url}/rest/applications?output=JSON $_proxy_details) | ||
|
||
applicationObject=$(jq --arg appName "$_application_name" '.[] | select(.name == $appName)' <<<$allApplications) | ||
|
||
if [ "$applicationObject" = "" ]; then | ||
func_check_http_status 404 "Application '"$_application_name"' not found. Aborting..." | ||
fi | ||
|
||
appId=$(jq '.id' <<<$applicationObject) | ||
|
||
#All conditions met.. | ||
|
||
# 4. EXECUTE | ||
func_delete_health_rules $appId "${_health_rules_delete}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
#!/bin/bash | ||
|
||
# 1. INPUT PARAMETERS | ||
_controller_url=${1} # hostname + /controller | ||
_user_credentials=${2} # ${username}:${password} | ||
|
||
_application_name=${3} | ||
_proxy_details=${4} | ||
|
||
_health_rules_overwrite=${5} | ||
_include_sim=${6} | ||
|
||
#init HR templates | ||
serverVizHealthRuleFile="./health_rules/ServerVisibility/*.json" | ||
applicationHealthRule="./health_rules/Application/*.json" | ||
|
||
# 2. FUNCTIONS | ||
function func_check_http_status() { | ||
local http_code=$1 | ||
local message_on_failure=$2 | ||
#echo "HTTP status code: $http_code" | ||
if [[ $http_code -lt 200 ]] || [[ $http_code -gt 299 ]]; then | ||
echo "${dt} ERROR "{$http_code: $message_on_failure}"" >> error.log | ||
echo "$http_code: $message_on_failure" | ||
exit 1 | ||
fi | ||
} | ||
|
||
function func_import_health_rules(){ | ||
local appId=$1 | ||
local folderPath=$2 | ||
|
||
# get all current health rules for application | ||
allHealthRules=$(curl -s --user ${_user_credentials} ${_controller_url}/alerting/rest/v1/applications/${appId}/health-rules ${_proxy_details}) | ||
|
||
for f in $folderPath; do | ||
echo "Processing $f health rule template" | ||
# get health rule name from json file | ||
healthRuleName=$(jq -r '.name' <$f) | ||
# use it to get health rule id (if exists) | ||
healthRuleId=$(jq --arg hrName "$healthRuleName" '.[] | select(.name == $hrName) | .id' <<<$allHealthRules) | ||
|
||
# create new if health rule id does not exist | ||
if [ "${healthRuleId}" == "" ]; then | ||
httpCode=$(curl -s -o /dev/null -w "%{http_code}" -X POST --user ${_user_credentials} ${_controller_url}/alerting/rest/v1/applications/${appId}/health-rules --header "Content-Type: application/json" --data "@${f}" ${_proxy_details}) | ||
func_check_http_status $httpCode "Error occured while importing health rule ${healthRuleName}." | ||
# overwrite existing health rule only if flag is true | ||
elif [ "${_health_rules_overwrite}" = true ]; then | ||
httpCode=$(curl -s -o /dev/null -w "%{http_code}" -X PUT --user ${_user_credentials} ${_controller_url}/alerting/rest/v1/applications/${appId}/health-rules/${healthRuleId} --header "Content-Type: application/json" --data "@${f}" ${_proxy_details}) | ||
func_check_http_status $httpCode "Error occured while importing server rule ${healthRuleName}." | ||
fi | ||
|
||
done | ||
} | ||
|
||
# 3. PREPARE | ||
# check if App exist | ||
allApplications=$(curl -s --user ${_user_credentials} ${_controller_url}/rest/applications?output=JSON $_proxy_details) | ||
|
||
applicationObject=$(jq --arg appName "$_application_name" '.[] | select(.name == $appName)' <<<$allApplications) | ||
|
||
if [ "$applicationObject" = "" ]; then | ||
func_check_http_status 404 "Application '"$_application_name"' not found. Aborting..." | ||
fi | ||
|
||
appId=$(jq '.id' <<<$applicationObject) | ||
|
||
#All conditions met.. | ||
|
||
# 4. EXECUTE | ||
|
||
# Server Visibility health rules | ||
if [ "${_include_sim}" = true ]; then | ||
echo "Creating Server Visibility Health Rules...Please wait" | ||
echo "" | ||
|
||
func_import_health_rules $appId "${serverVizHealthRuleFile}" | ||
fi | ||
|
||
# Application health rules | ||
echo "" | ||
echo "Creating ${_application_name} Health Rules..." | ||
sleep 1 | ||
|
||
func_import_health_rules $appId "${applicationHealthRule}" | ||
|
||
|
||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still, here it shows like the Health Rule does not exist although I imported it in the previous step (line 101) :/