Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #%# family=auto
- #%# capabilities=autoconf suggest
- if [ "$1" = "autoconf" ]; then
- echo yes
- exit 0
- fi
- if [ "$1" = "suggest" ]; then
- awk '/ [hs]d[a-z][0-9]* / { print $3 }' /proc/diskstats
- exit 0
- fi
- device=$(basename $0 | sed 's/^diskutil_//g')
- ncpu=$(egrep -c '^cpu[0-9]+ ' /proc/stat)
- if [ "$1" = "config" ]; then
- echo 'graph_category disk'
- echo "graph_title Disk utilization for /dev/${device}"
- echo 'graph_args -l 0 -u 100'
- echo 'graph_vlabel %'
- echo 'util.label utilization'
- echo 'util.info utilization %'
- echo 'util.type GAUGE'
- echo 'util.draw AREA'
- exit 0
- fi
- statefiledir=/var/lib/munin/plugin-state/
- statefile="${statefiledir}diskutil-${device}.state"
- newticks=$(awk '/^cpu / { print $2+$3+$4+$5+$6+$7+$8+$9+$10 }' /proc/stat)
- newioticks=$(awk "/ $device / { print \$13 }" /proc/diskstats)
- if [ -s $statefile ] ; then
- read oldticks oldioticks <$statefile
- else
- oldticks=$newticks
- oldioticks=$newioticks
- fi
- echo "${newticks} ${newioticks}" > $statefile
- deltaticks=$(($newticks-$oldticks))
- deltaioticks=$(($newioticks-$oldioticks))
- printf "util.value %d.%d\n" $(($deltaioticks*$ncpu*10/$deltaticks)) $(($deltaioticks*$ncpu*10*10000/$deltaticks-$deltaioticks*$ncpu*10/$deltaticks*10000))
Add Comment
Please, Sign In to add comment