Ubuntu under Nagios installation (source website)
Https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/4/en/toc.html
Https://support.nagios.com/kb/article/nagios-core-installing-nagios-core-from-source.html#Ubuntu
security-enhanced Linux
This are based on the SELinux being disabled or in permissive mode. SELinux is not enabled by default on Ubuntu. If you would if it is installed run the following command:
sudo dpkg-l selinux*
Prerequisites
Perform These steps to install the pre-requisite packages.
===== Ubuntu 13.x/14.x/15.x =====
sudo apt-get update
sudo apt-get install-y autoconf gcc libc6 make wget unzip apache2 apache2-utils php5 Libgd2-xpm-dev
===== Ubuntu 16.x/17.x =====
sudo apt-get update
sudo apt-get install-y autoconf gcc libc6 make wget unzip apache2 php libapache2-mod-php7.0 Libgd2-xpm-dev
Downloading the Source
Cd/tmp
Wget-o nagioscore.tar.gz https://github.com/NagiosEnterprises/nagioscore/archive/nagios-4.3.4.tar.gz
Tar xzf nagioscore.tar.gz
Compile
cd/tmp/nagioscore-nagios-4.3.4/
sudo./configure--with-httpd-conf=/etc/apache2/sites-enabled
sudo make all
Create User and Group
This creates the Nagios user and group. The Www-data user is also added to the Nagios group.
sudo useradd Nagios
sudo usermod-a-G Nagios www-data
Install Binaries
This step installs the binary files, CGIs, and HTML files.
sudo make install
Install Service/daemon
This installs the service or daemon files and also configures them to start on boot.
sudo make Install-init
sudo update-rc.d nagios defaults
Information on starting and stopping services would be is explained further on.
Install Command Mode
This installs and configures the external command file.
sudo make Install-commandmode
Install Configuration Files
This installs the *sample* configuration files. These is required as Nagios needs some configuration files to allow it to start.
sudo make Install-config
Install Apache Config Files
This installs the Apache Web server configuration files and configures Apache settings.
sudo make install-webconf
sudo a2enmod rewrite
sudo a2enmod CGI
Configure Firewall
You need to allow port inbound traffic on the local firewall so can reach the Nagios Core Web interface.
sudo ufw allow Apache
sudo ufw reload
Create nagiosadmin User Account
You'll need to create a Apache user account to being able to log into Nagios.
The following command would create a user account called Nagiosadmin and you'll be prompted to provide a password for the Account.
sudo htpasswd-c/usr/local/nagios/etc/htpasswd.users nagiosadmin
When adding additional users on the future, you need to remove-c from the above command otherwise it'll replace the Exi Sting Nagiosadmin User (and any and all other users) are added.
Start Apache Web Server
===== Ubuntu 13.x/14.x =====
Need to restart it because it is already running.
sudo service apache2 restart
===== Ubuntu 15.x/16.x/17.x =====
Need to restart it because it is already running.
sudo systemctl restart Apache2.service
Start Service/daemon
This command starts Nagios Core.
===== Ubuntu 13.x/14.x =====
sudo service Nagios start
===== Ubuntu 15.x/16.x/17.x =====
sudo systemctl start Nagios.service
Test Nagios
Nagios is now running, to confirm this need to log into the Nagios Web Interface.
Point your Web browser to the IP address or FQDN of your Nagios Core server, for example:
Http://10.25.5.143/nagios
Http://core-013.domain.local/nagios
You'll be prompted for a username and password. The username is nagiosadmin (your created it in a previous step) and the password are what do you provided earlier.
Once you has logged in you is presented with the Nagios interface. Congratulations you have installed Nagios Core.
But WAIT ...
Currently you has only installed the Nagios Core engine. You ' ll notice some errors under the hosts and services along the lines of:
(No output on stdout) STDERR:EXECVP (/usr/local/nagios/libexec/check_load, ...) failed. errno is 2:no such file or directory
These errors'll be resolved once you install the Nagios Plugins, which are covered in the next step.
Installing the Nagios Plugins
Nagios Core needs plugins to operate properly. The following steps would walk you through installing Nagios Plugins.
These steps install Nagios-plugins 2.2.1. Newer versions would become available in the future and you can use those in the following installation steps. Please see the releases page on GitHub for all available versions.
Please note that the following steps install the most of the plugins that come in the Nagios plugins package. However there is some plugins that require other libraries which is not included in those instructions. Refer to the following KB article for detailed installation instructions:
Documentation-installing Nagios Plugins from Source
Prerequisites
Make sure the following packages installed.
sudo apt-get install-y autoconf gcc libc6 libmcrypt-dev make libssl-dev wget BC gawk DC build-essential SNMP libnet-snmp- Perl GetText
Downloading the Source
Cd/tmp
wget--no-check-certificate-o nagios-plugins.tar.gz https://github.com/nagios-plugins/nagios-plugins/archive/ Release-2.2.1.tar.gz
Tar zxf nagios-plugins.tar.gz
Compile + Install
Cd/tmp/nagios-plugins-release-2.2.1/
sudo./tools/setup
sudo./configure
sudo make
sudo make install
Test Plugins
Point your Web browser to the IP address or FQDN of your Nagios Core server, for example:
Http://10.25.5.143/nagios
Http://core-013.domain.local/nagios
Go to a host or service object and "Re-schedule the next check" under the Commands menu. The error you previously saw should now disappear and the correct output would be shown on the screen.
Service/daemon Commands
Different Linux Distributions has Different methods of Starting/stopping/restarting/status Nagios.
===== Ubuntu 13.x/14.x =====
sudo service Nagios start
sudo service Nagios stop
sudo service Nagios restart
sudo service Nagios status
===== Ubuntu 15.x/16.x/17.x =====
sudo systemctl start Nagios.service
sudo systemctl stop Nagios.service
sudo systemctl restart Nagios.service
sudo systemctl status Nagios.service
Ubuntu under Nagios installation (source website)