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
468c0a73
Commit
468c0a73
authored
1 year ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
fix line breaks of sent output
parent
b84b89a2
No related branches found
No related tags found
1 merge request
!30
icinga client: fix line breaks of sent output
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
icinga-cli.sh
+18
-6
18 additions, 6 deletions
icinga-cli.sh
with
18 additions
and
6 deletions
icinga-cli.sh
+
18
−
6
View file @
468c0a73
...
...
@@ -21,6 +21,7 @@
# 2023-02-17 v0.14 ah add hostnamme into CFGSTORAGE
# 2023-02-17 v0.15 ah check inc_getconfig.sh exists and hostname -f has a value
# 2023-11-01 v0.16 ah generate json with "jo"
# 2023-11-02 v0.17 ah generate json with "jo"
# ======================================================================
...
...
@@ -313,6 +314,8 @@ function processCheck(){
_log
"
${
_logPrefix
}
INFO: every
${
checkInterval
}
sec:
${
checkCommand
}
"
local
_outfile
=
${
dir_data
}
/service__check__
${
checkName
}
__output.txt
local
_output
local
_FoundErrors
local
_response
=
${
dir_data
}
/service__check__
${
checkName
}
__icinga_response.txt
typeset
-i
local
_rc
=
0
...
...
@@ -361,12 +364,14 @@ function processCheck(){
_elog
"
${
_logPrefix
}
$(
ls
-ld
${
dir_data
}
$_outfile
)
"
exit
1
fi
test
$rc
-gt
0
&&
_FoundErrors+
=
"Exitcode of check is
$rc
(greater zero).
\n
"
typeset
-i
local
iTsEnd
=
`
date
+%s
`
# outPerfdata=`grep '|' $_outfile | cut -f 2 -d '|'`
outPerfdata
=
`
grep
'|'
$_outfile
| rev |
cut
-f
1
-d
'|'
| rev
`
_output
=
"
$(
cat
"
$_outfile
"
)
"
_echo
_echo
--------
check output:
_echo
$(
cat
"
$_outfile
"
)
_echo
"
$_output
"
iPipes
=
$(
grep
-o
"|"
<
"
$_outfile
"
|
wc
-l
)
_echo
"Pipe chars:
$iPipes
"
...
...
@@ -397,7 +402,7 @@ function processCheck(){
commandAsJson
=
"
$(
jq
-nR
--arg
data
"""
${
myFullscript
}
$myparams
"""
'$data'
)
"
outAsJson
=
"
$(
jq
-nR
--arg
data
"""
${
_output
}
"""
'$data'
)
"
local
JSONPARAMS
=
"
check_source=
${
MY_NAME
}
...
...
@@ -407,9 +412,8 @@ function processCheck(){
execution_start=
$iTsStart
execution_end=
$iTsEnd
performance_data="
\"
${
outPerfdata
}
\"
"
plugin_output="
\"
$(
cat
"
${
_outfile
}
"
)
\"
"
"
plugin_output=
$outAsJson
"
data
=
$(
eval
jo
-p
-d
.
$JSONPARAMS
)
...
...
@@ -434,6 +438,7 @@ function processCheck(){
else
_elog
"
${
_logPrefix
}
rc=
$rc
- WARNING:
$(
http.getStatuscode
)
the check response was NOT sent to Icinga"
_rc
=
$_rc
+1
_FoundErrors+
=
"Response was not sent to Icinga."
_echo
_echo For Debugging:
_echo
"
$data
"
...
...
@@ -453,7 +458,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
"
ERRORS: [
${
checkName
}
]
$_FoundErrors
"
;
_echo
;
_echo
)
}
# ----------------------------------------------------------------------
# help
...
...
@@ -546,6 +551,13 @@ function showVersion(){
.
"
$(
dirname
$0
)
/inc_functions.sh"
if
[
"
$1
"
=
"--version"
]
||
[
"
$1
"
=
"-v"
]
;
then
echo
"
$(
basename
$0
)
v
$_version
"
echo
"
$_license
..
$_copyright
"
exit
0
fi
_echo
"
______________________________________________________________________________________
...
...
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