A few quick notes on steps I took when installing Nagios from MacPorts. Most of this is given to you during the install, but there are a few missing steps that I’ve added here.I didn’t end up using it, after the installation, but I’ve got a few notes from what little usage I did after the install.
- Do the install:
sudo port install nagios
- Edit
/opt/local/apache2/conf/httpd.conf
and add the following before any existingScriptAlias
directives:# # Nagios stuff ScriptAlias /nagios/cgi-bin/ "/opt/local/sbin/nagios/" <directory "/opt/local/sbin/nagios"> AllowOverride None Options ExecCGI Order allow,deny Allow from all AuthName "Nagios Access" AuthType Basic AuthUserFile /opt/local/etc/nagios/htpasswd.users require valid-user </directory> Alias /nagios "/opt/local/share/nagios" <directory "/opt/local/share/nagios"> Options None AllowOverride AuthConfig Order allow,deny Allow from all </directory> # End Nagios stuff #
# # Nagios stuff ScriptAlias /nagios/cgi-bin/ "/opt/local/sbin/nagios/" <directory "/opt/local/sbin/nagios"> AllowOverride None Options ExecCGI Order allow,deny Allow from all AuthName "Nagios Access" AuthType Basic AuthUserFile /opt/local/etc/nagios/htpasswd.users require valid-user </directory> Alias /nagios "/opt/local/share/nagios" <directory "/opt/local/share/nagios"> Options None AllowOverride AuthConfig Order allow,deny Allow from all </directory> # End Nagios stuff #
- Back up the default config files, just in case:
cd /opt/local/etc/nagios sudo mkdir sample sudo cp *.cfg-sample sample/ cd objects sudo mkdir sample sudo cp *.cfg-sample sample/
- Rename the default config files:
cd /opt/local/etc/nagios sudo -s for i in *cfg-sample; do mv $i `echo $i | sed -e s/cfg-sample/cfg/`; done; cd objects for i in *cfg-sample; do mv $i `echo $i | sed -e s/cfg-sample/cfg/`; done; exit
- Create an Apache password file for the ‘nagiosadmin’ user:
sudo /opt/local/apache2/bin/htpasswd -c /opt/local/etc/nagios/htpasswd.users nagiosadmin
- Create a couple of directories that are needed:
sudo mkdir -p /opt/local/var/nagios/spool/checkresults sudo chown -R nagios:nagios /opt/local/var/nagios/spool
- Add the
www
user to thenagios
group so that Apache has write access to certain files, especially/opt/local/var/nagios/rw/nagios.cmd
:sudo dscl . -append /Groups/nagios GroupMembership www sudo dscl . -append /Groups/nagios GroupMembership _www
- Test the config to make sure everything’s okay:
sudo nagios -v /opt/local/etc/nagios/nagios.cfg
- Restart Apache and start the Nagios daemon:
sudo /opt/local/apache2/bin/apachectl -k restart sudo /opt/local/var/nagios/nagios.init start
- If you want it to run at startup, enable the startup item:
sudo launchctl load -w /Library/LaunchDaemons/org.macports.nagios.plist
Usage Notes
The documentation is of course geared toward a Linux install; directory names are different in a MacPorts install.
/usr/local/nagios/libexec/
is/opt/local/libexec/nagios/
/usr/local/nagios/etc/
is/opt/local/etc/nagios/
- The startup script
/etc/rc.d/init.d/nagios
is at/opt/local/var/nagios/nagios.init
- The binary location
/usr/local/nagios/bin/nagios
is/opt/local/bin/nagios
I’m glad to stumble upon this. Any ideas which variants of OS X this’ll build and run on properly (Tiger Server, Leopard Client, … ?)
Pretty much anything I’d guess. It’s not a terribly complicated piece of software! “sudo port install nagios” is the easiest way to find out.
Fair enough. Thanks.
I’m very appreciative someone is assuming the entire groundwork is laid by MacPorts to get this going, thanks a lot for this.
Not to be anal or anything, I still don’t have this working yet in Snow Leopard or Leo(second fresh setup with 403 access denied errors) but it’s only been a short while I’ve been trying.
For the sake of completeness, it seems a bit out of order that the nagios-specific ScriptAlias comes before the Alias additions to the file, is that required?
It is obvious that a MacPorts-installed Apache2 is being installed as well, but that’s not mentioned.
Also, step 4 assumes the working directory is /opt/local/etc/nagios, so you may want to throw in a “cd ..” at the beginning of that step.
Please understand I just want to verify I’m doing the steps correctly before I tinker with users and chown(wasn’t there supposed to be a nagioscmd group as well?)
I’ve fixed the mistake in step 4, thanks for that. I didn’t get very far with this, Nagios seems more painful to configure than any piece of software should ever be. For a network that’s constantly adding and updating devices, it’s not very useful.
I can say I got the thing running successfully with these steps, but that’s about as far as I got with it.
Awesome post. Thanks! A few minor comments…
1. In step 6, -P must be lowercase:
sudo mkdir -p /opt/local/var/nagios/spool/checkresults
2. In step 5, sudo is repeated twice, and for those using the default apache install, htpasswd binary is located in the default path:
sudo sudo /opt/local/apache2/bin/htpasswd -c /opt/local/etc/nagios/htpasswd.users nagiosadmin
would then be:
sudo htpasswd -c /opt/local/etc/nagios/htpasswd.users nagiosadmin
Thanks, I’ve updated to fix the errors you pointed out.
This worked perfect in lion