Skip to content
Snippets Groups Projects
Commit 5d865639 authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

add detection for disabled hosts; update texts

parent 539fedc7
Branches
No related tags found
1 merge request!176check_onehost - add detection for disabled hosts; update texts
......@@ -10,12 +10,13 @@
# 2023-06-09 v1.0 <axel.hahn@unibe.ch> initial version
# 2023-06-12 v1.1 <axel.hahn@unibe.ch> show message if no sudo permissions on onehost command exist
# 2023-08-23 v1.2 <axel.hahn@unibe.ch> update help; show help without requirements
# 2023-09-15 v1.3 <axel.hahn@unibe.ch> add detection for disabled hosts; update texts
# ======================================================================
. $(dirname $0)/inc_pluginfunctions
self_APPVERSION=1.2
self_APPVERSION=1.3
# ----------------------------------------------------------------------
# functions
......@@ -26,13 +27,14 @@ function showHelp(){
cat <<EOF
$( ph.showImlHelpHeader )
Show count of hosts in OpenNebula and warn if a host is down.
Show count of hosts in OpenNebula and warn if a host is disabled or on error.
It switches to critical if more than a given critical level are not running.
SYNTAX:
$_self [ -w value -c value -h ]
-w VALUE cpu usage warning level (default: 1)
-c VALUE cpu usage critical level (default: 2)
-w VALUE warning level (default: 1)
-c VALUE critical level (default: 2)
-h or --help show this help.
PARAMETERS:
......@@ -83,22 +85,24 @@ csvdata=$( echo "$cmdout" | sed -n '2,$p' )
out=""
typeset -i iTotal; iTotal=$( echo "$csvdata" | wc -l )
typeset -i iOn; iOn=$( echo "$csvdata" | grep -c "on$" )
typeset -i iOther; iOther=$iTotal-$iOn
typeset -i iDis; iDis=$( echo "$csvdata" | grep -c "dsbl$" )
typeset -i iNotOn; iNotOn=$iTotal-$iOn
typeset -i iOther; iOther=$iTotal-$iOn-$iDis
ph.perfadd "total" "${iTotal}"
ph.perfadd "on" "${iOn}"
ph.perfadd "other" "${iOther}"
ph.perfadd "total" "${iTotal}"
ph.perfadd "on" "${iOn}"
ph.perfadd "disabled" "${iDis}"
ph.perfadd "other" "${iOther}"
if [ $iOther -ge $iCriticalLimit ]; then
out="ERROR: not all hosts are up - count $iOther reached critical value $iCriticalLimit"
if [ $iNotOn -ge $iCriticalLimit ]; then
out="ERROR: not all hosts are up - count $iNotOn 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"
elif [ $iNotOn -ge $iWarnLimit ]; then
out="WARNING: not all hosts are up - count $iNotOn reached warning value $iWarnLimit"
ph.setStatus "warning"
fi
ph.status "ONEHOST - Total: $iTotal .. on: $iOn .. other: $iOther"
ph.status "ONEHOST - Total: $iTotal .. on: $iOn .. disabled: $iDis ... other: $iOther"
echo "$cmdout"
echo "$out"
ph.exit
......@@ -23,7 +23,7 @@ icingaclient ALL=(ALL) NOPASSWD: /bin/onehost
______________________________________________________________________
CHECK_ONEHOST
v1.1
v1.3
(c) Institute for Medical Education - University of Bern
Licence: GNU GPL 3
......@@ -31,13 +31,14 @@ Licence: GNU GPL 3
https://os-docs.iml.unibe.ch/icinga-checks/Checks/check_onehost.html
______________________________________________________________________
show count of hosts in OpenNebula and warn if a host is down.
Show count of hosts in OpenNebula and warn if a host is disabled or on error.
It switches to critical if more than a given critical level are not running.
SYNTAX:
check_onehost [ -w value -c value -h ]
-w VALUE cpu usage warning level (default: 1)
-c VALUE cpu usage critical level (default: 2)
-w VALUE warning level (default: 1)
-c VALUE critical level (default: 2)
-h or --help show this help.
PARAMETERS:
......@@ -51,17 +52,17 @@ check_onehost -c 1 set to critical if the 1st host is off.
## Example
Without parameter
Without parameter we get a warning if the 1st host is disabled or on error.
``./check_onehost`` returns
```txt
/check_onehost
OK: ONEHOST - Total: 5 .. on: 5 .. other: 0
WARNING: ONEHOST - Total: 5 .. on: 4 .. disabled: 1 ... other: 0
ID,NAME,CLUSTER,TVM,ALLOCATED_CPU,ALLOCATED_MEM,STAT
4,kvm5.backend.one.intra,default,5,600 / 2400 (25%),13G / 503.1G (2%),on
3,kvm4.backend.one.intra,default,5,1100 / 2400 (45%),22G / 503.1G (4%),on
2,kvm3.backend.one.intra,default,8,1150 / 2400 (47%),20G / 251.1G (7%),on
1,kvm2.backend.one.intra,default,6,1000 / 2400 (41%),12G / 188.1G (6%),on
0,kvm1.backend.one.intra,default,8,1350 / 2400 (56%),18.5G / 188.1G (9%),on
|total=5;; on=5;; other=0;;
```
\ No newline at end of file
4,kvm5.example.com,default,11,1930 / 2400 (80%),76G / 503.1G (15%),dsbl
3,kvm4.example.com,default,2,400 / 2400 (16%),5G / 503.1G (0%),on
2,kvm3.example.com,default,9,1600 / 2400 (66%),55G / 251.1G (21%),on
1,kvm2.example.com,default,14,1770 / 2400 (73%),71.5G / 188.1G (38%),on
0,kvm1.example.com,default,16,2380 / 2400 (99%),75G / 188.1G (39%),on
WARNING: not all hosts are up - count 1 reached warning value 1
|total=5;; on=4;; disabled=1;; other=0;;
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment