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

reduce output to use as service

parent f58801dd
No related branches found
No related tags found
1 merge request!5reduce output to use as service
......@@ -265,19 +265,19 @@ function icingaHostMustExist(){
_log "check if the host [${myHost}] exists on Icinga ..."
icingaHost get
if [ $? -ne 0 ]; then
http.getResponse
_echo $( http.getResponse )
if [ "$(http.getStatuscode)" = "000" ]; then
_elog "ERROR: Unable to reach the Icinga node. Stopping script current monitoring actions."
exit 1
fi
_elog "ERROR: host object for ${myHost} is not available on Icinga service (yet) - Status: $(http.getStatuscode)"
echo
echo "ABORTING"
echo
echo "To run checks ..."
echo "- you must create the host on director (check director-cli.sh --hr)"
echo "- the director must deploy the host to icinga daemon"
echo
_echo
_echo "ABORTING"
_echo
_echo "To run checks ..."
_echo "- you must create the host on director (check director-cli.sh --hr)"
_echo "- the director must deploy the host to icinga daemon"
_echo
rm -f "${dir_data}"/service__check* 2>/dev/null
exit 1
fi
......@@ -354,10 +354,10 @@ function processCheck(){
typeset -i local iTsEnd=`date +%s`
# outPerfdata=`grep '|' $_outfile | cut -f 2 -d '|'`
outPerfdata=`grep '|' $_outfile | rev | cut -f 1 -d '|' | rev`
echo
echo -------- check output:
cat $_outfile
echo
_echo
_echo -------- check output:
_echo $( cat $_outfile )
_echo
# echo -------- extracted performance data:
# echo $outPerfdata
# echo
......@@ -371,7 +371,7 @@ function processCheck(){
export CFGSTORAGE="${checkName}output"
outputAsText="$(cat $_outfile)"
outputAsJson="$(jq -nR --arg data """${outputAsText}""" '$data')"
# outputAsJson="$(jq -nR --arg data """${outputAsText}""" '$data')"
commandAsJson="$(jq -nR --arg data """${myFullscript} $myparams""" '$data')"
(
$ch --set check_source \"${myHost}\"
......@@ -390,7 +390,7 @@ function processCheck(){
slot="`_getName4Svcathost ${checkName} | sed 's# #%20#g'`"
_log "${_logPrefix} starting POST of data to monitoring server"
echo POST actions/process-check-result?service=${myHost}!${slot} "$data"
_echo POST actions/process-check-result?service=${myHost}!${slot} "$data"
_APIcall POST actions/process-check-result?service=${myHost}!${slot} "$data"
http.responseExport "$_response"
if [ ! -w "$_response" ]; then
......@@ -408,9 +408,9 @@ function processCheck(){
else
_log "${_logPrefix} WARNING: the check response was NOT sent to Icinga"
_rc=$_rc+1
echo
echo For Debugging:
$ch --show --json
_echo
_echo For Debugging:
_echo "$( $ch --show --json )"
fi
$ch --flush 2>/dev/null
......@@ -427,7 +427,7 @@ function processCheck(){
typeset -i local iCheckTime=$iCheckEnd-$iCheckStart
_log "${_logPrefix} finished after $iCheckTime sec with returncode $_rc"
test $_rc -eq 0 || (echo; echo " >>> Check ${checkName} was not OK. See Output block above!"; echo; echo)
test $_rc -eq 0 || (_echo; _echo " >>> Check ${checkName} was not OK. See Output block above!"; _echo; _echo)
}
# ----------------------------------------------------------------------
# help
......
......@@ -5,6 +5,8 @@
#
# ======================================================================
isInteractiveShell=false
test -n "$PS1" && isInteractiveShell=true
# ..................................................................
# write debug output to STDERR
......@@ -47,6 +49,12 @@
_log "$*"
}
# echo if there is an interactive shell
# params string(s) message to log
function _echo(){
test $isInteractiveShell && echo $*
}
# ======================================================================
#
# DATE AND TIME FUNCTIONS
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment