NagiosExchange
NagiosForge
NagiosWiki
Nagios Community Platform powered by NETWAYS

HowTos:BestPractice:NagiosFromSourceFedora

Search  
From NagiosWiki
Jump to: navigation, search

Nagios from Source (Fedora)

Contents

These Best Practice guide are intended to provide you with simple instructions on how to install Nagios from source (code) on Fedora and have it monitoring your local machine within 20 minutes.
No advanced installation options are discussed here - just the basics that will work for 95% of users who want to get started.

The advanced installations are discussed on another Best Practice Guide. The basic Nagios installation is always this Best Practice.

Requirement

  • Installing Fedora System (best a minimal installation)
  • For building needed programs (gcc, make, etc.)
[root@nag-server ~]# yum install httpd glib2-devel gcc make automake autoconf gd gd-devel
  • Create Nagios-User and Nagios-Groups
[root@nag-server ~]# groupadd -g 9000 nagios
[root@nag-server ~]# groupadd -g 9001 nagcmd
[root@nag-server ~]# useradd -u 9000 -g nagios -G nagcmd -d /usr/local/nagios -c "Nagios Admin" nagios
  • Disable SELinux; After installation, webserver's user is not allowed to access /usr/local/nagios/ and it's content because of the folders security context.
    Hint: Only after a reboot, SELinux will be disabled!
[root@nag-server ~]# vi /etc/sysconfig/selinux
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#       enforcing - SELinux security policy is enforced.
#       permissive - SELinux prints warnings instead of enforcing.
#       disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
#       targeted - Targeted processes are protected,
#       mls - Multi Level Security protection.
SELINUXTYPE=targeted

Download sources

[root@nag-server ~]# cd /usr/local/src
[root@nag-server src]# wget http://downloads.sourceforge.net/nagios/nagios-3.0.3.tar.gz
[root@nag-server src]# wget http://downloads.sourceforge.net/nagiosplug/nagios-plugins-1.4.12.tar.gz

Installing Nagios

  • Extract the Nagios source code tarball
[root@nag-server src]# tar -xvzf nagios-3.0.3.tar.gz
  • change into the sourcefolder
[root@nag-server src]# cd nagios-3.0.3
  • Run the Nagios configure script, passing the name of the group you created earlier like so
    With the --help command you see a lot of configuration options.
    I'm installing with this options
[root@nag-server nagios-3.0.3]# ./configure --enable-nanosleep --with-command-group=nagcmd
...
...
...
*** Configuration summary for nagios 3.0.3 06-25-2008 ***: 

 General Options:
 -------------------------
        Nagios executable:  nagios
        Nagios user/group:  nagios,nagios
       Command user/group:  nagios,nagcmd
            Embedded Perl:  no
             Event Broker:  yes
        Install ${prefix}:  /usr/local/nagios
                Lock file:  ${prefix}/var/nagios.lock
   Check result directory:  ${prefix}/var/spool/checkresults
           Init directory:  /etc/rc.d/init.d
  Apache conf.d directory:  /etc/httpd/conf.d
             Mail program:  /bin/mail
                  Host OS:  linux-gnu 

 Web Interface Options:
 ------------------------
                 HTML URL:  http://localhost/nagios/
                  CGI URL:  http://localhost/nagios/cgi-bin/
 Traceroute (used by WAP):  /bin/traceroute


Review the options above for accuracy.  If they look okay,
type 'make all' to compile the main program and CGIs.

[root@nag-server nagios-3.0.3]#
  • Compile the Nagios source code
[root@nag-server nagios-3.0.3]# make all
  • Install binaries, init script, sample config files and set permissions on the external command directory
[root@nag-server nagios-3.0.3]# make install
[root@nag-server nagios-3.0.3]# make install-init
[root@nag-server nagios-3.0.3]# make install-commandmode
[root@nag-server nagios-3.0.3]# make install-config
  • change permissions of /usr/local/nagios
[root@nag-server ~]# ls -ld /usr/local/nagios/
drwx------ 9 nagios nagios 4096 2008-08-29 15:07 /usr/local/nagios/
[root@nag-server ~]# 
[root@nag-server ~]# chmod 755 /usr/local/nagios/
[root@nag-server ~]# 
[root@nag-server ~]# ls -ld /usr/local/nagios/
drwxr-xr-x 9 nagios nagios 4096 2008-08-29 15:07 /usr/local/nagios/
[root@nag-server ~]#

Configuring the webserver

  • Copy the nagios sample config to your webservers conf.d folder
[root@nag-server nagios-3.0.3]# cp /usr/local/src/nagios-3.0.3/sample-config/httpd.conf /etc/httpd/conf.d/nagios.conf
  • Create a nagiosadmin account for logging into the Nagios web interface. Remember the password you assign to this account.
[root@nag-server nagios-3.0.3]# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
New password: 
Re-type new password: 
Adding password for user nagiosadmin
[root@nag-server nagios-3.0.3]#
  • Find out webservers user and add him to nagcmd group
[root@nag-server nagios-3.0.3]# grep -R "^User" /etc/httpd/conf*
/etc/httpd/conf/httpd.conf:User apache
[root@nag-server nagios-3.0.3]#
[root@nag-server nagios-3.0.3]# usermod -G nagcmd apache
  • Now, restart your webserver
[root@nag-server nagios-3.0.3]# /etc/init.d/httpd restart
  • And tell chkconfig to start him on next boot
[root@nag-server nagios-3.0.3]# chkconfig httpd on

Installing Nagios Plugins

  • Installing the requirements
[root@nag-server src]# yum install openssl-devel mysql-devel mysql-server mysql openldap-devel net-snmp-libs net-snmp-devel net-snmp net-snmp-perl net-snmp-utils
  • Extract the Nagios Plugins source code tarball
[root@nag-server src]# tar xvzf nagios-plugins-1.4.12.tar.gz
  • change into the sourcefolder
[root@nag-server src]# cd nagios-plugins-1.4.12
  • Run the Nagios Plugins configure script
    With the --help command you see a lot of configuration options
[root@nag-server nagios-plugins-1.4.12]# ./configure --with-ipv6
...
...
...
config.status: creating po/Makefile
            --with-apt-get-command: 
              --with-ping6-command: /bin/ping6 -n -U -w %d -c %d %s
               --with-ping-command: /bin/ping -n -U -w %d -c %d %s
                       --with-ipv6: yes
                      --with-mysql: /usr/bin/mysql_config
                    --with-openssl: yes
                     --with-gnutls: no
               --enable-extra-opts: no
                       --with-perl: /usr/bin/perl
             --enable-perl-modules: no
                     --with-cgiurl: /nagios/cgi-bin
               --with-trusted-path: /bin:/sbin:/usr/bin:/usr/sbin
[root@nag-server nagios-plugins-1.4.12]#
  • Compile the Nagios Plugins source code
[root@nag-server nagios-plugins-1.4.12]# make
  • Install the plugins
[root@nag-server nagios-plugins-1.4.12]# make install

Start Nagios

[root@nag-server ~]# service nagios start
[root@nag-server ~]# chkconfig --add nagios 
[root@nag-server ~]# chkconfig nagios on

Login to the Web Interface

You should now be able to access the Nagios web interface at the URL below. You'll be prompted for the username (nagiosadmin) and password you specified earlier.

http://localhost/nagios/