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

detect failed and unknown vms

parent cb615a66
No related branches found
No related tags found
1 merge request!105detect failed and unknown vms
check_onevm 100644 → 100755
......@@ -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 "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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment