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

onevm: add info if no vm exists

parent 4ca2c562
Branches
No related tags found
1 merge request!115onevm: add info if no vm exists
......@@ -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"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment