Google Plus

How to install nagios in RHEL|Centos|Fedora

Written by Mel Kham on . Posted in Linux tutorials

Nagios is the industry standard in enterprise-class monitoring for good reason. It allows you to gain insight into your network and fix problems before customers know they even exist. It’s stable, scalable, supported, and extensible.

 

Install  Nagios

I First step  :

Let   me  show  you  how to install   nagios monitoring tool .

This  installation has been  tested  by  unixmen team  in  Fedora/Cenots/RHEL/ .

1- First   install some  tools : httpd, gcc, glib, glibc-common, gd and gd-devel

 yum install httpd php
yum install gcc
yum install glibc glibc-common
yum install gd gd-devel
 

2- Create  nagios  user :

#/usr/sbin/useradd -m nagios
#passwd nagios

3- Add  nagcmd  group

/usr/sbin/groupadd nagcmd
/usr/sbin/usermod -a -G nagcmd nagios
/usr/sbin/usermod -a -G nagcmd apache

4- Now go   to http://www.nagios.org   download  files  .

nagios-3.1.0.tar.gz  nagios-plugins-1.4.13.tar.gz  nrpe-2.12.tar.gz

tar  -zxvf  nagios-3.1.0.tar.gz  
cd  nagios-3.1.0
./configure --with-command-group=nagcmd
 #make all; make install; make install-init; make install-config; make install-commandmode; make install-webconf

5-  Edit  your  email  admin address :

Go to

vi /usr/local/nagios/etc/objects/contacts.cfg 

 

6- Create a nagiosadmin account for logging into the Nagios web interfaceassign to this you’ll need it later.

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

enter   the  password.

7- Restart  the  httpd  server :

#Service  httpd   restart

The  second  step  : Extract   and  install  plugins

1- Go  to you  downloaded  nagios  tools

 tar  -zxvf   nagios-plugins-1.4.13.tar.gz

2- cd  nagios-plugins

./configure --with-nagios-user=nagios --with-nagios-group=nagios
make; make   install

3- Now  you  have  to  add nagios  to  Chkconfig

chkconfig --add nagios
chkconfig nagios on

4- Verify  if  you  have  a  good config of nagios with the command

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

5- Check if  there  are  no errors  displayed;  then start   nagios with command :

service  nagios  start

To  simplify  the   procesure  please  disable  the selinux  and  iptables  and  ip6tables

now  open   your  browser   and http://localhost/nagios orr http://ip/nagios

http://www.unixmen.com/images/stories/screenshot004.gif

http://www.unixmen.com/images/stories/screenshot005.gif

 

N.B : Please   if  you  have  questions  about   debian or ubuntu or othe  unix system    . we  are    here  to help.

if  ou  have  more  questions  abouth  commands   nrpe ? , how  to add  new  client  to the  server   ?Feel free to ask

Unixmen Team

 

{module user9-footer}

For questions please refer to our Q/A forum at : http://ask.unixmen.com

Mel Kham

Founder of Unixmen, Living in Amsterdam. Am working in my free time to help people to understand the Opensource and to explain them in easy way how to make the fist steps to the the light. Working day and night with my Co-founder Zinovsky to keep this website live even with less resources.
  • jpedlow

    SElinux causes problems with allowing nagios to start (it wouldnt let me login), I simply put SElinux to permissive mode and then nagios started like a charm.

  • emka57

    hello,

    for me it was also necessary to:
    yum install php
    for avoiding cgi to produce 403 erors when accessing the website

    greetz,

    Manu K

  • Roy

    Hi,
    I am completely new to Linux and I
    have Acer Aspire One-Linpus Linux.
    I am trying to install a Comic book viewer-Cbrpager which is a tar.gz file. I have extracted it to my Downloads folder, but I can’t seem to install it! I would be very grateful if you could give me step by step instructions on how to do it!

  • arlly

    I have successfully gone through the local installation part. where can I find instructions for monitor remote servers, services. etc. I have tied more than a week. still cannot make it work with monitoring nodes other than the local host.
    Could you please give me some links?

    thanks

    • pirat9

      i will add next week how to add new remote hosts to nagios server.

      Best regards
      Unixmen admin

  • Dennis C. Bernardo

    Hi,

    We have existing nagios and also have 30 running servers. We can create a group of alert only for certain servers and just to check only LOAD Average, DISKSpace, HTTP. There’s any configuration or guidelines on this matter.

    Hoping you help me. Thanks…

    Regards on the team.

  • pirat9

    Hi Dennis C. Bernardo;
    please check the search of in this website . add nagios host is another usefull tutorial .
    im waiting of your feedback if you have other questions

  • Anonymous

    Hi pirat9,

    Thanks you its usefull, can i ask you again, we have 2 existing team to handle all the servers, can we track the IP who latest access the servers???

    Any tools or apps that can monitor who accessing the servers.

  • Pirat9

    You have to add a script to nagios to check in system Logs the lateste IP adresses who connected yesterday to your machine .

  • Dennis

    Hi Pirat9,

    Who have any idea about the script, or sample?

    Thanks

  • pirat9

    make sh script with tail -f /var/log/secure option and add script to nagios plugins in /usr/local/nagios/libexec

    and this monitoting script to nagios configuration and restartnagios

    Good Luck :)

  • Oren

    If you encounter with 403 apache error you’ll need to disable the SELinux service.

    The above will switch off enforcement temporarily – until you reboot the system. If you want the system to always start in permissive mode, then here is how you do it.
    In Fedora Core and RedHat Enterprise, edit /etc/selinux/config and you will see some lines like this:

    # 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=enforcing
    # SELINUXTYPE= can take one of these two values:
    # targeted – Only targeted network daemons are protected.
    # strict – Full SELinux protection.
    SELINUXTYPE=targeted
    … just change SELINUX=enforcing to SELINUX=permissive, and you’re done. Reboot if you want to prove it.

  • Avinesh

    Thanks for this tutorial. works perfectly

    I had tried installing nagios with the plugins on fedora 12. Installation was successful was Nagios did start up properly as no log on screen popped up and no details of host or services were shown. these were installed using kpackagekit, yum, rpm. no success with these one

    I tried this tutorial. it work it worked perfectly. A tip for all fedora users – DONT USE kpackagekit, yum or rpm for nagios installation

    Always using the tar.gz file.

    Also you may need to browse for the contacts, and other configuration files. havent tried that yet.

    • Avinesh

      Hi,

      I have tried installing nagios on fedora12 following the instructions given above. I had this installation on a virtualbox machine on running in fedora12.

      the installation was successful but it gives all critical errors for the localhost. when i did a ping to localhost using the terminal, its successful but nagios is not able to ping the localhost. the error say, "plugin may be missing"

      does mean that i need to install all the plugins individually or do i need to do some changes to the nagios settings

      Avinesh

  • pirat9

    you are welcome. we are here to help

  • Charles So

    Followed the installation step-by-step, and started Nagios in Fedora 13.

    Typed’nagiosadmin’ to log in, and Apache says Forbidden, you don’t have permission to access /nagios/ on this server.

    I have not touched httpd (Apache) config at all. It can load the Apache front page.

    What else do I have to configure?

  • Charles So

    [quote=Charles So]Followed the installation step-by-step, and started Nagios in Fedora 13.

    Typed’nagiosadmin’ to log in, and Apache says Forbidden, you don’t have permission to access /nagios/ on this server.

    I have not touched httpd (Apache) config at all. It can load the Apache front page.

    What else do I have to configure?[/quote]

    I need to follow the post above by ‘emka57′, install php, restart httpd before I can log in.

    Thanks alot!

  • rizwan

    i want to install nagios and apache.
    i followed the step which is given above.
    but it not yet completed.

    plz look cmd where is the fault.?
    [root@redhat /]# yum install httpd
    Loaded plugins: rhnplugin, security
    This system is not registered with RHN.
    RHN support will be disabled.
    Setting up Install Process
    No package httpd available.
    Nothing to do
    [root@redhat /]# yum install gcc
    Loaded plugins: rhnplugin, security
    This system is not registered with RHN.
    RHN support will be disabled.
    Setting up Install Process
    No package gcc available.
    Nothing to do
    [root@redhat /]# yum install glibc glibc-common
    Loaded plugins: rhnplugin, security
    This system is not registered with RHN.
    RHN support will be disabled.
    Setting up Install Process
    Nothing to do
    [root@redhat /]# yum install gd gd-devel
    Loaded plugins: rhnplugin, security
    This system is not registered with RHN.
    RHN support will be disabled.
    Setting up Install Process
    No package gd-devel available.
    Nothing to do
    [root@redhat /]# usr/sbin/useradd -m nagios
    useradd: user nagios exists
    [root@redhat /]# passwd nagios
    Changing password for user nagios.
    New UNIX password:
    BAD PASSWORD: it is based on a dictionary word
    Retype new UNIX password:
    passwd: all authentication tokens updated successfully.
    [root@redhat /]# /usr/sbin/groupadd nagcmd
    groupadd: group nagcmd exists
    [root@redhat /]# /usr/sbin/usermod -a -G nagcmd nagios
    [root@redhat /]# /usr/sbin/usermod -a -G nagcmd apache
    [root@redhat /]# tar -zxvf nagios-3.2.0.tar.gz
    tar: nagios-3.2.0.tar.gz: Cannot open: No such file or directory
    tar: Error is not recoverable: exiting now
    tar: Child returned status 2
    tar: Error exit delayed from previous errors
    [root@redhat /]# tar tmp nagios-3.2.0.tar.gz
    cd nagios-3.2.0
    ./configure –with-command-group=nagcmd
    make all; make install; make install-init; make install-config; make install-commandmode; make install-webconf

    vi /usr/local/nagios/etc/objects/contacts.cfg
    htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

    [1]+ Stopped tar tmp nagios-3.2.0.tar.gz
    [root@redhat /]# Service httpd restart
    bash: Service: command not found
    [root@redhat /]# service httpd restart
    httpd: unrecognized service
    [root@redhat /]# make all
    make: *** No rule to make target `all’. Stop.
    [root@redhat /]# make install
    make: *** No rule to make target `install’. Stop.
    [root@redhat /]# make install-init
    make: *** No rule to make target `install-init’. Stop.
    [root@redhat /]# make install-config
    make: *** No rule to make target `install-config’. Stop.
    [root@redhat /]# make install-commandmode
    make: *** No rule to make target `install-commandmode’. Stop.
    [root@redhat /]# make install-webconf
    make: *** No rule to make target `install-webconf’. Stop.
    [root@redhat /]# vi /usr/local/nagios/etc/objects/contacts.cfg

    [2]+ Stopped vi /usr/local/nagios/etc/objects/contacts.cfg
    [root@redhat /]# Service httpd restart
    bash: Service: command not found
    [root@redhat /]# service httpd restart
    httpd: unrecognized service
    [root@redhat /]# service http restart
    http: unrecognized service
    [root@redhat /]# tar -tmp nagios-plugins-1.4.13.tar.gz
    ./configure –with-nagios-user=nagios –with-nagios-group=nagios
    make
    make install
    chkconfig –add nagios
    chkconfig nagios on
    /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
    wq

    ^X
    [3]+ Stopped tar -tmp nagios-plugins-1.4.13.tar.gz
    [root@redhat /]# make
    make: *** No targets specified and no makefile found. Stop.
    [root@redhat /]# make install
    make: *** No rule to make target `install’. Stop.
    [root@redhat /]# chkconfig –add nagios
    error reading information on service nagios: No such file or directory
    [root@redhat /]# chkconfig -add nagios
    -add: unknown option
    [root@redhat /]# chkconfig –add nagios on
    chkconfig version 1.3.30.1 – Copyright (C) 1997-2000 Red Hat, Inc.
    This may be freely redistributed under the terms of the GNU Public License.

    usage: chkconfig –list [name]
    chkconfig –add
    chkconfig –del
    chkconfig [--level ]
    [root@redhat /]# chkconfig –add nagios
    chkconfig version 1.3.30.1 – Copyright (C) 1997-2000 Red Hat, Inc.
    This may be freely redistributed under the terms of the GNU Public License.

    usage: chkconfig –list [name]
    chkconfig –add
    chkconfig –del
    chkconfig [--level ]
    [root@redhat /]# service nagios start
    nagios: unrecognized service
    [root@redhat /]#

    • Morshed

      Brother,
      I am a new user and i make Nagious. So please advice me the correct information and i can do the job. Help me and success this job.
      Morshed

  • pirat9

    you are behind RHEL not registred . convert to centos and enjoy

  • Avinesh

    Hi, I had problems with nagios running on Fedora 12 on a virtualbox machine. I installed it on a dedicated machine and it works fine. The initial problem of not able tp ping check the localhost has been solve the new installation.

    The steps provided above was a great help. Thank you for it

    Avinesh

  • Seyyed

    you forgot to say
    yum install php

    • mosleh

      but OpenNMS is better than nagios 

  • http://enteryoursiteURL... Vishal

    how should i integrate nrpe with the installation?

  • Bill

    #Service httpd restart

    should be

    #service httpd restart

    minor I know

  • http://servertechz.com/?s=nagios jin

    good article..i completed installing nagios with out any issues with the help of this post..good work.

  • Charles So

    unsubscribe

  • http://enteryoursiteURL... abcd

    as shown in the above picture,igot the first page … but how to get the 2nd page(service layout page)

  • http://enteryoursiteURL... ztank

    Hello,
    is there an alternative for [b]SELINUX issue[/b]? I got the nagios environment working fine putting the SELINUX policy in [b]permissive[/b] mode but is there any different approach to this? Is it possible to just disable SELINUX only for what is related to nagios?
    Thanks a lot for helping.

  • Sumit Gupta

    Hi i have installed the nagios on linux system and when i am checking the error then there is no error but web interface is not coming. please suggest.

    Regards,
    Ramesh

  • Sumit Gupta

    The server encountered an internal error or misconfiguration and was unable
    to complete your request.

    Please contact the server administrator, root@localhost and inform them of
    the time the error occurred, and anything you might have done that may have
    caused the error.

    More information about this error may be available in the server error
    log.

    Apache/2.0.52 (Red Hat) Server at 10.0.55.42 Port 80I am facing this issue on consol.regards,Sumit

  • Cd72886

    The Nagios server is now running..how to introduce machines to be monitored?

  • Jeffin_m

    Hi,
    First of all Thank you for a good post. I have two  doughts

    1. what is the use of nrpe that we download already nrpe-2.12.tar.gz
    2. how can i add a new machine into the serverPlease make a post regarding this.

  • Bashasks

    how to add client to nagios server
     

  • Sunny_fs4u

    Forbidden

    You don’t have permission to access /nagios/
    on this server.

    Apache/2.2.15 (Fedora) Server at localhost Port 80Fedora 12
     

  • vishal_babrekar

    This a really useful and perfect post for Nagios I ever seen. If we follow each step correctly all works good.

    Thanks a lot !!

  • Nareshd20

    Executable file /usr/local/nagios/bin/nagios not found.. i am this error …pls do the needful,what may be problem, 

    Can  u send the Clear document of  how to install nagios and how to use in same system and remotely ..

    my mail id: nareshd20@gmail:disqus .com

  • redhatrider

    If selinux is enforcing mode use these two commands

    chcon -R -t httpd_sys_content_t /usr/local/nagios/sbin/
    chcon -R -t httpd_sys_content_t /usr/local/nagios/share/

  • http://www.facebook.com/xavii87 Sérgio Pedrosa

    Hey! Thank you for this tutorial! Helped me a lot with my school project! ;)

Like us on Facebook

This week Top Posts

Write for us

Recent Comments

Nova

|

I wonder if there is a way to create your own themes.

Red Adaya

|

Thank you! This worked for me!!!

SK

|

Andrew look into your httpd.conf file at line no 350. There might be a syntax error.

andrew

|

hello I have this error

[root@cloud html]# /etc/init.d/httpd restart

then this appears

Starting httpd: httpd: Syntax error on line 350 of /etc/httpd/conf/httpd.conf: without matching section.

plz tell how to fix this.

 
IDG Tech Network
Copyright © 2008-2013 Unixmen.com .
Maintained by Anblik .