OK, this seems to be unreliable:
Code:
--------------------
#!/bin/sh
SHAREPATH='/mnt/media/Videos'
# Check for an file open anywhere in SHAREPATH..
OPENFILE=`/usr/bin/lsof +D "$SHAREPATH"`
if [ -n "$OPENFILE" ]; then
echo "File $OPENFILEis open.."
exit 1
fi
exit 0
--------------------
The DLNA server that I'm using, mediatomb, only opens a file momentarily
to read the portion that it's currently streaming. So the above is only
occasionally clued into the fact that mediatomb is actively streaming a
file.
Bandwidth monitoring of the network interface seems to be more
promising. The following seems to correctly detect current network
bandwidth usage above a certain threshold:
Code:
--------------------
#!/bin/sh
#Threshold for bytes transmitted over a 10 second interval..
THRESHOLD="10000.00"
# Check for current network bandwith usage above our THRESHOLD..
# from wgm-ng README:
#csv output format:
#Type svg, sum, max:
#unix
timestamp;iface_name;bytes_out;bytes_in;bytes_total;packets_out;packets_in;packets_total;errors_out;errors_in\n
#monitor bandwith usage on eth0 for 10 seconds | sed output just last (total)
line | awk extract the 3rd csv field
TXSUM=`bwm-ng --interfaces eth0 --allif 0 --type rate --count 10 --output csv
--ansiout --type sum --unit bytes | sed '$!d' | awk -F ";" '{ print $3 }'`
#use bc to do a floating point comparison..
ABOVETHRESHOLD=`echo "$TXSUM> $THRESHOLD" | bc`
if [ $ABOVETHRESHOLD -gt 0 ]
then
echo "System is busy! TXSUM == $TXSUM"
exit 1
else
echo "System is not busy! TXSUM == $TXSUM"
fi
exit 0
--------------------
Having to call bwm-ng, sed, awk and bc all seems a little heavy handed.
Can anyone think of a simpler way to do this?
--
gharris999
------------------------------------------------------------------------
gharris999's Profile: http://forums.slimdevices.com/member.php?userid=115
View this thread: http://forums.slimdevices.com/showthread.php?t=49028
_______________________________________________
unix mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/unix