#!/bin/sh

# reads

# to do
# make disk grep a little less messy

# check for stats file and fill if necessary
# if we don't have the file, the first set of numbers are going to be less than accurate
if [ ! -e /tmp/vmstat-read.mrtg ] 
	then
		$(vmstat -dp | grep sda | awk '{print $2}' > /tmp/vmstat-read.mrtg)
	fi

# get previous stats from file

prevreads=$(cat /tmp/vmstat-read.mrtg)

# get current stats

currreads=$(vmstat -dp | grep sda | awk '{print $2}') 

# put current values into file for next time

echo "$currreads" > /tmp/vmstat-read.mrtg

# calculate how many reads since last time - high number indicates lots of i/o
# currwrites will always be higher or the same as vmstat is NOT an average
# but rather i/o since boot

readdiff=$(expr $currreads - $prevreads)

# echo it so mrtg can access via snmp
echo $readdiff
