Saturday, October 25, 2008

Integrate Growl with syslog

Growl is a great notification system for Mac OS X. Integrating Growl is easy, you only have to write a small perl script and reconfigure the syslog system.

syslog.conf
*.notice;authpriv.none;kern.debug;    |exec /bin/growl_log.pl

Perl script
#!/usr/bin/perl
use strict;
use Net::Growl;

my $host = "0.0.0.0"; // Your Apple computer
my $app = "Syslog Integrator";
my $pwd = "xyz123";

Net::Growl::register(host => $host, application => $app, password => $pwd) ;

my $log = `tail -n 1 /var/log/messages`;

Net::Growl::notify(host => $host, application => $app, password => $pwd, title => "Syslog", description => $log);

exit 0;

For more information about Growl, click here.