Network monitoring: Nagios

Installation

by ross at 16:43:27 on December 29, 2011

Install the port

# cd /usr/ports/net-mgmt/nagios
# make config-recursive
# make install clean
# rehash

# sh
# cd /usr/local/etc/nagios
# for i in *.cfg-sample; do mv $i `echo $i | sed 's/cfg-sample/cfg/'`; done
# cd /usr/local/etc/nagios/objects
# for i in *.cfg-sample; do mv $i `echo $i | sed 's/cfg-sample/cfg/'`; done

Create virtual host

<VirtualHost *:80>
        ServerName nagios.example.com
        ServerAdmin root@example.com
        DocumentRoot "/usr/local/www/nagios"
        ScriptAlias /cgi-bin/ "/usr/local/www/nagios/cgi-bin/"
        ScriptAlias /nagios/cgi-bin/ "/usr/local/www/nagios/cgi-bin/"
        Alias /nagios "/usr/local/www/nagios"
        ErrorLog "/home/www/nagios.example.com/logs/nagios.example.com-error.log"
        CustomLog "/home/www/nagios.example.com/logs/nagios.example.com-access.log" combined

        # "ls /usr/share/zoneinfo" lists the available timezones
        SetEnv TZ "Australia/Brisbane"
        
        <Location />
                AuthType Basic
                AuthName "Nagios access"
                AuthUserFile /home/www/nagios.example.com/.htpasswd
                Require valid-user
        </Location>
</VirtualHost>

<Directory /usr/local/www/nagios>
        Order Allow,Deny
        Allow from all
        php_flag engine on
        php_admin_value open_basedir /usr/local/www/nagios/:/var/spool/nagios/
</Directory>

<Directory /usr/local/www/nagios/cgi-bin>
        Options ExecCGI
        Order Allow,Deny
        Allow from all
</Directory>
# mkdir /home/www/nagios.example.com
# cd /home/www/nagios.example.com
# mkdir logs
# htpasswd -c .htpasswd nagiosadmin
# chown -R www:www /home/www/nagios.example.com

Add to /etc/rc.conf:

# Enable Nagios
nagios_enable="YES"
# service nagios start

Open http://nagios.example.com and login as nagiosadmin.

 

Comments