Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
icinga-passive-client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Open Source
icinga-passive-client
Commits
9907f6f4
Commit
9907f6f4
authored
3 years ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
reduce output to use as service
parent
f58801dd
No related branches found
No related tags found
1 merge request
!5
reduce output to use as service
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
icinga-cli.sh
+18
-18
18 additions, 18 deletions
icinga-cli.sh
inc_functions.sh
+8
-0
8 additions, 0 deletions
inc_functions.sh
with
26 additions
and
18 deletions
icinga-cli.sh
+
18
−
18
View file @
9907f6f4
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
inc_functions.sh
+
8
−
0
View file @
9907f6f4
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment