How can I see how long my computer has been active (as in not idle)
You can also find the idle time in UNIX by running

ioreg -c IOHIDSystem


And looking for the returned HIDIdleTime

Or you could run a shell script on idle like so, just call it every 30 seconds or so using LaunchD. Make sure to put the launchd xml file in /Library/LaunchDaemons so it runs even when no user is logged in, or /Library/LaunchAgents/ if you only want it to run when someone is logged into the machine.

#!/bin/bash
idl=$"`ioreg -c IOHIDSystem | awk '/HIDIdleTime/ {print int($NF/1000000000); exit}'`"
idletime="600"
if [ $idl -gt $idletime ]; then
#Your
#Code
#Here
fi