Below I am going to outline how to install Nagios 3.5.0 on CentOS 6.4 from source. I'm assuming that you are starting from a clean minimal install of CentOS
Ok first lets get the needed packages
yum install wget httpd php gcc glibc glibc-common gd gd-devel make net-snmp libssl-dev openssl* wget policycoreutils-python
Now lets get nagios and it's plugins, at this time the link below was the most up to date, but you can verify this by omitting the data after the last trailing slash.
cd /tmp
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.5.0.tar.gz
wget http://sourceforge.net/projects/nagiosplug/files/nagiosplug/1.4.16/nagios-plugins-1.4.16.tar.gz
Now unpack and lets start with Nagios fist:
gunzip *.gz
tar xf nagios-3.5.0.tar
cd nagios
/usr/sbin/adduser nagios
/usr/sbin/groupadd nagcmd
usermod -a -G nagcmd nagios
./configure --with-command-group=nagcmd
make all
make install
make install-init
make install-config
make install-commandmode
make install-webconf
chkconfig --add nagios
chkconfig --level 35 nagios on
chkconfig --add httpd
chkconfig --level 35 httpd on
#Create a nagios login
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Now lets get those plugins working.
cd /tmp
tar xf nagios-plugins-1.4.16.tar
cd nagios-plugins-1.4.16
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install
Now check your base build, if you get any errors, you will need to fix them first
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Now start it up
service nagios start
service httpd start
#Add port 80 to your iptables
vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
#Now restart
service iptables restart
Now, here is where I want to strangle most other websites... DO NOT disable selinux! It's dumb to not just properly configure it! Below I will help you to authorize Nagios in SElinux.
chcon -R -t httpd_sys_content_t /usr/local/nagios
set enforce 0
chcon -R -t httpd_sys_script_t /usr/local/nagios/var/rw/nagios.cmd
set enforce 1
If you find that you are getting blocked cmd in nagios, run the following to fix it.
grep denied /var/log/audit/audit.log |audit2why
audit2allow -a
#For each context header (IE httpd_sys_script_t) run
audit2allow -a -M httpd_sys_script_t
#Then activate each header
semodule -i httpd_sys_script_t.pp
#repeat
That should do it, to add hosts, you need to edit the files in /usr/local/nagios/etc/objects/
If this was helpful, please let others know in the comments below!