diff --git a/plugins/virtualbox/virtualbox_cpu_kernel b/plugins/virtualbox/virtualbox_cpu_kernel index 5f4db938..d39db3fd 100755 --- a/plugins/virtualbox/virtualbox_cpu_kernel +++ b/plugins/virtualbox/virtualbox_cpu_kernel @@ -37,8 +37,8 @@ if [ "$1" = "config" ]; then echo 'graph_info This graph shows the percentage of processor time spent in kernel mode by the every single VM process.' echo 'graph_category Virtualization' echo 'graph_period second' - vboxmanage list vms | sed -r 's/^\"(.*)\" \{.*\}$/\1/' | while read VM_NAME; do - VM_NAME_PRINT=`echo -e "${VM_NAME}" | sed 's/[^A-Za-z0-9_]/_/g'` + vboxmanage list vms | sed -r 's/^\"(.*)\" \{.*\}$/\1/' | while read -r VM_NAME; do + VM_NAME_PRINT=$(echo -e "${VM_NAME}" | sed 's/[^A-Za-z0-9_]/_/g') echo "${VM_NAME_PRINT}_kernel.label ${VM_NAME}" done exit 0 @@ -47,8 +47,7 @@ fi vboxmanage metrics setup --period 5 --samples 3 sleep 5 -vboxmanage list vms | sed -r 's/^\"(.*)\" \{.*\}$/\1/' | while read VM_NAME; do - VM_NAME_PRINT=`echo -e "${VM_NAME}" | sed 's/[^A-Za-z0-9_]/_/g'` - vboxmanage metrics query "${VM_NAME}" CPU/Load/Kernel | grep -E "^${VM_NAME}" | sed -r 's/^.*([0-9]+\.[0-9]+)%/'''${VM_NAME_PRINT}'''_kernel.value \1/' +vboxmanage list vms | sed -r 's/^\"(.*)\" \{.*\}$/\1/' | while read -r VM_NAME; do +VM_NAME_PRINT=$(echo -e "${VM_NAME}" | sed 's/[^A-Za-z0-9_]/_/g') + vboxmanage metrics query "${VM_NAME}" CPU/Load/Kernel | grep -E "^${VM_NAME}" | sed -r 's/^.*([0-9]+\.[0-9]+)%/'"${VM_NAME_PRINT}"'_kernel.value \1/' done - diff --git a/plugins/virtualbox/virtualbox_cpu_user b/plugins/virtualbox/virtualbox_cpu_user index 8bd77674..33c1b469 100755 --- a/plugins/virtualbox/virtualbox_cpu_user +++ b/plugins/virtualbox/virtualbox_cpu_user @@ -37,8 +37,8 @@ if [ "$1" = "config" ]; then echo 'graph_info This graph shows the percentage of processor time spent in user mode by the every single VM process.' echo 'graph_category Virtualization' echo 'graph_period second' - vboxmanage list vms | sed -r 's/^\"(.*)\" \{.*\}$/\1/' | while read VM_NAME; do - VM_NAME_PRINT=`echo -e "${VM_NAME}" | sed 's/[^A-Za-z0-9_]/_/g'` + vboxmanage list vms | sed -r 's/^\"(.*)\" \{.*\}$/\1/' | while read -r VM_NAME; do + VM_NAME_PRINT=$(echo -e "${VM_NAME}" | sed 's/[^A-Za-z0-9_]/_/g') echo "${VM_NAME_PRINT}_user.label ${VM_NAME}" done exit 0 @@ -47,8 +47,7 @@ fi vboxmanage metrics setup --period 5 --samples 3 sleep 5 -vboxmanage list vms | sed -r 's/^\"(.*)\" \{.*\}$/\1/' | while read VM_NAME; do - VM_NAME_PRINT=`echo -e "${VM_NAME}" | sed 's/[^A-Za-z0-9_]/_/g'` - vboxmanage metrics query "${VM_NAME}" CPU/Load/User | grep -E "^${VM_NAME}" | sed -r 's/^.*([0-9]+\.[0-9]+)%/'''${VM_NAME_PRINT}'''_user.value \1/' +vboxmanage list vms | sed -r 's/^\"(.*)\" \{.*\}$/\1/' | while read -r VM_NAME; do + VM_NAME_PRINT=$(echo -e "${VM_NAME}" | sed 's/[^A-Za-z0-9_]/_/g') + vboxmanage metrics query "${VM_NAME}" CPU/Load/User | grep -E "^${VM_NAME}" | sed -r 's/^.*([0-9]+\.[0-9]+)%/'"${VM_NAME_PRINT}"'_user.value \1/' done - diff --git a/plugins/virtualbox/virtualbox_ram_usage b/plugins/virtualbox/virtualbox_ram_usage index e81db92c..6205c638 100755 --- a/plugins/virtualbox/virtualbox_ram_usage +++ b/plugins/virtualbox/virtualbox_ram_usage @@ -34,7 +34,7 @@ if [ "$1" = "autoconf" ]; then fi if [ "$1" = "config" ]; then -RAMTOT=`free -b | grep Mem | awk '{print $2}'` + RAMTOT=$(free -b | grep Mem | awk '{print $2}') echo 'graph_title Memory usage of virtual machines' echo "graph_args --base 1024 -r --lower-limit 0 --upper-limit $RAMTOT --units-exponent 9" echo 'graph_vlabel GB' @@ -42,11 +42,11 @@ RAMTOT=`free -b | grep Mem | awk '{print $2}'` echo 'graph_category Virtualization' echo 'graph_period second' I=0 - vboxmanage list vms | sed -r 's/^\"(.*)\" \{.*\}$/\1/' | while read VM_NAME; do - VM_NAME_PRINT=`echo -e "${VM_NAME}" | sed 's/[^A-Za-z0-9_]/_/g'` + vboxmanage list vms | sed -r 's/^\"(.*)\" \{.*\}$/\1/' | while read -r VM_NAME; do + VM_NAME_PRINT=$(echo -e "${VM_NAME}" | sed 's/[^A-Za-z0-9_]/_/g') echo "${VM_NAME_PRINT}.label ${VM_NAME}" - echo "${VM_NAME_PRINT}.cdef ${VM_NAME_PRINT},1024,*" - if [ ${I} -eq 0 ]; then + echo "${VM_NAME_PRINT}.cdef ${VM_NAME_PRINT},1024,*" + if [ "$I" -eq 0 ]; then echo "${VM_NAME_PRINT}.draw AREA" else echo "${VM_NAME_PRINT}.draw STACK" @@ -59,8 +59,8 @@ fi vboxmanage metrics setup --period 5 --samples 3 sleep 5 -vboxmanage list vms | sed -r 's/^\"(.*)\" \{.*\}$/\1/' | while read VM_NAME; do - VM_NAME_PRINT=`echo -e "${VM_NAME}" | sed 's/[^A-Za-z0-9_]/_/g'` # s/[.]/_/g;s/[ ]/_/g;s/[-]/_/g - vboxmanage metrics query "${VM_NAME}" RAM/Usage/Used | grep -E "^${VM_NAME}" | sed -r 's/^.* ([0-9]+) kB$/'''${VM_NAME_PRINT}'''.value \1/' +vboxmanage list vms | sed -r 's/^\"(.*)\" \{.*\}$/\1/' | while read -r VM_NAME; do + VM_NAME_PRINT=$(echo -e "${VM_NAME}" | sed 's/[^A-Za-z0-9_]/_/g') # s/[.]/_/g;s/[ ]/_/g;s/[-]/_/g + vboxmanage metrics query "${VM_NAME}" RAM/Usage/Used | grep -E "^${VM_NAME}" | sed -r 's/^.* ([0-9]+) kB$/'"${VM_NAME_PRINT}"'.value \1/' done