# $Id: Portfile 21341 2007-01-21 07:29:10Z markd@macports.org $ PortSystem 1.0 name nagios version 2.7 categories net maintainers markd@macports.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 d664d2785cdca3c5c8a3e84c033e8e6e depends_build port:gd2 depends_lib port:openssl \ port:nagios-plugins 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 variant monarch { # This variant installs the Monarch configuration GUI for Nagios depends_lib-append port:monarch } 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" reinplace "s|NagiosLockDir=/var/lock/subsys|NagiosLockDir=${prefix}/var/nagios|g" \ ${worksrcpath}/daemon-init.in reinplace "s|su -|su -m|g" \ ${worksrcpath}/daemon-init.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 } 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 Nagios sample files in ${prefix}/etc/nagios. a) First, backup the Nagios sample files. cd ${prefix}/etc/nagios sudo mkdir sample sudo cp *.cfg-sample sample/ b) Then rename the sample files for use. sudo for i in *cfg-sample; do mv \$i `echo \$i | sed -e s/cfg-sample/cfg/`; done; c) Configure the default commands.cfg file to your requirements. Then test the Nagios configuration with this command until you get no errors: sudo nagios -v ${prefix}/etc/nagios/nagios.cfg 3) Set user 'nagiosadmin' as a \"superuser\" to browse all hosts/services in ${prefix}/etc/nagios/cgi.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' Apache user/password to correspond with the Nagios Apache user created above 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) Set Nagios to start at system boot, and start Nagios OS X 10.4 - Run launchctl so Nagios will start at system boot sudo launchctl load -w /Library/LaunchDaemons/org.macports.nagios.plist OS X 10.3 - A startup item was created in /Library/StartupItems Add \"NAGIOS=-YES-\" to the /etc/hostconfig file to run Nagios at system boot 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 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" }