Skip to content
Snippets Groups Projects
Commit 7144be7c authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

abort on http 5xx error

parent 6770ec69
Branches
No related tags found
1 merge request!4abort on http 5xx error
......@@ -16,6 +16,7 @@
# ----------------------------------------------------------------------
# ah = axel.hahn@iml.unibe.ch
# 2022-02-16 v0.2 ah add --cfg param
# 2022-03-04 v0.3 ah abort on http 5xx error
# ======================================================================
tmpfile=/tmp/outcurl.tmp
......@@ -365,6 +366,10 @@ typeset cfg_dryrun=false
if [ ${_paramDryrun} = false ]; then
_wd ">>>>> $_paramAction $_paramObj [${_object_name}] >> $_sMethod $_sUrl $_jsondata"
http.makeRequest "$_sMethod" "$_sUrl" "$_jsondata"
if http.isServerError >/dev/null; then
echo "CRITICAL ERROR: Director API request failed with a server error $_sMethod $_sUrl"
exit 1
fi
if [ $_bShowResponse = true ]; then
http.getResponseHeader
http.getResponse
......
......@@ -13,11 +13,12 @@
# 2021-03-.. init
# 2022-01-11 v0.7 ah shellcheck
# 2022-02-16 v0.8 ah add --cfg param
# 2022-03-04 v0.9 ah abort on http 5xx error
# ======================================================================
_product="ICINGA PASSIVE CLIENT"
_version="0.8"
_version="0.9"
_license="GNU GPL 3.0"
_copyright='(c) 2020 Institute for Medical Education * University of Bern'
......@@ -248,6 +249,10 @@ function icingaHost(){
http.setCacheTtl $_iRefreshCache
http.setCacheFile $_localCache
http.makeRequest GET $_apiRequest
if http.isServerError >/dev/null; then
echo "CRITICAL ERROR: Icinga2 API request failed with a server error GET $_apiRequest"
exit 1
fi
# set return code of GET action
http.isOk >/dev/null
......
......@@ -232,6 +232,10 @@ function _getIpPrivate(){
function _APIcall(){
http.makeRequest "$1" "$2" "$3"
if http.isServerError >/dev/null; then
echo "CRITICAL ERROR: API request failed with a server error $1 $2"
exit 1
fi
http.getResponseHeader
http.getResponse
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment