1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-22 02:51:03 +00:00

Use /bin/bash as interpreter, and switch to UNIX line breaks

This commit is contained in:
Stig Sandbeck Mathisen 2014-10-04 21:03:22 +02:00
parent 2eef2d55b5
commit bebd78f74b

View file

@ -1,79 +1,79 @@
#!/bin/sh #!/bin/bash
# #
# Script to monitor iostat cpu|tps. # Script to monitor iostat cpu|tps.
# #
# Parameters understood: # Parameters understood:
# #
# config (required) # config (required)
# autoconf (optional - used by munin-config) # autoconf (optional - used by munin-config)
judge=`basename $0 | sed 's/^iostat_//g'` judge=`basename $0 | sed 's/^iostat_//g'`
current=`date +%H":"%M":"%S`; current=`date +%H":"%M":"%S`;
tenMago=`date --date "10 minutes ago" +%H":"%M":"%S` tenMago=`date --date "10 minutes ago" +%H":"%M":"%S`
export LANG=en_US.UTF-8 export LANG=en_US.UTF-8
# autoconf # autoconf
if [ "$1" == "autoconf" ]; then if [ "$1" == "autoconf" ]; then
if ( sar 1 1 >/dev/null 2>&1 ); then if ( sar 1 1 >/dev/null 2>&1 ); then
echo yes echo yes
exit 0 exit 0
else else
if [ $? -eq 127 ]; then if [ $? -eq 127 ]; then
echo "no (could not run \"sar\")" echo "no (could not run \"sar\")"
exit 1 exit 1
else else
echo no echo no
exit 1 exit 1
fi fi
fi fi
fi fi
ARRAY=( `sar -p -d -s ${tenMago} -e ${current} | grep -v nodev | grep "Average" | awk '{ print $2 , $3 , $10 }'` ) ARRAY=( `sar -p -d -s ${tenMago} -e ${current} | grep -v nodev | grep "Average" | awk '{ print $2 , $3 , $10 }'` )
# config # config
if [ "$1" == "config" ]; then if [ "$1" == "config" ]; then
if [ "$judge" == cpu_average ]; then if [ "$judge" == cpu_average ]; then
echo 'graph_title iostat util' echo 'graph_title iostat util'
echo 'graph_args --upper-limit 100 -l 0' echo 'graph_args --upper-limit 100 -l 0'
echo 'graph_vlabel %' echo 'graph_vlabel %'
echo 'graph_category System' echo 'graph_category System'
for (( i=0 ; i<${#ARRAY[*]} ; i++ )) ; do for (( i=0 ; i<${#ARRAY[*]} ; i++ )) ; do
echo "_dev_${ARRAY[i]}.label ${ARRAY[i]}" echo "_dev_${ARRAY[i]}.label ${ARRAY[i]}"
i=`expr $i + 2` i=`expr $i + 2`
done done
exit 0 exit 0
fi fi
if [ "$judge" == tps_average ]; then if [ "$judge" == tps_average ]; then
echo 'graph_title iostat tps' echo 'graph_title iostat tps'
echo 'graph_args -l 0' echo 'graph_args -l 0'
echo 'graph_vlabel tps' echo 'graph_vlabel tps'
echo 'graph_category System' echo 'graph_category System'
for (( i=0 ; i<${#ARRAY[*]} ; i++ )) ; do for (( i=0 ; i<${#ARRAY[*]} ; i++ )) ; do
echo "_dev_${ARRAY[i]}.label ${ARRAY[i]}" echo "_dev_${ARRAY[i]}.label ${ARRAY[i]}"
i=`expr $i + 2` i=`expr $i + 2`
done done
exit 0 exit 0
fi fi
fi fi
# other # other
if [ "$judge" == cpu_average ]; then if [ "$judge" == cpu_average ]; then
for (( i=0 ; i<${#ARRAY[*]} ; i++ )) ; do for (( i=0 ; i<${#ARRAY[*]} ; i++ )) ; do
echo -n "_dev_${ARRAY[i]}.value " echo -n "_dev_${ARRAY[i]}.value "
i=`expr $i + 2` i=`expr $i + 2`
echo "${ARRAY[i]}" echo "${ARRAY[i]}"
done done
fi fi
if [ "$judge" == tps_average ]; then if [ "$judge" == tps_average ]; then
for (( i=0 ; i<${#ARRAY[*]} ; i++ )) ; do for (( i=0 ; i<${#ARRAY[*]} ; i++ )) ; do
echo -n "_dev_${ARRAY[i]}.value " echo -n "_dev_${ARRAY[i]}.value "
i=`expr $i + 1` i=`expr $i + 1`
echo "${ARRAY[i]}" echo "${ARRAY[i]}"
i=`expr $i + 1` i=`expr $i + 1`
done done
fi fi