Nagios Installation and Configuration on Fedora Core 4.

Resources:
Overview: The General Process for installing from source.
Installation
  1. Get the Nagios files.  On Fedora Core 4 with httpd, perl and gcc, download the source tarballs for both the core Nagios files and the plugins from the Nagios download site.
    # wget http://unc.dl.sourceforge.net/sourceforge/nagios/nagios-2.0b4.tar.gz
    # wget http://easynews.dl.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.2.tar.gz
    Prepare your system for the installation as per the Installation docs.
    # adduser nagios
    # mkdir /usr/local/nagios
    # chown nagios.nagios /usr/local/nagios
    # grep "^User" /etc/httpd/conf/httpd.conf
    User apache


  2. Untar the files and cd into the nagios-2.0b4 directory.  Then configure, build and install...
    # tar xvzf nagios-2.0b4.tar.gz
    # cd nagios-2.0b4
    # /usr/sbin/usermod -G nagios apache
    # ./configure --prefix=/usr/local/nagios --with-cgiurl=/nagios/cgi-bin --with-htmurl=/nagios/ --with-nagios-user=nagios --with-nagios-group=nagios --with-command-group=nagios  [output]
    # make all  [output]  [error]
    # make install  [output]
    # make install-init  [output]
    # make install-commandmode  [output]
    # make install-config  [output]


  3. Now extract, build and install the plugins...
    # cd ../
    # tar xvzf nagios-plugins-1.4.2.tar.gz
    # cd nagios-plugins-1.4.2
    # ./configure  [output]  [error]
    # make [output]  [error]
    # make test  [output]  [error]
    # make install  [output]


  4. Set up the Web Interface using Apache for httpd.  Add the following to your /etc/httpd/conf/httpd.conf file or create an entry in /etc/httpd.conf.d.  Basic Web Interface setup is thoroughly documented here and configuring Web Authentication here.
    # cat /etc/httpd/conf.d/nagios.paulororke.net.conf
    										
    <VirtualHost *:80>
     ServerAdmin paul@paulororke.net
     DocumentRoot /usr/local/nagios/share
     ServerName nagios.paulororke.net
     ErrorLog logs/nagios.paulororke.net-error_log
     CustomLog logs/nagios.paulororke.net-access_log common
     ScriptAlias /nagios/cgi-bin /usr/local/nagios/sbin
    
     <Directory "/usr/local/nagios/sbin">
      AllowOverride AuthConfig
      Options ExecCGI
      Order allow,deny
      Allow from all
     </Directory>
    
     Alias /nagios /usr/local/nagios/share
     <Directory "/usr/local/nagios/share">
      Options None
      AllowOverride AuthConfig
      Order allow,deny
      Allow from all
     </Directory>
    
    </VirtualHost>
    									


  5. Modify the configuration files to suit your system and then create/modify Object Definition files to monitor your chosen hosts and services. Use the sample config files provided in /usr/local/nagios/etc/.  Refer to the links above to see my config files.



  6. Do the 'preflight' checks. Call the Nagios executable with the - v arguement and then the path to the nagios.cfg configuration file. This will test all the config files you have in /usr/local/nagios/etc and provide feedback about any misconfiguration.  It will not however do any checks on the plugins to check if they are actually going to work.  
    # /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
    <snip>
    Total Warnings: 0
    Total Errors: 0

    Things look okay - No serious problems were detected during the pre-flight check   [complete output]
    I had some serious problems actually getting the Nagios CGI's to display in the browser. After a great deal of research and posting on the Nagios mailing lists I found that nagios needs to write some temporary files to the hard drive of the machine on which the nagios process is running. In the nagios.cfg file there are references to status_file and temp_file.  status_file is dependant on temp_file successfully writing to the HDD. In my case I had copied my nagios.cfg from an earlier RPM install and the values for the loactions of these two files were such that the Nagios process did not have write rights. Moving these valuse to a location inside /usr/local/nagios resolved this and the CGI generated imaged suddenly appeared in the Web Interface.


  7. Choose a method to run Nagios.  Since I had run the install script to create startup scripts in /etc/init.d/", then starting Nagios should have been as simple as:
    # service nagios start
    Starting network monitor: nagios
    
    However, on checking for the process I found it did not exist and the service was infact not running. Checking the nagios log I found:
    [1129916622] Nagios 2.0b4 starting... (PID=10639)
    [1129916622] LOG VERSION: 2.0
    [1129916622] You do not have permission to write to /var/run/nagios.pid
    [1129916622] Bailing out due to errors encountered while attempting to daemonize... (PID=10639)
    
    It seems that the permission issue for Nagios is quite far reaching. Changing the value of temp_file from /var/run/nagios.pid to /usr/local/nagios/var/nagios.pid allowed the PID to be written and the init script to succeed.
    # service nagios start
    Starting network monitor: nagios
    
    # ps aux |grep nagios
    nagios   11474  0.0  0.2  12548  1216 ?        Ssl  11:11   0:00 /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
    root     11488  0.0  0.1   3760   668 pts/0    R+   11:11   0:00 grep nagios
    
    # tail -3 /usr/local/nagios/var/nagios.log
    [1129918272] Nagios 2.0b4 starting... (PID=11473)
    [1129918272] LOG VERSION: 2.0
    [1129918272] Finished daemonizing... (New PID=11474)
    
    
The end of the article.
The end of the page.