

Some days ago our website was unavailable. It was some time before the problem was detected because our website is hosted by an ISP. This could have disastrous consequences for your commerce if you strongly depend on high website traffic.
1. Prerequisites
Growl is your communication room and the de facto standard for Mac OS X systems. There are so many applications that use Growl. Growl can let you know when any event occurs with a subtle notification.
What Growl is for system notification on Mac OS X – is Nagios for system monitoring of your IT infrastructure. Nagios is available for nearly all major operating systems.
This seems to be a perfect duo.
2. Installing Growl
Before you can start you have to install Growl which is free of charge until version 1.3. The installation itself should be a rapid and easy task.
3. Installing Nagios
Next you need Nagios to be installed on your system. Because Mac OS X is a *BSD-style operating system you can use MacPorts. With MacPorts you have access to thousands of ports of well-known Open Source software.
Here you will find a very detailed installation instruction for Mac OS X. If you only want to use Growl or Email/SMTP for notifications you can skip step 2.2 (Apache Webserver) and 2.3 (Postfix SMTP). Later I will use an external SMTP server for sending notification emails.
4. Building the bridge between Nagios and Growl
Here is an installation tutorial for German users.
Growl is able to receive system notifications via network. To enable this open the Growl Preference Pane, tick the necessary option and give a password.
To send Growl notifications we need the Perl script: grotify.pl. You can download this small peace of code from here. I’ve renamed the script to grotify and copied to directory /opt/local/libexec/nagios – the default location for Nagios commands. Don’t forget to chmod 755 grotify the executable. This grotify script makes use of an additional Perl module: Net::Growl. You can easily install the module via the CPAN shell (sudo perl -MCPAN -e shell):
install Net::Growl
. The default installation path on my Mac OS X system is /opt/local/lib/perl5/site_perl/5.8.9. Typically this directory is not added to the Perl library path. Extend the library path by adding the installation directory of the Net::Growl module to the grotify script:
... use lib '/opt/local/lib/perl5/site_perl/5.8.9'; use strict; use warnings; use Getopt::Long qw(:config no_ignore_case bundling); use IO::Socket; use Net::Growl; use Pod::Usage; ...
To verify your changes try to send a Growl test message:
grotify -H 127.0.0.1 -p -a Nagios -t "Nagios Notification" -m "Testalert"
Next we add new Nagios commands using the grotify script installed above to /opt/local/etc/nagios/objects/commands.cfg:
define command {
command_name notify-host-by-grotify
command_line $USER1$/grotify -H $USER11$ -p $USER12$ -a Nagios -t "Nagios Notification" -m "$NOTIFICATIONTYPE$ Alert $HOSTNAME$ is $HOSTSTATE$"
}
define command {
command_name notify-service-by-grotify
command_line $USER1$/grotify -H $USER11$ -p $USER12$ -a Nagios -t "Nagios Notification" -m "$NOTIFICATIONTYPE$ Alert $HOSTNAME$/$SERVICEDESC$ is $SERVICESTATE$"
}
The macros $USER1$, $USER11$ and $USER12$ are defined in /opt/local/etc/nagios/resource.cfg. Where
- $USER1$ – Nagios plugin directory
- $USER11$ – the IP address of the recipient host for notification
- $USER12$ – the Growl password
The pre-defined contact “nagiosadmin” in configuration file /opt/local/etc/nagios/objects/contacts.cfg must be extended to send notifications by grotify:
define contact {
contact_name nagiosadmin
use generic-contact
alias Nagios Admin
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options n
service_notification_commands notify-service-by-email,notify-service-by-grotify
host_notification_commands notify-host-by-email,notify-host-by-grotify
email root ; ** CHANGE THIS TO YOUR EMAIL ADDRESS **
}
Again, verify your changes with a dry-run:
sudo nagios -v /opt/local/etc/nagios/nagios.cfg
5. External SMTP for sending notification emails
By default Nagios will use the local mail daemon to send all the notifications. If you want to use an existing external SMTP service I recommend you to use the alternative mail command sendEmail from http://caspian.dotconf.net/menu/Software/SendEmail. Daniele Cuocci wrote a good blog article about using sendEmail to send email notifications. You will find the article here.
Once the configuration is verified you may start Nagios at boot time:
sudo launchctl load –w /Library/LaunchDaemons/org.macports.nagios.plist
6. Et voilà
If everything went well you will see Growl notifications like this. Of course only if there is a problem to report.



Hello,
Your guide is the best one I can find on the net – for setting up GROWL+NAGIOS on MAC OS X.
I fallowed the steps and installed/configured and started nagios but have some troubles with accessing – nagios web interface “You don’t have permission to access /nagios/ on this server.”
Unfortunatly detailed instatllation that you share link is dead:
http://homepage.mac.com/duling/halfdozen/Nagios-Howto-p1.html
http://homepage.mac.com/duling/halfdozen/Nagios-Howto-p2.html
I’m almost there but hit the bump with Nagios Web, can you advice?
I’m using default Apache2 form MacOS X SL 10.6.8, installed Nagios 3.2.3 form macports.
Thanks for the great ideas!
Regards,
Please have a look at the Apache2 error log file to be found in “/var/log/httpd” for a detailed error log message.