User Rating: / 5
PoorBest 

Bookmark and Share

If you are new to Unixmen, you may want to subscribe :

Nagios is a popular open source computer system and network monitoring software application. It watches hosts and services, alerting users when things go wrong and again when they get better.


Nagios was originally designed to run under Linux, but also runs well on other Unix variants. It is free software, licensed under the terms of the GNU General Public License version 2 as published by the Free Software Foundation.

Before to start, if you want to install Nagios in fedora ,RHEL or centos please read our previous tutorial

 

I- Install Apache, PHP  and  some  needed  libraries

First we will install apache , php and needed librairies

  • Install some necessary compilers using the command :
sudo  apt-get install build-essential

  • Install GD Libraries using the command :
sudo apt-get install libgd2-xpm-dev

  • Install Apache2
sudo apt-get install apache2
 
  • Install PHP for  apache 2 :
sudo apt-get install php5-common php5 libapache2-mod-php5

Now configure Apache to use PHP:

Open apache2.conf file

sudo vi   /etc/apache2/apache2.conf 

and  add this line

DirectoryIndex index.html index.php index.cgi

Now  restart  your   apache

sudo  /etc/init.d/apache2   restart

II- Install and Configure Nagios :

Now  lets  install  and  configure   Nagios

First download  the latest  core  nagios  from nagios  website and before  installing create a user to run the service and a group to run external commands:

 * sudo useradd -m nagios
 * sudo passwd nagios
 * sudo groupadd nagcmd
 * sudo usermod -a -G nagcmd nagios
 * sudo usermod -a -G nagcmd www-data

Now install the Nagios tarballs that were downloaded previously:

tar -zxvf nagios-3.2.1.tar.gz 

Then cd the the extracted folder and install

cd nagios-3.2.1
sudo ./configure --with-command-group=nagcmd
sudo make all
sudo make install
sudo make install-init
sudo make install-config
sudo make install-commandmode
sudo make install-webconf
 

Add a user for the Nagios interface:

sudo  mkdir  /usr/local/nagios/etc

Create a new password

sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

Output

New password:
Re-type new password:
pirat9@pirat9-desktop:~/Downloads/nagios-3.2.1$

Now add  Nagios directory to apache, first open apache.conf :

sudo vi /etc/apache2/apache.conf

and  add these lines :

ScriptAlias /nagios/cgi-bin /usr/local/nagios/sbin

Options ExecCGI

AllowOverride None

Order allow,deny

Allow from all

AuthType Basic

AuthUserFile /usr/local/nagios/etc/htpasswd.users

Require valid-user

Alias /nagios /usr/local/nagios/share

Options None

AllowOverride None

Order allow,deny

Allow from all

AuthType Basic

AuthUserFile /usr/local/nagios/etc/htpasswd.users

Require valid-user

save and exit then restart apache2


sudo  /etc/init.d/apache2 restart

Install Nagios Plugins :

tar -zxvf  nagios-plugins-1.4.14.tar.gz 
 
  • Cd the extracted folder and install the plugins
 cd nagios-plugins-1.4.14
 sudo ./configure --with-nagios-user=nagios --with-nagios-group=nagios
sudo make 
sudo make install
  • Create a link to start the service:

sudo ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios
 
ls -altr

Output

total 20

-rw-r--r--   1 root root   447 2009-09-07 20:58 README

lrwxrwxrwx   1 root root    20 2010-04-04 22:10 S70x11-common -> ../init.d/x11-common

lrwxrwxrwx   1 root root    24 2010-04-04 22:10 S70screen-cleanup -> ../init.d/screen-cleanup

lrwxrwxrwx   1 root root    17 2010-04-04 22:10 S55urandom -> ../init.d/urandom

lrwxrwxrwx   1 root root    23 2010-04-04 22:10 S49console-setup -> ../init.d/console-setup

lrwxrwxrwx   1 root root    18 2010-04-04 22:10 S37apparmor -> ../init.d/apparmor

lrwxrwxrwx   1 root root    16 2010-04-04 22:10 S25brltty -> ../init.d/brltty

lrwxrwxrwx   1 root root    21 2010-04-04 22:10 S13pcmciautils -> ../init.d/pcmciautils

lrwxrwxrwx   1 root root    24 2010-04-04 22:10 S06keyboard-setup -> ../init.d/keyboard-setup

drwxr-xr-x 132 root root 12288 2010-04-15 01:45 ..

lrwxrwxrwx   1 root root    18 2010-04-15 02:09 S99nagios -> /etc/init.d/nagios

drwxr-xr-x   2 root root  4096 2010-04-15 02:09 .

 

Please before running the configuration check and copy all config files from your nagios directory to /usr/local/nagios/etc/objects/ and /usr/local/nagios/etc/

like

config file '/usr/local/nagios/etc/objects/commands.cfg'...

object config file '/usr/local/nagios/etc/objects/contacts.cfg'...

object config file '/usr/local/nagios/etc/objects/timeperiods.cfg'...

object config file '/usr/local/nagios/etc/objects/templates.cfg'...

object config file '/usr/local/nagios/etc/objects/localhost.cfg'...


  • Verify the config:

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

Output :

Nagios Core 3.2.1

Copyright (c) 2009-2010 Nagios Core Development Team and Community Contributors

Copyright (c) 1999-2009 Ethan Galstad

Last Modified: 03-09-2010

License: GPL

Website: http://www.nagios.org

Reading configuration data...

Read main config file okay...

Processing object config file '/usr/local/nagios/etc/objects/commands.cfg'...

Processing object config file '/usr/local/nagios/etc/objects/contacts.cfg'...

Processing object config file '/usr/local/nagios/etc/objects/timeperiods.cfg'...

Processing object config file '/usr/local/nagios/etc/objects/templates.cfg'...

Processing object config file '/usr/local/nagios/etc/objects/localhost.cfg'...

Read object config files okay...

Running pre-flight check on configuration data...

Checking services...

Checked 8 services.

Checking hosts...

Checked 1 hosts.

Checking host groups...

Checked 1 host groups.

Checking service groups...

Checked 0 service groups.

Checking contacts...

Checked 1 contacts.

Checking contact groups...

Checked 1 contact groups.

Checking service escalations...

Checked 0 service escalations.

Checking service dependencies...

Checked 0 service dependencies.

Checking host escalations...

Checked 0 host escalations.

Checking host dependencies...

Checked 0 host dependencies.

Checking commands...

Checked 24 commands.

Checking time periods...

Checked 5 time periods.

Checking for circular paths between hosts...

Checking for circular host and service dependencies...

Checking global event handlers...

Checking obsessive compulsive processor commands...

Checking misc settings...

Total Warnings: 0

Total Errors:   0

Things look okay - No serious problems were detected during the pre-flight check

pirat9@pirat9-desktop:~/Downloads/nagios-3.2.1$

  • Now start Nagios:

sudo /etc/init.d/nagios start

 

  • Now you are ready to use Nagios, open your browser and type :
   http://hostname/nagios or http://ip/nagios  




If you have a Tip, tutorial, Idea or anything you want to share with unixmen readers, you can send it to : tips[a]unixmen.com or use our contact form Thanks.


Related Articles By Tags:




Related Articles By Tags:

Comments (31)
  • Rudiger Wolf  - Directory change missing?
    avatar

    Hi

    When I do "ls -altr" as per instructions I do not get dir listing you do. Can you please calrify what dir I should be in at that point in time?

    Thaanks
    Rudi

  • pirat9
    avatar

    This just listing of /etc/rcS.d/S99nagios.
    its not verry important

  • Lynn  - cant get nagios to start
    avatar

    Hi, I followed this how-to exactly, and I cant get nagios to start. I can get to the web interface, but when I click on anything it gives me an error stating:
    Error: Could not read host and service status information!

    When I checked the nagios logs I see:
    [1272750947] Nagios 3.2.1 starting... (PID=28967)
    [1272750947] Local time is Sat May 01 17:55:47 EDT 2010
    [1272750947] LOG VERSION: 2.0
    [1272750947] Finished daemonizing... (New PID=28970)
    [1272750947] Caught SIGSEGV, shutting down...


    What can I try now to get nagios starting?

  • coldsystem
    avatar


    Lynn
    what is the output of your
    sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg


  • Corzo  - did it work?
    avatar

    Lynn, did you make it work? im having the same problem...

  • Pirat9
    avatar

    Please post your problem on the forum with screen shots . and we will solve this together.
    Thanks

  • Joe  - remove
    avatar

    so how would I go about unistalling? Is there a straightforward way to remove nagios?

  • pirat9
    avatar

    rm -rf /usr/local/nagios /etc/init.d/nagios

  • taivna  - problem.
    avatar

    hi sir. Your advice is best.

    but my apache failed.

    II- Install and Configure Nagios : last row

    Problem: AllowOverride not allowed here

    PLS HELP ME!!!

  • Fefo  - AllowOverride not allowed here
    avatar

    hi. i wrote the same witch is in the document. but it showed the following error:

    * Restarting web server apache2 Syntax error on line 240 of /etc/apache2/apache2.conf:
    AllowOverride not allowed here

    what can i do?
    thx

  • taivna  - continous
    avatar

    my nagios fine working but apache have problem.

    AllowOverride not allowed her

  • taivna  - Good
    avatar

    Oh sorry it is my fault. I add some changes apache2.conf. it was wrong.

    kk sorry Sir.

  • pirat9
    avatar

    you are welcome :)

  • tomw  - Excellent...do you have a similar one for Nagvis?
    avatar

    Hi, I'd also like to install nagvis to Ubuntu 9.10...do you have or know of a similar step by step guide for this that follows on from installing nagios(as per above)?

  • Mad  - Thanks, but...
    avatar

    Thanks for your efforts but I had to stop in the middle of getting complete.

    You described:
    sudo vi /etc/apache2/apache.conf
    but there is'nt such a file, did you mean
    sudo vi /etc/apache2/apache2.conf?

    If so, (I used it instead) I got errormessages that AllowOverride None ist not allowed than I restart apache service
    Also I got a warning message, that the SriptAlias directive will probably never match because it overlaps an earlier SriptAlias.

    Any help is appreciated very much an urgendly needed.

    Best regards
    Mad

  • Jim  - Thanks
    avatar

    Worked perfectly for me. Thanks for the help!

  • Anonymous  - Great Job - Have question though
    avatar

    Hi,

    Great job !!! It works very well.

    However I got a question about one of your steps that isn't very clear.

    Where you wrote:
    "Please before running the configuration check and copy all config files from your nagios directory to /usr/local/nagios/etc/objects/ and /usr/local/nagios/etc/"

    FROM what directory are you talking about?
    Because you haven't listed that directory and thus I have no idea which directory you are writing about.

    Please advise.
    Thanks and Cheers!

  • khaled
    avatar

    how can add user in nagios

  • khaled  - users
    avatar

    how can add user in nagios

  • krushna  - please help
    avatar

    How to configure nagios in ubuntu 10.04.

  • pirat9
    avatar

    How to add user is :
    sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin


    or

    sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users userX

  • pirat9
    avatar

    krushna,

    check your config,
    sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

  • rm  - the whole thing - cut and paste
    avatar

    Below are all the commands - to cut and paste
    to a file

    note: Nagios dir has both tar files
    note: apache2 conf lines at end of this list

    Robert

    ================


    sudo apt-get install apache2
    sudo apt-get install libapache2-mod-php5
    sudo apt-get install build-essential
    sudo apt-get install libgd2-xpm-dev
    sudo apt-get install php5-common php5 libapache2-mod-php5
    sudo apt-get install vim
    sudo vim /etc/apache2/apache2.conf
    sudo useradd -m nagios
    sudo passwd nagios
    sudo groupadd nagcmd
    sudo usermod -a -G nagcmd
    sudo groupadd nagcmd
    sudo usermod -a -G nagcmd nagios
    sudo usermod -a -G nagcmd www-data

    cd Nagios/
    ls
    tar -xvf nagios-3.2.1.tar.gz
    cd nagios-3.2.1
    sudo ./configure -with-command-group=nagcmd
    sudo make all
    sudo make install
    sudo make install-init
    sudo make install-config
    sudo make install-commandmode
    sudo make install-webconf
    sudo mkdir /usr/local/nagios/etc
    sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
    sudo /etc/init.d/apache2 restart

    cd Nagios/
    tar -xvf nagios-plugins-1.4.14.tar.gz
    cd nagios-plugins-1.4.14
    sudo ./configure --withnagios-user=nagios --with-group=nagios
    sudo ./configure --with-nagios-user=nagios --with-group=nagios
    sudo make
    sudo make install
    sudo -ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios
    sudo ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios
    sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
    sudo /etc/init.d/nagios start
    sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
    sudo /etc/init.d...

  • rm  - the Rest of the commands
    avatar

    Fixed typo "withnagos"
    previous post cut off end

    Robert

    =====

    cd Nagios/
    tar -xvf nagios-plugins-1.4.14.tar.gz
    cd nagios-plugins-1.4.14
    sudo ./configure --with-nagios-user=nagios --with-group=nagios
    sudo make
    sudo make install
    sudo -ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios
    sudo ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios
    sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
    sudo /etc/init.d/nagios start
    sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
    sudo /etc/init.d/apache2 restart

    ## ADD the following to the end of /etc/apache2/apache2.conf

    # added for nagios
    DirectoryIndex index.html index.php index.cgi

    ScriptAlias /nagios/cgi-bin/ "/usr/local/nagios/sbin"

    Options ExecCGI
    AllowOverride None
    Order allow,deny
    Allow from all
    AuthType Basic
    AuthUserFile /usr/local/nagios/etc/htpasswd.users
    Require valid-user


    Alias /nagios/ "/usr/local/nagios/share"

    Options None
    AllowOverride None
    Order allow,deny
    Allow from all
    AuthType Basic
    AuthUserFile /usr/local/nagios/etc/htpasswd.users
    Require valid-user


    ## the end of /etc/apache2/apache2.conf

  • rm  - one more thing
    avatar

    not all charaters are cut and paste see correction below:

    Robert

    =====

    the apache2.conf

    ScriptAlias /nagios/cgi-bin/ "/usr/local/nagios/sbin"

    greater-then Directory less-then

    options go here

    greater-then slash Directory less-then

    Alias /nagios/ "/usr/local/nagios/share"

    greater-then Directory less-then

    options go here

    greater-then slash Directory less-then

  • Saroj, Ox
    avatar

    Hi there,

    I am getting 'Syntax error on line 243 of /etc/apache2/apache2.conf: AllowOverride not allowed here
    error message, could someone please let me know what is causing this issue?

    Many thanks,
    Saroj
    Ox

  • SysAdmin74  - Great instructions!
    avatar

    Thanks for the awesome instructions! It worked perfectly!

  • JM  - Works great from my desktop
    avatar

    Call me apache deficient but I can't seem to get one thing working. I can't seem to view the system from anywhere outside of the VLAN that the server resides in. I know this has to be a simple solution but I've been all over with no luck.

  • Mart  - Script Error
    avatar

    The information below is already in /etc/apache2/conf.d/nagios.conf causing the error - "Syntax error on line 243 of /etc/apache2/apache2.conf: AllowOverride not allowed here" I left it in the nagios.conf file and everything appears to be working.

    ---------# added for nagios
    DirectoryIndex index.html index.php index.cgi

    ScriptAlias /nagios/cgi-bin/ "/usr/local/nagios/sbin"

    Options ExecCGI
    AllowOverride None
    Order allow,deny
    Allow from all
    AuthType Basic
    AuthUserFile /usr/local/nagios/etc/htpasswd.users
    Require valid-user


    Alias /nagios/ "/usr/local/nagios/share"

    Options None
    AllowOverride None
    Order allow,deny
    Allow from all
    AuthType Basic
    AuthUserFile /usr/local/nagios/etc/htpasswd.users
    Require valid-user


    ## the end of /etc/apache2/apache2.conf
    -------

  • pirat9
    avatar

    JM - Works great from my desktop

    try to desactivate selinux and adjust Iptables and will be fine

  • nnamdi  - thanks
    avatar

    nice how too. work well for me but i want to know can i monitor a windows network with this app. cos i was looking for something like OSmonitor for windows can it do something like that. i use ubuntu myself

Write comment
Your Contact Details:
Gravatar enabled
Comment:
[b] [i] [u] [s] [url] [quote] [code] [img]   
:D:):(:0:shock::confused:8):lol::x:P:oops::cry:
:evil::twisted::roll::wink::!::?::idea::arrow: