Since others might be interested, here's what I ended up doing. Feel free to make suggestions - I'll probably improve on this solution over time.
Anyway, I ended up installing tcpdump via optware. I've heard entware was better maintained, but since I'm only using this for tcpdump, I figure optware will suffice.
My Plex client will try to reach my Plex server on port 32400, so I have tcpdump monitor this port. I could probably add a source and destination host to be more specific with what it is I want to observe, but for now, this is how I have it:
Code:
tcpdump -i any -q 'port 32400' | tee /tmp/mnt/ROUTER_DISK/plex.log&
/tmp/mnt/ROUTER_DISK is an external USB drive that I have plugged into the router.
I then have script which monitors the plex.log file for any changes (x's are my MAC and IP of the Plex server):
Code:
#!/bin/sh
INTERVAL=2
NUMP=1
TARGET=xxxxxxxx
MAC=xxxxxxxxx
WOL=/usr/bin/ether-wake
OLD_LC=`wc -l /tmp/mnt/ROUTER_DISK/plex.log | awk '{print $1}'`
while sleep $INTERVAL;do
NEW_LC=`wc -l /tmp/mnt/ROUTER_DISK/plex.log | awk '{print $1}'`
NEWLINES=`expr $NEW_LC - $OLD_LC`
if [ "$NEW_LC" -ne "$OLD_LC" ]; then
RET=`ping -c $NUMP -W 1 $TARGET 2> /dev/null | awk '/packets received/ {print $4}'`
if [ "$RET" -ne "$NUMP" ]; then
/usr/bin/ether-wake -i br0 $MAC
sleep 20
fi
fi
OLD_LC=`wc -l /tmp/mnt/ROUTER_DISK/plex.log | awk '{print $1}'`
done
Pretty basic. I also have a script for cleaning the log file every so often.
Code:
#!/bin/sh
> /tmp/mnt/ROUTER_DISK/plex.log
sleep 36000
The only issue I see with this approach is that when I clean my log file, my script will cause my Plex server to wake up. I should probably add some logic that says if word count is equal to 0, then do nothing.
Anyway, it seems to be working great. I will monitor over the next few weeks and see if it affects performance of the router, but so far so good.