Skip to content
Snippets Groups Projects

detect failed and unknown vms

Merged Hahn Axel (hahn) requested to merge 6435-check-onehost into master
1 file
+ 22
6
Compare changes
  • Side-by-side
  • Inline
check_onevm 100644 → 100755
+ 22
6
@@ -3,8 +3,7 @@
#
# Check ONEVM
# show virtual machines
#
# requirements:
## requirements:
# - sudo onevm
#
# ----------------------------------------------------------------------
@@ -57,7 +56,10 @@ v$self_APPVERSION
Licence: GNU GPL 3
______________________________________________________________________
show count of vms in OpenNebula
Show count of vms in OpenNebula - listed by state and by host.
It will go to warning if a non running state was found.
It will go to critical if a vm is on failure.
SYNTAX:
$(basename $0)
@@ -98,7 +100,7 @@ cmdout=$( sudo onevm list --csv 2>&1 )
if ! grep "ID,USER" <<< "$cmdout" >/dev/null; then
ph.setStatus "unknown"
echo "UNKNOWN: sudo onehost failed."
echo "UNKNOWN: sudo onevm failed."
echo "$cmdout"
ph.exit
fi
@@ -111,17 +113,31 @@ csvdata=$( echo "$cmdout" | sed -n '2,$p' )
out=""
typeset -i iTotal; iTotal=$( echo "$csvdata" | wc -l )
typeset -i iRunning; iRunning=$( echo "$csvdata" | grep -c ",runn," )
typeset -i iOther; iOther=$iTotal-$iRunning
typeset -i iFail; iFail=$( echo "$csvdata" | grep -c ",fail," )
typeset -i iUnknown; iUnknown=$( echo "$csvdata" | grep -c ",unkn," )
typeset -i iOther; iOther=$iTotal-$iRunning-$iFail-$iUnknown
ph.perfadd "total" "${iTotal}"
ph.perfadd "running" "${iRunning}"
ph.perfadd "other" "${iOther}"
ph.perfadd "fail" "${iFail}"
ph.perfadd "unknown" "${iUnknown}"
ph.perfadd "other" "${iOther}"
if [ $iUnknown -ne 0 ]; then
ps.setStatus "warning"
out+="WARNING: a vm with status [Unknown] was found."
fi
if [ $iOther -ne 0 ]; then
ps.setStatus "warning"
out+="WARNING: There is a VM that has another status than [running]."
fi
if [ $iFail -ne 0 ]; then
ps.setStatus "critical"
out+="ERROR: a vm with status [Failed] was found."
fi
out+=$(
echo '>>>>>> By state'
grep "^# STAT:" "$0" | while read -r line
Loading