Prerequisites
=========
* Apache
* PHP
* GCC compiler
* GD development libraries
Steps
====
sudo yum install httpd php
sudo yum install gcc glibc glibc-common
sudo yum install gd gd-devel
Create Users
=========
sudo adduser -m nagios
sudo passwd nagios
sudo groupadd nagcmd
sudo usermod -a -G nagcmd nagios
sudo usermod -a -G nagcmd apache
Download Nagios Core
=================
mkdir ~/downloads
cd ~/downloads
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.0.8.tar.gz
wget http://nagios-plugins.org/download/nagios-plugins-2.0.3.tar.gz
Compile and Install Nagios
====================
tar zxvf nagios-4.0.8.tar.gz
cd nagios-4.0.8
./configure --with-command-group=nagcmd
make all
sudo make install
sudo make install-init
sudo make install-config
sudo make install-commandmode
Customize Configuration
==================
Sample configuration files have now been installed in the /usr/local/nagios/etc directory. These sample files should work fine for getting started with Nagios. You'll need to make just one change before you proceed...
Edit the /usr/local/nagios/etc/objects/contacts.cfg config file with your favorite editor and change the email address associated with the nagiosadmin contact definition to the address you'd like to use for receiving alerts.
sudo vim /usr/local/nagios/etc/objects/contacts.cfg
Configure the Web Interface
====================
Install the Nagios web config file in the Apache conf.d directory.
sudo make install-webconf
Create a nagiosadmin account for logging into the Nagios web interface. Remember the password you assign to this account - you'll need it later.
sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Type the new password twice. Restart Apache to make the new settings take effect.
sudo service httpd restart
Compile and Install the Nagios Plugins
============================
cd ~/downloads
tar zxvf nagios-plugins-2.0.3.tar.gz
cd nagios-plugins-2.0.3
Compile and install the plugins.
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
sudo make install
Start Nagios
=========
sudo chkconfig --add nagios
sudo chkconfig nagios on
Verify the sample Nagios configuration files.
sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
If there are no errors, start Nagios.
sudo service nagios start
Enable 80 port in AWS
=================
* From the EC2 console select Security Groups from the left navigation pane.
* Select the Security Group applicable for the instance that Nagios was installed on and open the Inbound tab
* If there is no rule to allow HTTP traffic on port 80 then click edit in the Inbound tab to add a new rule
* Click on New Rule button
* Scroll down to select HTTP from the list under Type
* If you want to be able to access nagios from anywhere then select Save, otherwise enter the IP address or range of IP address you want to be able to access it from then select Save.
Access Nagios
===========
http://ec2-xx-xxx-xxx-xx.ap-southeast-2.compute.amazonaws.com/nagios/