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

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

onevm: add info if no vm exists

See merge request !115
parents 5aeb3c00 8fced3b7
No related branches found
No related tags found
1 merge request!115onevm: add info if no vm exists
...@@ -128,51 +128,54 @@ ph.perfadd "fail" "${iFail}" ...@@ -128,51 +128,54 @@ ph.perfadd "fail" "${iFail}"
ph.perfadd "unknown" "${iUnknown}" ph.perfadd "unknown" "${iUnknown}"
ph.perfadd "other" "${iOther}" ph.perfadd "other" "${iOther}"
if [ $iUnknown -ne 0 ]; then if [ $iTotal -gt 0 ]; then
ph.setStatus "warning" if [ $iUnknown -ne 0 ]; then
out+="WARNING: a vm with status [Unknown] was found.${NL}" ph.setStatus "warning"
fi out+="WARNING: a vm with status [Unknown] was found.${NL}"
fi
if [ $iOther -ne 0 ]; then
ph.setStatus "warning" if [ $iOther -ne 0 ]; then
out+="WARNING: There is a VM that has another status than [running].${NL}" ph.setStatus "warning"
fi out+="WARNING: There is a VM that has another status than [running].${NL}"
fi
if [ $iFail -ne 0 ]; then
ph.setStatus "critical" if [ $iFail -ne 0 ]; then
out+="ERROR: a vm with status [Failed] was found.${NL}" ph.setStatus "critical"
fi out+="ERROR: a vm with status [Failed] was found.${NL}"
fi
out+=$(
echo '>>>>>> By state' out+=$(
grep "^# STAT:" "$0" | while read -r line echo '>>>>>> By state'
do grep "^# STAT:" "$0" | while read -r line
IFS=':' read -r prefix statusS statusL descr <<<"$line" do
data=$( grep ",${statusS}," <<< "$csvdata" ) IFS=':' read -r prefix statusS statusL descr <<<"$line"
typeset -i count; count=$( wc -l <<< "$data" ) data=$( grep ",${statusS}," <<< "$csvdata" )
if [ -n "$data" ]; then typeset -i count; count=$( wc -l <<< "$data" )
echo "--- $statusL ($statusS): $count" if [ -n "$data" ]; then
echo "$descr" echo "--- $statusL ($statusS): $count"
if [ $showData -ne 0 ] || [ "${statusS}" != "runn" ]; then echo "$descr"
echo "$data" if [ $showData -ne 0 ] || [ "${statusS}" != "runn" ]; then
echo "$data"
fi
fi fi
fi done
done echo
echo )
)
out+=$(
out+=$( echo
echo echo '>>>>>> By host:'
echo '>>>>>> By host:' for onehost in $( cut -f 8 -d ',' <<< "$csvdata" | sort -u )
for onehost in $( cut -f 8 -d ',' <<< "$csvdata" | sort -u ) do
do echo -n "--- $onehost: "
echo -n "--- $onehost: " grep -c ",${onehost}," <<< "$csvdata"
grep -c ",${onehost}," <<< "$csvdata" test $showData -ne 0 && grep ",${onehost}," <<< "$csvdata" | nl
test $showData -ne 0 && grep ",${onehost}," <<< "$csvdata" | nl done
done echo
echo )
) else
out+="Info: no vm was created yet."
fi
ph.status "OpenNebula VMs - Total: $iTotal .. running: $iRunning, Fail: $iFail, unknown: $iUnknown .. other: $iOther" ph.status "OpenNebula VMs - Total: $iTotal .. running: $iRunning, Fail: $iFail, unknown: $iUnknown .. other: $iOther"
echo "$out" echo "$out"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment