From 515c21d3f810be9aa7e6e1150f2d3f8ae0ce7a2a Mon Sep 17 00:00:00 2001 From: Patrick Stadler Date: Tue, 17 Mar 2015 20:12:34 +0100 Subject: [PATCH] fixes for dash --- lib/utils/loader.sh | 4 +++- metrics/disk_io.sh | 2 +- metrics/network_io.sh | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/utils/loader.sh b/lib/utils/loader.sh index 483e31e..afb190c 100644 --- a/lib/utils/loader.sh +++ b/lib/utils/loader.sh @@ -3,7 +3,8 @@ load_reporter_with_prefix () { local prefix=$1 local file=$2 - # dash will error if this variable is defined as `local` + local content + content=$(sed \ -e 's/^[[:space:]]*\(init[ ]*()[ ]*{\)/'"$prefix"'\1/' \ -e 's/^[[:space:]]*\(report[ ]*()[ ]*{\)/'"$prefix"'\1/' \ @@ -16,6 +17,7 @@ load_reporter_with_prefix () { load_metric_with_prefix () { local prefix=$1 local file=$2 + local content # dash will error if this variable is defined as `local` content=$(sed \ diff --git a/metrics/disk_io.sh b/metrics/disk_io.sh index 0486c3f..09a015e 100644 --- a/metrics/disk_io.sh +++ b/metrics/disk_io.sh @@ -21,7 +21,7 @@ if is_osx; then } else __disk_io_bgproc () { - iostat -y -m -d 1 $DISK_IO_MOUNTPOINT | while read line; do + iostat -y -m -d $INTERVAL $DISK_IO_MOUNTPOINT | while read line; do echo $line | awk '/[0-9.]/{ print $3 }' > $__disk_io_fifo done } diff --git a/metrics/network_io.sh b/metrics/network_io.sh index 1cc6993..30aa0e5 100644 --- a/metrics/network_io.sh +++ b/metrics/network_io.sh @@ -28,7 +28,8 @@ __network_io_calc_kBps() { } collect () { - local sample=$(__network_io_collect) + local sample + sample=$(__network_io_collect) if [ ! -z "$__network_io_sample" ]; then report "in" $(__network_io_calc_kBps $(echo $sample | awk '{print $1}') \ $(echo $__network_io_sample | awk '{print $1}'))