Round I, FIGHT!
I have a ReadyNAS box with ~600GB in it. It's full and because of some quirks with the way the firmware upgrade process works I have to start from scratch if I want more than ~1.5TB in a single volume. So I picked up a couple of 750GB hdds and planned to do the obvious copy/format/copy loop with the newest firmware and a fresh disk volume. Problem: The old firmware had some bugginess with network shares. It would occasionally hiccup and freeze the stream. This isn't a problem for using the device normally, the hiccups were small enough to be caught in the buffer but it turns out that rsync loads the network far, far more heavily and causes the mount point to lock up on the client machine. So I wrote a script to watch for an idle network interface (stalled transfer) and kill rsync, which is run in a loop and does the remount thing if rsync dies or fails. ::until umount skorgu || umount skorgu -fl; mount //machine/share /mnt/point -ousername=username,password=password -tsmbfs && rsync /mnt/point to/path -avP -timeout=10 --inplace; do echo retrying; sleep 10; done And then this in another terminal (or subshell if you're feeling adventurous):
while ~/watch_for_idle_nic.sh eth1 2 10000 && killall rsync; do echo "killing"; sleep 10; done watch_for_idle_nic.sh
(which could probably be simplified to a one-liner but I wasn't in the mood for golfing):
#!/bin/bash LAST=$(ifconfig $1 | perl -ne 'print $1 if m/RX bytes:(\\d+)/') sleep $2 THIS=$(ifconfig $1 | perl -ne 'print $1 if m/RX bytes:(\\d+)/') DELTA=$(( THIS - LAST )) echo "$DELTA" while [[ $DELTA > $3 ]] do LAST=$THIS sleep $2 THIS=$(ifconfig $1 | perl -ne 'print$1 if m/RX bytes:(\\d+)/') DELTA=$(( THIS - LAST )) echo "$DELTA" done
The echos aren't needed, only nice to look at.