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

Merge branch '6435-check-onehost' into 'master'

detect failed and unknown vms

See merge request !105
parents 62963a2c 56f550a4
No related branches found
No related tags found
1 merge request!105detect failed and unknown vms
check_onevm 100644 → 100755
...@@ -3,8 +3,7 @@ ...@@ -3,8 +3,7 @@
# #
# Check ONEVM # Check ONEVM
# show virtual machines # show virtual machines
# ## requirements:
# requirements:
# - sudo onevm # - sudo onevm
# #
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
...@@ -57,7 +56,10 @@ v$self_APPVERSION ...@@ -57,7 +56,10 @@ v$self_APPVERSION
Licence: GNU GPL 3 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: SYNTAX:
$(basename $0) $(basename $0)
...@@ -98,7 +100,7 @@ cmdout=$( sudo onevm list --csv 2>&1 ) ...@@ -98,7 +100,7 @@ cmdout=$( sudo onevm list --csv 2>&1 )
if ! grep "ID,USER" <<< "$cmdout" >/dev/null; then if ! grep "ID,USER" <<< "$cmdout" >/dev/null; then
ph.setStatus "unknown" ph.setStatus "unknown"
echo "UNKNOWN: sudo onehost failed." echo "UNKNOWN: sudo onevm failed."
echo "$cmdout" echo "$cmdout"
ph.exit ph.exit
fi fi
...@@ -111,17 +113,31 @@ csvdata=$( echo "$cmdout" | sed -n '2,$p' ) ...@@ -111,17 +113,31 @@ csvdata=$( echo "$cmdout" | sed -n '2,$p' )
out="" out=""
typeset -i iTotal; iTotal=$( echo "$csvdata" | wc -l ) typeset -i iTotal; iTotal=$( echo "$csvdata" | wc -l )
typeset -i iRunning; iRunning=$( echo "$csvdata" | grep -c ",runn," ) 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 "total" "${iTotal}"
ph.perfadd "running" "${iRunning}" 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 if [ $iOther -ne 0 ]; then
ps.setStatus "warning" ps.setStatus "warning"
out+="WARNING: There is a VM that has another status than [running]." out+="WARNING: There is a VM that has another status than [running]."
fi fi
if [ $iFail -ne 0 ]; then
ps.setStatus "critical"
out+="ERROR: a vm with status [Failed] was found."
fi
out+=$( out+=$(
echo '>>>>>> By state' echo '>>>>>> By state'
grep "^# STAT:" "$0" | while read -r line 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