Last active
December 23, 2015 01:48
-
-
Save jcla1/6562332 to your computer and use it in GitHub Desktop.
Cron and Applescript files for personal tracking
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[submodule "running_programs"] | |
path = running_programs | |
url = https://gist.github.com/6554497.git | |
[submodule "chrome_status"] | |
path = chrome_status | |
url = https://gist.github.com/6525572.git | |
[submodule "frontApp"] | |
path = frontApp | |
url = https://gist.github.com/6522769.git |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Log computer activity to daily log file | |
# by Joseph Adams | |
# MIT Licensed | |
CHROME_STATUS="data/misc/cron/chrome_status/chrome_status.applescript" | |
RUNNING_PROGRAMS="data/misc/cron/running_programs/running_programs.applescript" | |
FRONT_APP="data/misc/cron/frontApp/frontApp.applescript" | |
LOG_FILE="data/misc/activity_log/`date +%Y%m%d`.log" | |
function log_activity() | |
{ | |
local UTC=`date "+%s,%Z"` | |
local IDLE=$((`/usr/sbin/ioreg -c IOHIDSystem | sed -e '/HIDIdleTime/!{ d' -e 't' -e '}' -e 's/.* = //g' -e 'q'` / 1000000000 )) | |
local ACTIVE_PROGRAM=$(/usr/bin/osascript $FRONT_APP) | |
read CHROME_STATS ACTIVE_URL <<< `/usr/bin/osascript $CHROME_STATUS` | |
local PROGRAMS=$(/usr/bin/osascript $RUNNING_PROGRAMS) | |
echo "$UTC,$IDLE,$ACTIVE_PROGRAM,$CHROME_STATS\n$PROGRAMS\n$ACTIVE_URL" >> $LOG_FILE | |
#echo "`vnstat --dumpdb | grep "^d;0" | tr ";" "," | cut -d, -f 3-`" >> $LOG_FILE | |
} | |
log_activity | |
sleep 15 | |
log_activity | |
sleep 15 | |
log_activity | |
sleep 15 | |
log_activity |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0-55/5 * * * * data/misc/cron/net_usage.sh | |
* * * * * data/misc/cron/activity.sh | |
0-55/5 * * * * if [ -x /usr/local/Cellar/vnstat/1.11/bin/vnstat ] && [ `ls /usr/local/var/db/vnstat/ | wc -l` -ge 1 ]; then /usr/local/Cellar/vnstat/1.11/bin/vnstat -u; fi | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LOG_FILE="data/misc/activity_log/net_`date +%Y%m%d`.log" | |
echo "`date "+%s,%Z"`,`/usr/local/bin/vnstat --dumpdb | grep "^d;0" | tr ";" "," | cut -d, -f 4-`" >> $LOG_FILE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment