Install Nagios on Centos 5

Installing Nagios server and network monitoring on Centos 5 server

The official documentation can be found at http://support.nagios.com/knowledge-base/official-documentation

Install necessary packages

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

Create Nagios User account and group

useradd -m nagios

Create nagcmd group for allowing external commands to be submitted through the web interface. Add both the nagios user and the apache user

groupadd nagcmd
usermod -a -G nagcmd nagios
usermod -a -G nagcmd apache

Create Directory to store Nagios installation files

mkdir /opt/Nagios

Download Nagios and Plugins

Save file to directory /opt/Nagios

http://www.nagios.org/download/download.php

As of this writing Nagios 3.0.6 (Stable) and Nagios Plugins 1.4.13 (Stable)

Extract Files:

cd /opt/Nagios

tar xzf nagios-3.0.6.tar.gz

cd nagios-3.0.6

Compile and Configure Nagios

./configure --with-command-group=nagcmd

Compile Nagios:

make all

Compile binaries, init script, sample config files:

make install

make install-init

make install-config

make install-commandmode

** Do Not Start Nagios **

Nagios has now been installed to the directory /usr/local/nagios/

Install Nagios Web Interface:

make install-webconf

Nagios Web Interface installed to /usr/local/nagios/share ( http conf file added to /etc/httpd/conf.d/nagios.conf )

Create Web Interface Login User:

** This is not the most secure method **

We will create user “nagiosadmin” ( remember the password you assign !)

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

Restart Apache:

service httpd restart

Install Nagios Plugins

Extract Files:

cd /opt/Nagios

tar xzf nagios-plugins-1.4.13.tar.gz

cd nagios-plugins1.4.13

Compile and Configure Nagios Plugins

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

make

make install

Configure nagiosadmin email address for alerts

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

email     nagios@localhost   ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******

Verify the sample Nagios configuration files

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

Total Warnings: 0
Total Errors: 0

Start Nagios

Enable Nagios to start at system startup / boot

chkconfig --add nagios

chkconfig nagios on

chkconfig httpd on

Start Nagios

service nagios start

Log into Web Interface

http://ip-address/nagios/
Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogplay
Fabio Milano has written 79 articles for us. Fabio Milano is a certified RHCE, MCP, and CFOI. He runs an IT consulting and services company called RDS Support inc. Website:http://www.rdssupport.com
The information provided is for educational purposes only. All content including links and comments is provided "as is" with no warranty, expressed or implied. Use is at your own risk and you are solely responsible for what you do with it.

52 Comments so far

  1. Travis on October 7th, 2009

    Great writeup! One additional would be to include php in your yum install line.

    Thanks!

  2. Fabio Milano on October 10th, 2009

    Thank Travis

    Added php to yum install line

  3. painkiller on October 18th, 2009

    Hi

    I do all you wrote, i get no errors but when i try to logging to the Nagios using the web i get 401 error , i use the user and pass i cretaed in the start.

    any ideas?

  4. Fabio Milano on October 22nd, 2009

    401 is authorization error

    issue with /usr/local/nagios/etc/htpasswd.users

    Check permissions of htpasswd.users and also try again

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

  5. feranbe on October 27th, 2009

    It seems it is working so no it is time to play xD

    Thanks a lot!!

  6. Mahabub on February 9th, 2010

    How can i add host on nagios.. Here another problem when i browse like this http://10.156.0.36/nagios…that time when i click on host i saw an error.whats the reason

  7. Nino Francaviglia on February 15th, 2010

    I got the same 401 error but I could navigate to the left pane menu.

    to fix it i did
    #su -l
    #passwd nagios (reset the nagios password)
    #getenforce
    #setenforce 0
    #chcon -R -t httpd_sys_content_t /usr/local/nagios/sbin/
    #chcon -R -t httpd_sys_content_t /usr/local/nagios/share/

    I was able to see the content in the right frame.

    Hope this helps.

    ciao
    Nino

  8. Ranjith on March 30th, 2010

    Thanks a lot………it is perfect document ..thank u one again..

  9. [...] you want to install Nagios on Centos 5.4? Then this great tutorial is the way to do it.  Worked great for me in my practice [...]

  10. usayg on April 8th, 2010

    Dear Fabio,
    I have my system centos5.4 and i did all nagios configuration with no errors. But i have the problem in viewing in pages using the ip address like http://X.X.X.X/nagios/, i get the message like “Failed to connect”….May i know what sort of error is this?
    My configurations for nagios are as per your steps.
    Expecting a quick response.

    usayg

  11. Fabio Milano on April 9th, 2010

    Need more information

    Are you trying to connect from the machine that has Nagios installed or from another remote machine ?

    If remote machine do you have your firewall open to accept port 80 (web connections)

  12. Nic Matthew on May 16th, 2010

    You could add wget to the yum install line and then instead of downloading and putting in /opt/Nagios just put:

    cd /opt/Nagios

    wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-x.x.x.tar.gz

    wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-x.x.x.tar.gz

    and continue from there.

  13. Frank on July 26th, 2010

    worked like a charm. learning how to use it, thanks for making it easy to install it…

  14. bslater on August 24th, 2010

    Thanks Fabio. This was an outstanding tutorial.

  15. dorothy on September 9th, 2010

    Hi,

    I followed the steps above but I wasn’t able to access http://localhost/nagios. It says “The requested resource (/nagios) is not available.” Did I miss anything?

    Thanks!

  16. Keith Mc on September 15th, 2010

    wow, followed the directions and it’s UP & RUNNING!

    Great Help!!!

  17. Saroj on September 28th, 2010

    Well documented! Worked very well!! It took me a while to figure out that I need to remove a line on contacts.cfg <<***Add you email here****

    Cheers,
    Saroj
    Oxford

  18. Anggi on October 4th, 2010

    Thanks you for Nagions installing guide.

  19. Jmt on October 8th, 2010

    Great tutorial, very helpful. Thanks for sharing.

  20. subramanya on November 1st, 2010

    Its really a nice and good document .. without any error I have installed and configured my Nagios.. Thanks a ton..

  21. Abdel on November 13th, 2010

    I did install the nagios and everything is ok but when I try to get on it !! it gives me this message :

    Internal Server Error

    The server ancountered an internal error or misconfiguration and was unable to complete your requst.

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

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

    Apache/2.2.3 (CentOs) Server at localhost Port 80

    please can anyone help me ?

  22. Csabi on December 8th, 2010

    great how-to;) good job man!

  23. Erin D. on December 11th, 2010

    This was just an awesome, clear, succinct and easy-to-follow tutorial. Thanks so much for putting it out there!

  24. [...] How to install Nagios on Centos 5 | CentOS | Linux Tutorial [...]

  25. nikmit on January 28th, 2011

    Great tut, short and to the point.

    One addition – I had to change SELinux permissions to get this fully working.

    [root@localhost /]# cd /usr/local/nagios/sbin
    [root@localhost sbin]# ls -Z
    -rwxrwxr-x nagios nagios root:object_r:usr_t avail.cgi
    … …

    [root@localhost sbin]# chcon -t httpd_sys_script_exec_t *.cgi

    [root@localhost sbin]# ls -Z
    -rwxrwxr-x nagios nagios root:object_r:httpd_sys_script_exec_t avail.cgi
    … …

  26. Nate Cummings on February 5th, 2011

    [...] Nagios. After doing a little research I came across this link. So far so good, but I follow up on the resolve. This entry was posted in Current Projects. [...]

  27. alex on March 2nd, 2011

    now how do I add hosts to the setup.
    I did everything perfectly and its working just fine.
    I want to add the hosts I have on my network to it.

  28. emirsosa on March 22nd, 2011

    i was getting 404 erros.

    tried trouble shooting but no errors….

    i rebooted server and now it works like a charm!11

    FTW to this guide

  29. Ritesh Sanap on March 25th, 2011

    I m getting an 404 error don’t know y :( , also I m using DirectAdmin and I tried restarting sv but no use , i need it seriously to work so please help

  30. tanou on April 9th, 2011

    please help me these ar my problems
    [root@NAGIOS nagios-3.2.3]# service httpd restart
    bash: service: command not found

  31. brandon on April 12th, 2011

    Excellent write up – worked like a charm!

  32. ravindra on June 3rd, 2011

    Hi,
    whoever gets “internal server error” after succesfully installing nagios from this excellent writeup need not get frustrated.
    That is th result of context settings in ur linux.
    simply change the context and try again.I tried and it worked like a charm. thanks for this write-up.
    Here is the context to be set.
    chcon -R -t httpd_sys_content_t /usr/local/nagios

  33. ravindra on June 6th, 2011

    still if you are finding issues in using nagios interface, chance SElinux from enforcing to permissive
    setenforce 0
    This should work.

  34. Anbarasu on June 9th, 2011

    Hi,

    Really simple and fantastic installation guide.I configured my official mail in the place of root @localhost like me@somedomain.com , I am not getting alerts to that particular id. My question is should i have to install and configure any additional packages like sendmail. I am using centos version 5.2.

    Please guide on this.

    Thanks in Advance

    – Anbu

  35. Rensley Pereira on June 15th, 2011

    Hi,
    Very good installation guide, but i was facing the internal error …and the solution mentioned above does not seem to solve the problem…
    please elaborate..

    thank you in advance

  36. sreejith on June 22nd, 2011

    awesome!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    thank u

  37. Kushal on June 23rd, 2011

    Neat Article… helped me a lot..Will try to contribute from my side whenever required.

  38. nagiosbeginner on July 18th, 2011

    Thank you very much for the great write-up on the Nagios install. I just installed it on CentOS 6.0 with nagios-3-2-3 with nagios-plugins-1.4.15. Also thank you to ravindra for the context change information. That was driving me nuts.

  39. novice on July 20th, 2011

    Hello, really helpful tutorial. Thanks a lot, but please could you advise me if I see missing bin folder in /usr/local/nagios/ ?
    Then I am facing this problem
    /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
    -bash: /usr/local/nagios/bin/nagios: No such file or directory

    Because folder bin is missing, I have centos 6, so I understand it would be the problem.

  40. Raghu on August 8th, 2011

    Hello,

    Everything is fine in the steps but finally when i try to access the URL:- “http:///nagios” it throws an error like (Not Found
    The requested URL /nagios was not found on this server). So Please give a remedy for this..Very Very URGENT.

  41. raghu on August 8th, 2011

    Sorry URL:- “http:///nagios

  42. sunil on August 28th, 2011

    after all steps pls run: chcon -R -t httpd_sys_content_t /usr/local/nagios else you might get “internal server error”

  43. Shafeeq on September 19th, 2011

    good one…..

  44. Orlando on October 18th, 2011

    Unbelievable write-up…Thank you for taking the time, this is excellent work.

    Btw, I also received an Internal Server Error, which was quickly fixed by the “chcon …” command being posted by others.

    Thank you.

  45. Ravi Pundir on October 21st, 2011

    Thank u

    I installed nagios and working fine. Now i want to change web interface port 80 to 10000 for nagios..
    suggest me how can i do that.

    Thanks is advanced.

  46. antony on October 22nd, 2011

    Thank you,

    this post really helped me in installing nagios in my vps…good work :)

  47. hassan on November 3rd, 2011

    403 forbiden

  48. sudhanshu swarnkar on November 17th, 2011

    HI,

    Hello, really helpful tutorial. Thanks a lot, but please could you advise me if I see missing bin folder in /usr/local/nagios/ ?
    Then I am facing this problem
    /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
    -bash: /usr/local/nagios/bin/nagios: No such file or directory

    Because folder bin is missing, I have centos 5.7, so I understand it would be the problem. can you help me beacause i am new about the nagios.

  49. parth on November 26th, 2011

    It’s very good site. nice one

  50. Bill on December 12th, 2011

    Great, great, GREAT write up! Thanks so much for taking the time to do this!

  51. Gabriel on January 18th, 2012

    I’m getting this error:

    Internal Server Error

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

    Please contact the server administrator, webmaster@empresas.peoplenews.me 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.

    Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
    Apache/2.2.3 (CentOS) Server at 50.62.1.231 Port 80

    I tried the “chcon” commands suggested in some of the comments but I always get this message in return:

    chcon: can’t apply partial context to unlabeled file /usr/local/nagios

    Any suggestions?

  52. [...] http://www.kernelhardware.org/install-nagios-on-centos-5/  Print This Post Filed under: Nagios Leave a comment Comments (0) Trackbacks (0) ( subscribe to comments on this post ) [...]

Leave a reply