How to install Nagios 4.0.1 (Monitoring Tool) in ubuntu 13.10 server (Saucy Salamander)

Sponsored Link
Nagios® Core™ is an Open Source system and network monitoring application. It watches hosts and services that you specify, alerting you when things go bad and when they get better.Nagios Core was originally designed to run under Linux, although it should work under most other unices as well.

Some of the many features of Nagios Core include:

Monitoring of network services (SMTP, POP3, HTTP, NNTP, PING, etc.)
Monitoring of host resources (processor load, disk usage, etc.)
Simple plugin design that allows users to easily develop their own service checks
Parallelized service checks
Ability to define network host hierarchy using "parent" hosts, allowing detection of and distinction between hosts that are down and those that are unreachable
Contact notifications when service or host problems occur and get resolved (via email, pager, or user-defined method)
Ability to define event handlers to be run during service or host events for proactive problem resolution
Automatic log file rotation
Support for implementing redundant monitoring hosts
Optional web interface for viewing current network status, notification and problem history, log file, etc.

Preparing your system

We have already discussed how to install ubuntu 13.10 LAMP server and now you need to install the following extra packages

sudo apt-get install wget build-essential php5-gd wget libgd2-xpm libgd2-xpm-dev libapache2-mod-php5 apache2-utils daemon

Now you need to download nagios core and plugins from here

Adding the Nagios User and Group

Next add the appropriate user and group for the Nagios process to run

sudo useradd nagios

sudo groupadd nagcmd

sudo usermod -a -G nagcmd nagios

Now you need to install nagios core installation

You need to login as root and run the following commands

Extract the downloaded files (Nagios core and Plugins)

tar zxvf nagios-4.0.1.tar.gz

tar zxvf nagios-plugins-1.5.tar.gz

Change to the new Nagios directory and install the packages

cd nagios-4.0.1/

./configure --with-nagios-group=nagios --with-command-group=nagcmd -–with-mail=/usr/bin/sendmail

make all

make install

make install-init

make install-config

make install-commandmode

When you run the following command

make install-webconf

You might see the following error

/usr/bin/install -c -m 644 sample-config/httpd.conf /etc/httpd/conf.d/nagios.conf
/usr/bin/install: cannot create regular file â/etc/httpd/conf.d/nagios.confâ: No such file or directory
make: *** [install-webconf] Error 1

As per the error message it's clear that nagios is trying to create the nagios.conf file inside the /etc/httpd.conf file to fix the problem try the following

mkdir /etc/httpd

mkdir /etc/httpd/conf.d

mkdir /etc/httpd/conf.d/nagios.conf

and Finally run the following command

sudo make install-webconf

You should see similar to the following output

/usr/bin/install -c -m 644 sample-config/httpd.conf /etc/httpd/conf.d/nagios.conf

*** Nagios/Apache conf file installed ***

Now following the next steps for nagions installation

cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/

chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

/etc/init.d/nagios start

When i try to start nagios i got the following error

root@ubuntu:/# /etc/init.d/nagios start

/etc/init.d/nagios: 20: .: Can't open /etc/rc.d/init.d/functions

To fix the above error try the following commands to fix the problem try the following solution

Solution

wget https://raw.github.com/nicolargo/nagiosautoinstall/master/hack4nagiosstart.sh

chmod a+x ./hack4nagiosstart.sh

./hack4nagiosstart.sh

Now your nagios should start without any problem

Create a Default User for Web Access.

Add a default user for Web Interface Access:

htpasswd –c /usr/local/nagios/etc/htpasswd.users nagiosadmin

Nagios Plugin installation

cd nagios-plugins-1.5

./configure --with-nagios-user=nagios --with-nagios-group=nagios

make

make install

Nagios Service Setup

ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios

Login Nagios Web Interface

After correctly following the procedures you should now be able to access your Nagios Core installation from a web browser.
Simply use the following:

http:///nagios

And log in with the credentials you chose when adding the nagiosadmin user to the htpasswd.users file

Sponsored Link

You may also like...

33 Responses

  1. Nhan says:

    Hello,

    I have finished my installation on Ubuntu Trusty and trying to connect from Windows 8 laptop to the link: http:///nagios

    ——————————————————
    Not Found

    The requested URL /nagios was not found on this server.

    Apache/2.4.7 (Ubuntu) Server at 10.97.1.2 Port 80

    ———– All services seems to be working fine ———–

    root@ithfdb62:/usr/local/src/opm/nagios-plugins-2.0.3# ps -ef|grep nagios
    nagios 22538 1 0 15:33 ? 00:00:00 /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
    nagios 22539 22538 0 15:33 ? 00:00:00 /usr/local/nagios/bin/nagios –worker /usr/local/nagios/var/rw/nagios.qh
    nagios 22540 22538 0 15:33 ? 00:00:00 /usr/local/nagios/bin/nagios –worker /usr/local/nagios/var/rw/nagios.qh
    nagios 22541 22538 0 15:33 ? 00:00:00 /usr/local/nagios/bin/nagios –worker /usr/local/nagios/var/rw/nagios.qh
    nagios 22542 22538 0 15:33 ? 00:00:00 /usr/local/nagios/bin/nagios –worker /usr/local/nagios/var/rw/nagios.qh
    nagios 22543 22538 0 15:33 ? 00:00:00 /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
    root 51005 65464 0 15:43 pts/2 00:00:00 grep nagios
    root@ithfdb62:/usr/local/src/opm/nagios-plugins-2.0.3# /etc/init.d/nagios start
    Starting nagios: another instance of nagios is already running.
    root@ithfdb62:/usr/local/src/opm/nagios-plugins-2.0.3#
    root@ithfdb62:/usr/local/src/opm/nagios-plugins-2.0.3#
    root@ithfdb62:/usr/local/src/opm/nagios-plugins-2.0.3#
    root@ithfdb62:/usr/local/src/opm/nagios-plugins-2.0.3# ps -ef|grep apache
    root 55129 65464 0 15:47 pts/2 00:00:00 grep apache
    root 59170 1 0 15:10 ? 00:00:00 /usr/sbin/apache2 -k start
    www-data 59201 59170 0 15:10 ? 00:00:00 /usr/sbin/apache2 -k start
    www-data 59202 59170 0 15:10 ? 00:00:00 /usr/sbin/apache2 -k start
    www-data 59203 59170 0 15:10 ? 00:00:00 /usr/sbin/apache2 -k start
    www-data 59204 59170 0 15:10 ? 00:00:00 /usr/sbin/apache2 -k start
    www-data 59205 59170 0 15:10 ? 00:00:00 /usr/sbin/apache2 -k start
    www-data 60515 59170 0 15:11 ? 00:00:00 /usr/sbin/apache2 -k start
    root@ithfdb62:/usr/local/src/opm/nagios-plugins-2.0.3# service apache restart
    apache: unrecognized service
    root@ithfdb62:/usr/local/src/opm/nagios-plugins-2.0.3# service apache2 restart
    * Restarting web server apache2 [ OK ]
    root@ithfdb62:/usr/local/src/opm/nagios-plugins-2.0.3#

  2. Nhan says:

    I got that work out, did not notice that in the replies:

    sudo ln -s /etc/httpd/conf.d/nagios.conf /etc/apache2/sites-enabled/000-nagios.conf

    service apache2 restart

    Sorry for duplicating post.

  3. Lorena says:

    THANKS!!

Leave a Reply

Your email address will not be published. Required fields are marked *