Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
icinga-checks
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
IML Open Source
icinga-checks
Commits
2c14a978
Commit
2c14a978
authored
1 year ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
add check check_onehost
parent
8fb66b23
No related branches found
No related tags found
1 merge request
!99
6435 check onehost
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
check_onehost
+107
-0
107 additions, 0 deletions
check_onehost
with
107 additions
and
0 deletions
check_onehost
0 → 100644
+
107
−
0
View file @
2c14a978
#!/bin/bash
# ======================================================================
#
# Check ONEHOST
#
# requirements:
# - sudo onehost
#
# ----------------------------------------------------------------------
# 2023-06-09 v1.0 <axel.hahn@unibe.ch> initial version
# ======================================================================
.
$(
dirname
$0
)
/inc_pluginfunctions
self_APPNAME
=
$(
basename
$0
|
tr
[
:lower:]
[
:upper:]
)
self_APPVERSION
=
1.0
# ----------------------------------------------------------------------
# functions
# ----------------------------------------------------------------------
function
showHelp
(){
cat
<<
EOF
______________________________________________________________________
$self_APPNAME
v
$self_APPVERSION
(c) Institute for Medical Education - University of Bern
Licence: GNU GPL 3
______________________________________________________________________
show count of hosts in OpenNebula and warn if a host is down.
SYNTAX:
$(
basename
$0
)
[ -w value -c value -h ]
-w VALUE cpu usage warning level (default: 1)
-c VALUE cpu usage critical level (default: 2)
-h or --help show this help.
PARAMETERS:
None.
EXAMPLE:
$(
basename
$0
)
-c 1 set to critical if the 1st host is off.
EOF
}
# ----------------------------------------------------------------------
# MAIN
# ----------------------------------------------------------------------
# --- check required tools
ph.require onehost
# --- check param -h
case
"
$1
"
in
"--help"
|
"-h"
)
showHelp
exit
0
;;
*
)
esac
# --- set optional limits
typeset
-i
iWarnLimit
=
$(
ph.getValueWithParam 1 w
"
$@
"
)
typeset
-i
iCriticalLimit
=
$(
ph.getValueWithParam 2 c
"
$@
"
)
# --- get data
cmdout
=
$(
onehost list
--csv
2>&1
)
if
!
grep
"ID,NAME"
<<<
"
$cmdout
"
>
/dev/null
;
then
ph.setStatus
"unknown"
echo
"
$cmdout
"
ph.exit
fi
# header=$( head -1 <<< "$cmdout" )
csvdata
=
$(
echo
"
$cmdout
"
|
sed
-n
'2,$p'
)
# --- get result
out
=
""
typeset
-i
iTotal
;
iTotal
=
$(
echo
"
$csvdata
"
|
wc
-l
)
typeset
-i
iOn
;
iOn
=
$(
echo
"
$csvdata
"
|
grep
-c
"on$"
)
typeset
-i
iOther
;
iOther
=
$iTotal
-
$iOn
ph.perfadd
"total"
"
${
iTotal
}
"
ph.perfadd
"on"
"
${
iOn
}
"
ph.perfadd
"other"
"
${
iOther
}
"
if
[
$iOther
-ge
$iCriticalLimit
]
;
then
out
=
"ERROR: not all hosts are up - count
$iOther
reached critical value
$iCriticalLimit
"
ph.setStatus
"critical"
elif
[
$iOther
-ge
$iWarnLimit
]
;
then
out
=
"ERROR: not all hosts are up - count
$iOther
reached critical value
$iWarnLimit
"
ph.setStatus
"warning"
fi
ph.status
"ONEHOST - Total:
$iTotal
.. on:
$iOn
.. other:
$iOther
"
echo
"
$cmdout
"
echo
"
$out
"
\ No newline at end of file
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