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
7b067b74
Commit
7b067b74
authored
2 years ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
custom params per server
parent
380516a8
No related branches found
No related tags found
1 merge request
!24
custom params per server
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
director-cli.sh
+0
-3
0 additions, 3 deletions
director-cli.sh
icinga-cli.sh
+15
-14
15 additions, 14 deletions
icinga-cli.sh
inc_functions.sh
+2
-1
2 additions, 1 deletion
inc_functions.sh
with
17 additions
and
18 deletions
director-cli.sh
+
0
−
3
View file @
7b067b74
...
...
@@ -62,9 +62,6 @@ typeset cfg_dryrun=false
MY_IP
=
$(
_getIpFrontend |
head
-1
)
MY_ZONE
=
fi
IDC_host__cachefile
=
"
${
dir_data
}
/
${
MY_NAME
}
__host_at-director.txt"
IDC_service__cachefile
=
"
${
dir_data
}
/
${
MY_NAME
}
__all_defined_services__at-director.txt"
IDC_svcathost__cachefile
=
"
${
dir_data
}
/
${
MY_NAME
}
__services_on_host__at-director.txt"
# ch="`dirname $0`/inc/confighandler.sh"
ch
=
"./inc/confighandler.sh"
}
...
...
This diff is collapsed.
Click to expand it.
icinga-cli.sh
+
15
−
14
View file @
7b067b74
...
...
@@ -17,6 +17,7 @@
# 2022-03-14 v0.10 ah less output and add _elog to run as a service
# 2022-07-08 v0.11 ah check pipes in output and performance data
# 2023-01-30 v0.12 ah remove pipes with sed remove the pipe before performancedata
# 2023-02-13 v0.13 ah rename myHost to MY_NAME (like in director_cli)
# ======================================================================
...
...
@@ -40,7 +41,7 @@ typeset -i debug=0
logfile
=
"
${
dir_logs
}
/execution.log"
ch
=
"
$(
dirname
$0
)
/inc/confighandler.sh"
myHost
=
$(
hostname
-f
)
MY_NAME
=
$(
hostname
-f
)
# for loop mode only: max. random sleep time
typeset
-i
sleeptime
=
30
...
...
@@ -95,10 +96,10 @@ function _getFileSnapshot(){
function
loopChecks
(){
# TODO-MEMORY-CHECK
# echo ${
myHost
} | egrep "^(kvm4|icinga)"
# echo ${
myHost
} | egrep "^(monitortest)"
# echo ${
MY_NAME
} | egrep "^(kvm4|icinga)"
# echo ${
MY_NAME
} | egrep "^(monitortest)"
# if [ $? -ne 0 ]; then
# echo "HARD EXIT - DO NOT EXECUTE ANY CHECK ON $
myHost
"
# echo "HARD EXIT - DO NOT EXECUTE ANY CHECK ON $
MY_NAME
"
# exit 1
# fi
...
...
@@ -198,7 +199,7 @@ function processAllChecks(){
# checkInterval
# param string full path of a config file
#
function
_parseCheckConfig
(){
function
UNUSED
_parseCheckConfig
(){
local
_myconfig
=
"
$1
"
if
[
!
-r
"
$_myconfig
"
]
;
then
...
...
@@ -220,9 +221,9 @@ function _parseCheckConfig(){
# actions for icinga host
# param string action; "get" only
function
icingaHost
(){
local
_logPrefix
=
"
${
myHost
}
:: API |"
local
_apiRequest
=
objects/hosts/
${
myHost
}
local
_localCache
=
${
dir_data
}
/host_
${
myHost
}
_deployed-at-icinga.txt
local
_logPrefix
=
"
${
MY_NAME
}
:: API |"
local
_apiRequest
=
objects/hosts/
${
MY_NAME
}
local
_localCache
=
${
dir_data
}
/host_
${
MY_NAME
}
_deployed-at-icinga.txt
typeset
-i
local
_iRefreshCache
=
120
local
sAction
=
$1
...
...
@@ -260,10 +261,10 @@ function icingaHost(){
# for check on the beginning of the script:
# execute a check only if the host exists on icinga2
# global string
myHost
# global string
MY_NAME
# global string dir_data
function
icingaHostMustExist
(){
_log
"check if the host [
${
myHost
}
] exists on Icinga ..."
_log
"check if the host [
${
MY_NAME
}
] exists on Icinga ..."
icingaHost get
if
[
$?
-ne
0
]
;
then
_echo
$(
http.getResponse
)
...
...
@@ -271,7 +272,7 @@ function icingaHostMustExist(){
_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
)
"
_elog
"ERROR: host object for
${
MY_NAME
}
is not available on Icinga service (yet) - Status:
$(
http.getStatuscode
)
"
_echo
_echo
"ABORTING"
_echo
...
...
@@ -392,7 +393,7 @@ function processCheck(){
# outputAsJson="$(jq -nR --arg data """${outputAsText}""" '$data')"
commandAsJson
=
"
$(
jq
-nR
--arg
data
"""
${
myFullscript
}
$myparams
"""
'$data'
)
"
(
$ch
--set
check_source
\"
${
myHost
}
\"
$ch
--set
check_source
\"
${
MY_NAME
}
\"
$ch
--set
check_command
"
${
commandAsJson
}
"
$ch
--set
exit_status
$rc
# $ch --set plugin_output "${outputAsJson}"
...
...
@@ -408,8 +409,8 @@ 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
"
_APIcall POST actions/process-check-result?service
=
${
myHost
}
!
${
slot
}
"
$data
"
_echo POST actions/process-check-result?service
=
${
MY_NAME
}
!
${
slot
}
"
$data
"
_APIcall POST actions/process-check-result?service
=
${
MY_NAME
}
!
${
slot
}
"
$data
"
http.responseExport
"
$_response
"
if
[
!
-w
"
$_response
"
]
;
then
_elog
"
${
_logPrefix
}
ERROR: responsefile
$_response
is not writable."
...
...
This diff is collapsed.
Click to expand it.
inc_functions.sh
+
2
−
1
View file @
7b067b74
...
...
@@ -111,7 +111,8 @@
# max_check_attempts=3
checkName
=
$(
cat
"
$_myconfig
"
|
grep
^checkname
=
|
cut
-f
2
-d
"="
|
sed
's# #_#g'
)
checkCommand
=
$(
cat
"
$_myconfig
"
|
grep
^command
=
|
cut
-f
2
-d
"="
)
checkCommand
=
$(
cat
"
$_myconfig
"
|
grep
^command_
$MY_NAME
=
|
cut
-f
2
-d
"="
)
test
-z
"
$checkCommand
"
&&
checkCommand
=
$(
cat
"
$_myconfig
"
|
grep
^command
=
|
cut
-f
2
-d
"="
)
checkInterval
=
$(
cat
"
$_myconfig
"
|
grep
^interval
=
|
cut
-f
2
-d
"="
)
checkIcon
=
$(
cat
"
$_myconfig
"
|
grep
^icon
=
|
cut
-f
2
-d
"="
)
checkMaxAttempts
=
$(
cat
"
$_myconfig
"
|
grep
^max_check_attempts
=
|
cut
-f
2
-d
"="
)
...
...
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