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/



Great writeup! One additional would be to include php in your yum install line.
Thanks!
Thank Travis
Added php to yum install line
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?
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
It seems it is working so no it is time to play xD
Thanks a lot!!
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
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
Thanks a lot………it is perfect document ..thank u one again..
[...] 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 [...]
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
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)
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.
worked like a charm. learning how to use it, thanks for making it easy to install it…
Thanks Fabio. This was an outstanding tutorial.
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!
wow, followed the directions and it’s UP & RUNNING!
Great Help!!!
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
Thanks you for Nagions installing guide.
Great tutorial, very helpful. Thanks for sharing.
Its really a nice and good document .. without any error I have installed and configured my Nagios.. Thanks a ton..
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 ?
great how-to;) good job man!
This was just an awesome, clear, succinct and easy-to-follow tutorial. Thanks so much for putting it out there!
[...] How to install Nagios on Centos 5 | CentOS | Linux Tutorial [...]
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
… …
[...] 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. [...]
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.
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
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
please help me these ar my problems
[root@NAGIOS nagios-3.2.3]# service httpd restart
bash: service: command not found
Excellent write up – worked like a charm!
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
still if you are finding issues in using nagios interface, chance SElinux from enforcing to permissive
setenforce 0
This should work.
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
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
awesome!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
thank u
Neat Article… helped me a lot..Will try to contribute from my side whenever required.
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.
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.
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.
Sorry URL:- “http:///nagios
after all steps pls run: chcon -R -t httpd_sys_content_t /usr/local/nagios else you might get “internal server error”
good one…..
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.
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.
Thank you,
this post really helped me in installing nagios in my vps…good work
403 forbiden
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.
It’s very good site. nice one
Great, great, GREAT write up! Thanks so much for taking the time to do this!
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?
[...] 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 ) [...]
Please! Help me……
I don’t understand error, Please help me check this error. Thank!
Reading configuration data…
Read main config file okay…
Unable to open main config file ‘/usr/local/nagios/etc/nagios.cfg’
Error processing object config files!
Thank you sir…………………………
why we are using nagios?
what is the use of nagios…………..
Explain in briefly………………….
and their commandsin……………..
thanks so much how to add node to map.
Excellent!
I got da Not Found
The requested URL /nagios/< was not found on this server.
I install it via yum in centos….
what issue could I have?