From 4ca2c5623a3f8c199568b032ed3240d079872850 Mon Sep 17 00:00:00 2001 From: "Hahn Axel (hahn)" <axel.hahn@unibe.ch> Date: Thu, 15 Jun 2023 09:01:04 +0200 Subject: [PATCH] onevm: fix output if no vm is running --- check_onevm | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/check_onevm b/check_onevm index c41dd05..720959e 100755 --- a/check_onevm +++ b/check_onevm @@ -33,13 +33,14 @@ # STAT:done:Done:The VM is done. VMs in this state won’t be shown with onevm list but are kept in the database for accounting purposes. You can still get their information with the onevm show command. # ---------------------------------------------------------------------- # 2023-06-12 v1.0 <axel.hahn@unibe.ch> initial version +# 2023-06-15 v1.0 <axel.hahn@unibe.ch> fix output if no vm is running # ====================================================================== . $(dirname $0)/inc_pluginfunctions self_APPNAME=$( basename $0 | tr [:lower:] [:upper:] ) -self_APPVERSION=1.0 +self_APPVERSION=1.1 # new line NL=" @@ -115,10 +116,10 @@ csvdata=$( echo "$cmdout" | sed -n '2,$p' ) # --- get result out="" -typeset -i iTotal; iTotal=$( echo "$csvdata" | wc -l ) -typeset -i iRunning; iRunning=$( echo "$csvdata" | grep -c ",runn," ) -typeset -i iFail; iFail=$( echo "$csvdata" | grep -c ",fail," ) -typeset -i iUnknown; iUnknown=$( echo "$csvdata" | grep -c ",unkn," ) +typeset -i iTotal; iTotal=$( grep -c . <<< "$csvdata" ) +typeset -i iRunning; iRunning=$( grep -c ",runn," <<< "$csvdata" ) +typeset -i iFail; iFail=$( grep -c ",fail," <<< "$csvdata" ) +typeset -i iUnknown; iUnknown=$( grep -c ",unkn," <<< "$csvdata" ) typeset -i iOther; iOther=$iTotal-$iRunning-$iFail-$iUnknown ph.perfadd "total" "${iTotal}" -- GitLab