January 2010

Get Growl Notifications on VNC connections, SSH attempts, and HTTP logs [solved]

Use this script to monitor VNC connections with Vine Server:
nice -n 100 tail -n 0 -f /Users/jordan/Library/Logs/VineServer.log | php -r 'while ($m = fgets(STDIN)) shell_exec("growlnotify -p 0 Vine Server -m ". escapeshellarg($m));'

Change “jordan” to your username (home directory), or the whole path of the log if you’re monitoring something else. “Vine Server” is the alert title, which could be anything (“Hello World”).

Save this as a file such as vncnotify.sh. Run
chmod 755 vncnotify.sh
and then you can run the command by typing ./vinenotify.sh.

Duplicate this file and name it vinenotify.command.
Finally, in System Preferences > Accounts > Start up items, add vinenotify.command, and make it hidden, and it will run when you log in.

Things I’m still working on: preventing a string of notifications when you launch VNC; hiding the terminal window when you log in; and grepping for only connect/disconnect/login failures.
Thanks to drewish.com for the growl tail code.

Check for open logs running on OS X, unix or linux [solved]

Use this command to find the log you’re looking for:
lsof | grep -i log

On OS X, typical directories I look in are /var/log/, $HOME/Library/Logs/, and /private/var/log/.