12 December, 2014

Install Nagios Core 4.0.8 on Ubuntu Server 14.10

Command sequence for compiling and installing Nagios Core 4.0.8 and Nagios Plugins 2.0.3 on Ubuntu Server 14.10.

sudo apt-get install apache2
sudo apt-get install libapache2-mod-php5
sudo apt-get install build-essential
sudo apt-get install libgd2-xpm-dev
sudo useradd nagios
sudo passwd nagios
/usr/sbin/groupadd nagcmd
/usr/sbin/usermod -a -G nagcmd nagios
/usr/sbin/usermod -a -G nagcmd www-data
tar xzvf nagios-4.0.8.tar.gz
cd nagios-4.0.8
./configure  --with-nagios-group=nagios --with-command-group=nagcmd --with-httpd-conf=/etc/apache2
make all
make install
make install-init
make install-config
make install-commandmode
nano /usr/local/nagios/etc/objects/contacts.cfg # change email
make install-webconf
apt-get install apache2-utils # for next command
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagios # Create a nagiosadmin account for logging into the Nagios web interface
tar xzvf nagios-plugins-2.0.3.tar.gz
cd nagios-plugins-2.0.3/
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install
ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
cat /etc/apache2/nagios.conf >> /etc/apache2/apache2.conf

Add following code after DocumentRoot line inside /etc/apache2/sites-enabled/000-default.conf:
ScriptAlias /cgi-bin/ /var/cgi-bin/ 
<Directory "/var/cgi-bin">    
AllowOverride None    
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch    
Require all granted 
</Directory>


Continue...
ln -s /etc/apache2/mods-available/cgid.load /etc/apache2/mods-enabled/
ln -s /etc/apache2/mods-available/cgid.conf /etc/apache2/mods-enabled/
sudo a2enmod cgi
/etc/init.d/apache2 reload
/etc/init.d/nagios start

http://localhost/nagios should be running by now.

If you get an error like:
It appears as though you do not have permission to view information for any of the services you requested...
If you believe this is an error, check the HTTP server authentication requirements for accessing this CGI and check the authorization options in your CGI configuration file.

then make sure that /usr/local/nagios/etc/cgi.cfg contains correct values for:
authorized_for_system_information=nagios
authorized_for_configuration_information=nagios
authorized_for_system_commands=nagios
authorized_for_all_services=nagios
authorized_for_all_hosts=nagios
authorized_for_all_service_commands=nagios
authorized_for_all_host_commands=nagios

After changes restart nagios and apache2 services:
service nagios restart
service apache2 restart

No comments:

Post a Comment