Last active
March 17, 2020 08:22
-
-
Save soyo42/ead834d6c164f2508e2ddea87ce9644e to your computer and use it in GitHub Desktop.
spring-boot service inspection (parallel)
This file contains hidden or 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
Inspect spring-boot services (parallel) - reading their /info |
This file contains hidden or 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
EMPH="$(echo -en '\e[37;1m')" | |
NOC="$(echo -en '\e[0m')" | |
function getSafely() { | |
response="$(curl --write-out "\n%{http_code}" "$1" -m 5 2>/dev/null)" | |
status="$(echo "${response}" | tail -n 1)" | |
#echo "${status}" >&2 | |
#echo "${response}" | |
if [[ "${status}" =~ ^2[0-9]{2}$ ]]; then | |
echo "${response}" | sed '$d' | |
else | |
echo "HTTP ${status}" >&2 | |
fi | |
} | |
function digBuildInfo() { | |
if [ ! -t 0 ]; then | |
#cat | |
jq -r "(\"${EMPH}\" + .build.artifact + \":\" + .build.version + \" \" + .version + \"${NOC}\")" | |
fi | |
} | |
function digHealthInfo() { | |
if [ ! -t 0 ]; then | |
#cat | |
jq -r "(\"${EMPH}\" + .status + \"${NOC}\")" | |
fi | |
} | |
function dumpError() { | |
while read -e i; do echo -en "\e[41;1m! $i\e[0m "; done | |
} |
This file contains hidden or 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
#!/bin/bash | |
if [ -z "$1" ]; then | |
#echo "usage:: $0 <dataflow files, e.g.: IT*xml>" | |
echo "usage:: $0 <land project config, e.g.: application.yml>" | |
echo "usage:: $0 - # to read application.yml from stdin" | |
exit 1 | |
fi | |
SCRIPT_HOME="$(dirname "$(readlink -f "$0")")" | |
source ${SCRIPT_HOME}/.util | |
# for i in "$@"; do | |
# echo $i | |
# echo 'cat //service/@api' | xmllint --nonet --shell $i | |
# done \ | |
# | sed -En 's/^\s*api="(http[^"]{5,})".*$/\1/ p' \ | |
# | sed -E -e 's~/api/?~~' -e 's~http:~https:~' -e 's~/graphql/?~~' \ | |
if [[ "$1" != '-' ]]; then | |
application_yml="$1" | |
fi | |
cat ${application_yml} | yq -r '.client as $clients | $clients | keys[] | $clients[.].url' \ | |
| sort -u \ | |
| ( while read j; do | |
( | |
build="$(getSafely "${j}/info" 2> >(dumpError) 1> >(digBuildInfo))" | |
status="$(getSafely "${j}/health" 2> >(dumpError) 1> >(digHealthInfo))" | |
# fallback to actuator | |
if echo "${status}" | grep '!' > /dev/null; then | |
build="$(getSafely "${j}/actuator/info" 2> >(dumpError) 1> >(digBuildInfo))" | |
status="$(getSafely "${j}/actuator/health" 2> >(dumpError) 1> >(digHealthInfo))" | |
fi | |
echo "status= ${status} $j --> ${build}" | |
)& | |
done | |
wait | |
echo -e '\e[2m--done--\e[0m' | |
) | |
This file contains hidden or 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
#!/bin/bash | |
SCRIPT_HOME="$(dirname "$(readlink -f "$0")")" | |
source ${SCRIPT_HOME}/.util | |
key=${0##*_} | |
echo "key: ${key}" | |
lands=( | |
#'fer-le-nz' | |
'fbm-le-se' | |
'fbm-le-lv' | |
'fbm-le-dk' | |
'myaccount' | |
) | |
function doInspect() { | |
build="$(getSafely "${1}/info" 2> >(dumpError) 1> >(digBuildInfo))" | |
status="$(getSafely "${1}/health" 2> >(dumpError) 1> >(digHealthInfo))" | |
# fallback to actuator | |
if echo "${status}" | grep '!' > /dev/null; then | |
build="$(getSafely "${1}/actuator/info" 2> >(dumpError) 1> >(digBuildInfo))" | |
status="$(getSafely "${1}/actuator/health" 2> >(dumpError) 1> >(digHealthInfo))" | |
fi | |
echo -e "\e[37;2mstatus:\e[0m ${status} $1 \e[37;2m-->\e[0m ${build}" | |
} | |
for i in "${lands[@]}"; do | |
echo -e "\e[37;2mLAND:\e[0m $i" | |
j="https://process-${i}.${key}.ferratum.com" | |
doInspect "$j" & | |
j="https://process-${i}-manager.${key}.ferratum.com" | |
doInspect "$j" & | |
done | |
wait | |
echo -e '\e[2m--done--\e[0m' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment