Skip to content
Snippets Groups Projects

onevm: add info if no vm exists

Merged Hahn Axel (hahn) requested to merge 6435-check-onehost into master
1 file
+ 47
44
Compare changes
  • Side-by-side
  • Inline
+ 47
44
@@ -128,51 +128,54 @@ ph.perfadd "fail" "${iFail}"
ph.perfadd "unknown" "${iUnknown}"
ph.perfadd "other" "${iOther}"
if [ $iUnknown -ne 0 ]; then
ph.setStatus "warning"
out+="WARNING: a vm with status [Unknown] was found.${NL}"
fi
if [ $iOther -ne 0 ]; then
ph.setStatus "warning"
out+="WARNING: There is a VM that has another status than [running].${NL}"
fi
if [ $iFail -ne 0 ]; then
ph.setStatus "critical"
out+="ERROR: a vm with status [Failed] was found.${NL}"
fi
out+=$(
echo '>>>>>> By state'
grep "^# STAT:" "$0" | while read -r line
do
IFS=':' read -r prefix statusS statusL descr <<<"$line"
data=$( grep ",${statusS}," <<< "$csvdata" )
typeset -i count; count=$( wc -l <<< "$data" )
if [ -n "$data" ]; then
echo "--- $statusL ($statusS): $count"
echo "$descr"
if [ $showData -ne 0 ] || [ "${statusS}" != "runn" ]; then
echo "$data"
if [ $iTotal -gt 0 ]; then
if [ $iUnknown -ne 0 ]; then
ph.setStatus "warning"
out+="WARNING: a vm with status [Unknown] was found.${NL}"
fi
if [ $iOther -ne 0 ]; then
ph.setStatus "warning"
out+="WARNING: There is a VM that has another status than [running].${NL}"
fi
if [ $iFail -ne 0 ]; then
ph.setStatus "critical"
out+="ERROR: a vm with status [Failed] was found.${NL}"
fi
out+=$(
echo '>>>>>> By state'
grep "^# STAT:" "$0" | while read -r line
do
IFS=':' read -r prefix statusS statusL descr <<<"$line"
data=$( grep ",${statusS}," <<< "$csvdata" )
typeset -i count; count=$( wc -l <<< "$data" )
if [ -n "$data" ]; then
echo "--- $statusL ($statusS): $count"
echo "$descr"
if [ $showData -ne 0 ] || [ "${statusS}" != "runn" ]; then
echo "$data"
fi
fi
fi
done
echo
)
out+=$(
echo
echo '>>>>>> By host:'
for onehost in $( cut -f 8 -d ',' <<< "$csvdata" | sort -u )
do
echo -n "--- $onehost: "
grep -c ",${onehost}," <<< "$csvdata"
test $showData -ne 0 && grep ",${onehost}," <<< "$csvdata" | nl
done
echo
)
done
echo
)
out+=$(
echo
echo '>>>>>> By host:'
for onehost in $( cut -f 8 -d ',' <<< "$csvdata" | sort -u )
do
echo -n "--- $onehost: "
grep -c ",${onehost}," <<< "$csvdata"
test $showData -ne 0 && grep ",${onehost}," <<< "$csvdata" | nl
done
echo
)
else
out+="Info: no vm was created yet."
fi
ph.status "OpenNebula VMs - Total: $iTotal .. running: $iRunning, Fail: $iFail, unknown: $iUnknown .. other: $iOther"
echo "$out"
Loading