# $Id: Portfile,v 1.5 2006/02/07 16:34:38 markd Exp $
PortSystem 1.0
name nagios
version 2.0rc2
categories net
maintainers markd@opendarwin.org
platforms darwin
description Nagios is a host and service monitoring program
long_description A network service and host monitor that can notify you \
when servers go down by monitoring for external services \
such as HTTP, FTP, SMTP, SNMP, as well as internal host \
checks for things such as CPU and disk usage and many \
other things.
homepage http://nagios.org
master_sites sourceforge
checksums md5 373124639093919dc8858a243d760f84
depends_build port:gd2
depends_lib lib:libssl:openssl \
port:nagios-plugins
patchfiles patch-sample-minimal.cfg.in.diff
destroot.destdir prefix=${prefix} DESTDIR=${destroot}
destroot.target install install-config install-commandmode install-init
configure.args --with-cgiurl=/nagios/cgi-bin \
--with-htmurl=/nagios \
--with-nagios-user=nagios \
--with-nagios-grp=nagios \
--with-command-grp=nagios \
--with-gd-lib=${prefix}/lib \
--with-gd-inc=${prefix}/include \
--sbindir=${prefix}/sbin/nagios \
--libexecdir=${prefix}/libexec/nagios \
--datadir=${prefix}/share/nagios \
--with-lockfile=${prefix}/var/nagios/nagios.lock \
--with-init-dir=${prefix}/var/nagios \
--sysconfdir=${prefix}/etc/nagios \
--localstatedir=${prefix}/var/nagios
startupitem.create yes
startupitem.start "${prefix}/var/nagios/nagios.init start"
startupitem.stop "${prefix}/var/nagios/nagios.init stop"
pre-configure {
reinplace "s|INIT_OPTS=-o root -g root|INIT_OPTS=-o nagios -g nagios|g" \
"${worksrcpath}/Makefile.in"
reinplace "s|daemon-init \$(DESTDIR)\$(INIT_DIR)/nagios|daemon-init \$(DESTDIR)\$(INIT_DIR)/nagios.init|g" \
"${worksrcpath}/Makefile.in"
reinplace "s|check_external_commands=0|check_external_commands=1|g" \
"${worksrcpath}/sample-config/nagios.cfg.in"
}
pre-build {
adduser nagios
addgroup nagios
}
post-destroot {
# Keep the empty command file directory created by 'make install-commandmode'
destroot.keepdirs ${destroot}${prefix}/var/nagios/rw
# Backup sample files and then rename them for use
xinstall -d -m 755 ${destroot}${prefix}/etc/nagios/sample
system "cd ${destroot}${prefix}/etc/nagios ; cp *.cfg-sample sample/"
system "cd ${destroot}${prefix}/etc/nagios/ ; \
mv bigger.cfg-sample bigger.cfg; \
mv cgi.cfg-sample cgi.cfg; \
mv checkcommands.cfg-sample checkcommands.cfg; \
mv minimal.cfg-sample minimal.cfg; \
mv misccommands.cfg-sample misccommands.cfg; \
mv nagios.cfg-sample nagios.cfg; \
mv resource.cfg-sample resource.cfg;"
}
post-activate {
ui_msg "\n
************************************************************
The basic steps to complete the installation are below. But Nagios is
a complex program so you should read the documentation online at
http://www.nagios.org or locally at ${prefix}/share/nagios/docs/index.html
to fully understand Nagios.
************************************************************
IMPORTANT: A user and group called 'nagios' has been created and you must run
nagios as that user.
1) Setup Apache's httpd.conf file for Nagios (restart Apache when done)
Insert the \"Nagios stuff\" text block somewhere *above* your Apache cgi-bin
ScriptAlias statement:
ScriptAlias /cgi-bin/ \"/Library/WebServer/CGI-Executables/\"
#
# Nagios stuff
ScriptAlias /nagios/cgi-bin/ \"${prefix}/sbin/nagios/\"
AllowOverride None
Options ExecCGI
Order allow,deny
Allow from all
AuthName \"Nagios Access\"
AuthType Basic
AuthUserFile ${prefix}/etc/nagios/htpasswd.users
require valid-user
Alias /nagios \"${prefix}/share/nagios\"
Options None
AllowOverride AuthConfig
Order allow,deny
Allow from all
# End Nagios stuff
#
2) Configure the minimal.cfg sample file in ${prefix}/etc/nagios to your requirements.
Then test the configuration with this command until you get no errors:
sudo nagios -v ${prefix}/etc/nagios/nagios.cfg
3) Set user 'nagiosadmin' as a \"superuser\" in ${prefix}/etc/nagios/nagios.cfg
authorized_for_system_information= nagiosadmin
authorized_for_configuration_information= nagiosadmin
authorized_for_system_commands= nagiosadmin
authorized_for_all_services= nagiosadmin
authorized_for_all_hosts= nagiosadmin
authorized_for_all_service_commands= nagiosadmin
authorized_for_all_host_commands= nagiosadmin
4) Create a 'nagiosadmin' user/password for administator Nagios webpage access
htpasswd -c ${prefix}/etc/nagios/htpasswd.users nagiosadmin
Create other users as desired, omit '-c' since it creates the password file. Make
additional users login names match Nagios contact names to restrict web viewing to your
host's by contact.
5) Start Nagios and login
Be sure to run launchctl so Nagios will start at system boot:
sudo launchctl load -w /Library/LaunchDaemons/org.darwinports.nagios.plist
You may now start Nagios manually with this command (or a reboot):
sudo ${prefix}/var/nagios/nagios.init start
6) You may now login as 'nagiosadmin' to the Nagios web interface at http://localhost/nagios
NOTE: The SMTP server Postfix is required to enable Nagios email notifications
File Locations:
Configuration files: ${prefix}/etc/nagios (minimal.cfg used by default)
Nagios plugins: ${prefix}/libexec/nagios
Lock file: ${prefix}/var/nagios/nagios.lock
Init file: ${prefix}/var/nagios/nagios.init
HTML URL: http://localhost/nagios/
CGI URL: http://localhost/nagios/cgi-bin/
\n"
}