From dc5e652d2657f9dfc1770aaf40bc911e92a0a99b Mon Sep 17 00:00:00 2001 From: "T.O" Date: Fri, 8 Apr 2011 12:35:57 +0200 Subject: [PATCH] Initial version --- plugins/other/iostat-cputps-average | 79 +++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100755 plugins/other/iostat-cputps-average diff --git a/plugins/other/iostat-cputps-average b/plugins/other/iostat-cputps-average new file mode 100755 index 00000000..ccc846d1 --- /dev/null +++ b/plugins/other/iostat-cputps-average @@ -0,0 +1,79 @@ +#!/bin/sh +# +# Script to monitor iostat cpu|tps. +# +# Parameters understood: +# +# config (required) +# autoconf (optional - used by munin-config) + +judge=`basename $0 | sed 's/^iostat_//g'` +current=`date +%H":"%M":"%S`; +tenMago=`date --date "10 minutes ago" +%H":"%M":"%S` +export LANG=en_US.UTF-8 + +# autoconf + +if [ "$1" == "autoconf" ]; then + if ( sar 1 1 >/dev/null 2>&1 ); then + echo yes + exit 0 + else + if [ $? -eq 127 ]; then + echo "no (could not run \"sar\")" + exit 1 + else + echo no + exit 1 + fi + fi +fi + +ARRAY=( `sar -p -d -s ${tenMago} -e ${current} | grep -v nodev | grep "Average" | awk '{ print $2 , $3 , $10 }'` ) + +# config + +if [ "$1" == "config" ]; then + if [ "$judge" == cpu_average ]; then + echo 'graph_title iostat util' + echo 'graph_args --upper-limit 100 -l 0' + echo 'graph_vlabel %' + echo 'graph_category System' + for (( i=0 ; i<${#ARRAY[*]} ; i++ )) ; do + echo "_dev_${ARRAY[i]}.label ${ARRAY[i]}" + i=`expr $i + 2` + done + exit 0 + fi + + if [ "$judge" == tps_average ]; then + echo 'graph_title iostat tps' + echo 'graph_args -l 0' + echo 'graph_vlabel tps' + echo 'graph_category System' + for (( i=0 ; i<${#ARRAY[*]} ; i++ )) ; do + echo "_dev_${ARRAY[i]}.label ${ARRAY[i]}" + i=`expr $i + 2` + done + exit 0 + fi +fi + +# other + +if [ "$judge" == cpu_average ]; then +for (( i=0 ; i<${#ARRAY[*]} ; i++ )) ; do + echo -n "_dev_${ARRAY[i]}.value " + i=`expr $i + 2` + echo "${ARRAY[i]}" +done +fi + +if [ "$judge" == tps_average ]; then +for (( i=0 ; i<${#ARRAY[*]} ; i++ )) ; do + echo -n "_dev_${ARRAY[i]}.value " + i=`expr $i + 1` + echo "${ARRAY[i]}" + i=`expr $i + 1` +done +fi