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
GitLab 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
Show 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(){
...
@@ -265,19 +265,19 @@ function icingaHostMustExist(){
_log
"check if the host [
${
myHost
}
] exists on Icinga ..."
_log
"check if the host [
${
myHost
}
] exists on Icinga ..."
icingaHost get
icingaHost get
if
[
$?
-ne
0
]
;
then
if
[
$?
-ne
0
]
;
then
http.getResponse
_echo
$(
http.getResponse
)
if
[
"
$(
http.getStatuscode
)
"
=
"000"
]
;
then
if
[
"
$(
http.getStatuscode
)
"
=
"000"
]
;
then
_elog
"ERROR: Unable to reach the Icinga node. Stopping script current monitoring actions."
_elog
"ERROR: Unable to reach the Icinga node. Stopping script current monitoring actions."
exit
1
exit
1
fi
fi
_elog
"ERROR: host object for
${
myHost
}
is not available on Icinga service (yet) - Status:
$(
http.getStatuscode
)
"
_elog
"ERROR: host object for
${
myHost
}
is not available on Icinga service (yet) - Status:
$(
http.getStatuscode
)
"
echo
_
echo
echo
"ABORTING"
_
echo
"ABORTING"
echo
_
echo
echo
"To run checks ..."
_
echo
"To run checks ..."
echo
"- you must create the host on director (check director-cli.sh --hr)"
_
echo
"- you must create the host on director (check director-cli.sh --hr)"
echo
"- the director must deploy the host to icinga daemon"
_
echo
"- the director must deploy the host to icinga daemon"
echo
_
echo
rm
-f
"
${
dir_data
}
"
/service__check
*
2>/dev/null
rm
-f
"
${
dir_data
}
"
/service__check
*
2>/dev/null
exit
1
exit
1
fi
fi
...
@@ -354,10 +354,10 @@ function processCheck(){
...
@@ -354,10 +354,10 @@ function processCheck(){
typeset
-i
local
iTsEnd
=
`
date
+%s
`
typeset
-i
local
iTsEnd
=
`
date
+%s
`
# outPerfdata=`grep '|' $_outfile | cut -f 2 -d '|'`
# outPerfdata=`grep '|' $_outfile | cut -f 2 -d '|'`
outPerfdata
=
`
grep
'|'
$_outfile
| rev |
cut
-f
1
-d
'|'
| rev
`
outPerfdata
=
`
grep
'|'
$_outfile
| rev |
cut
-f
1
-d
'|'
| rev
`
echo
_
echo
echo
--------
check output:
_
echo
--------
check output:
cat
$_outfile
_echo
$(
cat
$_outfile
)
echo
_
echo
# echo -------- extracted performance data:
# echo -------- extracted performance data:
# echo $outPerfdata
# echo $outPerfdata
# echo
# echo
...
@@ -371,7 +371,7 @@ function processCheck(){
...
@@ -371,7 +371,7 @@ function processCheck(){
export
CFGSTORAGE
=
"
${
checkName
}
output"
export
CFGSTORAGE
=
"
${
checkName
}
output"
outputAsText
=
"
$(
cat
$_outfile
)
"
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'
)
"
commandAsJson
=
"
$(
jq
-nR
--arg
data
"""
${
myFullscript
}
$myparams
"""
'$data'
)
"
(
(
$ch
--set
check_source
\"
${
myHost
}
\"
$ch
--set
check_source
\"
${
myHost
}
\"
...
@@ -390,7 +390,7 @@ function processCheck(){
...
@@ -390,7 +390,7 @@ function processCheck(){
slot
=
"
`
_getName4Svcathost
${
checkName
}
|
sed
's# #%20#g'
`
"
slot
=
"
`
_getName4Svcathost
${
checkName
}
|
sed
's# #%20#g'
`
"
_log
"
${
_logPrefix
}
starting POST of data to monitoring server"
_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
"
_APIcall POST actions/process-check-result?service
=
${
myHost
}
!
${
slot
}
"
$data
"
http.responseExport
"
$_response
"
http.responseExport
"
$_response
"
if
[
!
-w
"
$_response
"
]
;
then
if
[
!
-w
"
$_response
"
]
;
then
...
@@ -408,9 +408,9 @@ function processCheck(){
...
@@ -408,9 +408,9 @@ function processCheck(){
else
else
_log
"
${
_logPrefix
}
WARNING: the check response was NOT sent to Icinga"
_log
"
${
_logPrefix
}
WARNING: the check response was NOT sent to Icinga"
_rc
=
$_rc
+1
_rc
=
$_rc
+1
echo
_
echo
echo
For Debugging:
_
echo For Debugging:
$ch
--show
--json
_echo
"
$(
$ch
--show
--json
)
"
fi
fi
$ch
--flush
2>/dev/null
$ch
--flush
2>/dev/null
...
@@ -427,7 +427,7 @@ function processCheck(){
...
@@ -427,7 +427,7 @@ function processCheck(){
typeset
-i
local
iCheckTime
=
$iCheckEnd
-
$iCheckStart
typeset
-i
local
iCheckTime
=
$iCheckEnd
-
$iCheckStart
_log
"
${
_logPrefix
}
finished after
$iCheckTime
sec with returncode
$_rc
"
_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
# help
...
...
This diff is collapsed.
Click to expand it.
inc_functions.sh
+
8
−
0
View file @
9907f6f4
...
@@ -5,6 +5,8 @@
...
@@ -5,6 +5,8 @@
#
#
# ======================================================================
# ======================================================================
isInteractiveShell
=
false
test
-n
"
$PS1
"
&&
isInteractiveShell
=
true
# ..................................................................
# ..................................................................
# write debug output to STDERR
# write debug output to STDERR
...
@@ -47,6 +49,12 @@
...
@@ -47,6 +49,12 @@
_log
"
$*
"
_log
"
$*
"
}
}
# echo if there is an interactive shell
# params string(s) message to log
function
_echo
(){
test
$isInteractiveShell
&&
echo
$*
}
# ======================================================================
# ======================================================================
#
#
# DATE AND TIME FUNCTIONS
# 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