All pastes #734735 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-10-12 23:13 UTC
rendered paste body
#!/bin/bash

# 1, 2, 3, 4, 5 min
# hd
# field 7, 3

hdname="sda"
servicelocation="/runprog"
donotidle="" # idle command here
elpasedTime="0"
g_read="`cat /proc/diskstats | grep ' sda ' | awk -F' ' '{print $4}'`"
g_wrote="`cat /proc/diskstats | grep ' sda ' | awk -F' ' '{print $7}'`"

function start()
{
	elpasedTime="0"
	_read="`cat /proc/diskstats | grep ' sda ' | awk -F' ' '{print $4}'`"
	_wrote="`cat /proc/diskstats | grep ' sda ' | awk -F' ' '{print $7}'`"
	sleep 240
	__read="`cat /proc/diskstats | grep ' sda ' | awk -F' ' '{print $4}'`"
	__wrote="`cat /proc/diskstats | grep ' sda ' | awk -F' ' '{print $7}'`"
	if $[ $__read -e $_read && $__wrote -e $_wrote ]
	then
		$donotidle
	fi
}


function main()
{
	while true
	do
		run="`cat $servicelocation`"
		if $[ $run -e "1" ]
		then
			start
		else
			elpasedTime="0"
			sleep 60
		fi
	done
}