{"id":382,"date":"2018-08-17T23:40:23","date_gmt":"2018-08-17T20:40:23","guid":{"rendered":"http:\/\/kifarunix.com\/?p=382"},"modified":"2024-03-10T17:44:09","modified_gmt":"2024-03-10T14:44:09","slug":"how-to-install-and-configure-nagios-core-on-ubuntu-18-04","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/how-to-install-and-configure-nagios-core-on-ubuntu-18-04\/","title":{"rendered":"Install and Configure Nagios Core from Repos on Ubuntu 18.04"},"content":{"rendered":"\n
In this tutorial we are going to learn how to install and configure Nagios Core<\/a> from Repos on Ubuntu 18.04. Nagios is an enterprise grade free and open source software that can be used to monitor servers, applications and networks. It also offers alerting services for servers, switches, applications and services. Nagios supports both agentless and agent based monitoring.<\/p>\n\n\n\n Ubuntu 18.04 default APT repos do not provide latest versions of Nagios Core. Nagios Core 4.4.5 is the current stable release version. Ubuntu 18.04 APT repos provide Nagios Core 3.5.1.<\/p>\n\n\n\n Thus, this guide is a bit dated.<\/p>\n\n\n\n To ensure you are running latest version of Nagios Core server on Ubuntu 18.04, check the guide below on how to build Nagios Core from source on Ubuntu 18.04.<\/p>\n\n\n\n Install and Configure Nagios Core From Source on Ubuntu 18.04<\/a><\/p>\n\n\n\n There are two ways in which Nagios can be installed;<\/p>\n\n\n\n In this tutorial, we will learn how to install Nagios Core On Ubuntu 18.04 from the repos.<\/p>\n\n\n\n If you want to build Nagios from source code on Ubuntu 18.04, then follow the link below;<\/p>\n\n\n\n Run system update<\/p>\n\n\n\n Before you can install Nagios from repos, ensure that apache http server as well as the necessary php modules are already installed. See installation command below:<\/p>\n\n\n\n Once the above packages are install, install Nagios and the plugins to monitor Nagios server itself.<\/p>\n\n\n\n During installation you will be required to select the mail server configuration type that best meets your needs as well as the admin password for login in to Nagios web console.<\/p>\n\n\n\n After you enter the above details, installation will proceed. Once the installation is complete, configure Nagios as follows:<\/p>\n\n\n\n Configure Nagios to check external commands and enable the use of CGI command interface by editing Nagios configuration file and changing the value of check_external_commands<\/strong> to 1 as shown below.<\/p>\n\n\n\n To limit access to Nagios Server to specific hosts or networks, open the nagios apache configuration file and comment out the line; Allow From All<\/strong> and specify the hosts\/networks to allow as shown below.<\/p>\n\n\n\n For my case since this is just for learning purposes, I will leave the defaults settings, Allow From All<\/strong>.<\/p>\n\n\n\n Edit the nagios service configuration file and make the changes as follows;<\/p>\n\n\n\n This lines add the read write permissions to the external command file, a file that Nagios checks for external command requests and is also where the command CGI will write commands that are submitted by users. Since the file is deleted every time its contents are processed, this ensures that the permissions are set whenever new file is created.<\/p>\n\n\n\n Change the group of the \/var\/lib\/nagios3\/<\/strong> to apache www-data<\/strong> group.<\/p>\n\n\n\n Set the read and execute<\/strong> permissions on the group of directory holding the external command files, \/var\/lib\/nagios3\/rw\/.<\/strong><\/p>\n\n\n\n Start and enable both apache and nagios to start on boot.<\/p>\n\n\n\n Now access the Nagios web interface using the following URL, http:\/\/<ip-address>\/nagios3<\/strong>.<\/p>\n\n\n\n You will prompted to enter the basic authentication username and password to access the dashboard.<\/p>\n\n\n\n Login as nagiosadmin using the password you set above. When you login, this dashboard below welcomes you.<\/p>\n\n\n\n You can view system status by clicking on the Tactical Overview<\/strong> option on the left panel under Current Status.<\/strong><\/p>\n\n\n\n There you go, you have successfully installed and configured Nagios Core on Ubuntu 8.04 and that marks the end of our guide on how to install Nagios Core from Repos on Ubuntu 18.04.<\/p>\n\n\n\n Monitor Linux Hosts using Nagios check_by_ssh Plugin<\/a><\/p>\n\n\n\n Add Hosts to Nagios Server For Monitoring<\/a><\/p>\n\n\n\n Monitor SSL\/TLS Certificates Expiry with Nagios<\/a><\/p>\n\n\n\nInstall Nagios Core from Repos on Ubuntu 18.04<\/h2>\n\n\n\n
\n
Install and Configure Nagios Core on Ubuntu 18.04<\/h3>\n\n\n\n
apt -y install apache2 php php-cgi libapache2-mod-php php-common php-pear php-mbstring<\/code><\/pre>\n\n\n\n
apt -y install nagios3 nagios-plugins-basic<\/code><\/pre>\n\n\n\n
\n...\nPlease select the mail server configuration type that best meets your needs.\n\nNo configuration:\nShould be chosen to leave the current configuration unchanged.\nInternet site:\nMail is sent and received directly using SMTP.\nInternet with smarthost:\nMail is received directly using SMTP or by running a utility such\nas fetchmail. Outgoing mail is sent using a smarthost.\nSatellite system:\nAll mail is sent to another machine, called a 'smarthost', for delivery.\nLocal only:\nThe only delivered mail is the mail for local users. There is no network.\n\n1. No configuration 2. Internet Site 3. Internet with smarthost 4. Satellite system 5. Local only\n\nGeneral type of mail configuration: 1<\/strong>\n\n\nConfiguring nagios3-cgi\n-----------------------\n\nPlease provide the password to be created with the \"nagiosadmin\" user.\n\nThis is the username and password you will use to log in to your nagios installation after configuration is complete. If you do not provide a password, you will have to configure access to nagios yourself.\n\nNagios web administration password: Enter you password<\/strong>\n\nPassword confirmation: Confirm your password\n...<\/strong>\n<\/code><\/pre>\n\n\n\n
vim \/etc\/nagios3\/nagios.cfg<\/code><\/pre>\n\n\n\n
\n...<\/strong>\n# EXTERNAL COMMAND OPTION\n# This option allows you to specify whether or not Nagios should check\n# for external commands (in the command file defined below). By default\n# Nagios will *not* check for external commands, just to be on the\n# cautious side. If you want to be able to use the CGI command interface\n# you will have to enable this.\n# Values: 0 = disable commands, 1 = enable commands\n\ncheck_external_commands=1\n...<\/strong>\n<\/code><\/pre>\n\n\n\n
vim \/etc\/nagios3\/apache2.conf<\/code><\/pre>\n\n\n\n
\n ...\n <IfVersion < 2.3>\n Order Allow,Deny\n # Allow From All\n<\/strong> Allow From localhost 192.168.0.0\/24\n<\/strong> <IfVersion>\n...\n<\/code><\/pre>\n\n\n\n
\n143 if ! check_started; then\n144 if ! check_named_pipe; then\n145 log_action_msg \"named pipe exists - removing\"\n146 rm -f $nagiospipe\n147 fi\n148 if check_config; then\n149 start_daemon -n $NICENESS -p $THEPIDFILE $DAEMON -d $NAGIOSCFG\n150 chmod o+rw \/var\/lib\/nagios3\/rw\/nagios.cmd<\/strong>\n151 ret=$?\n152 else\n<\/code><\/pre>\n\n\n\n
chgrp -R www-data \/var\/lib\/nagios3\/<\/code><\/pre>\n\n\n\n
chmod 750 \/var\/lib\/nagios3\/rw\/<\/code><\/pre>\n\n\n\n
systemctl enable apache2;systemctl start apache2\nsystemctl enable nagios3;systemctl start nagios3<\/code><\/pre>\n\n\n\n
<\/figure>\n\n\n\n
<\/figure>\n\n\n\n
<\/figure>\n\n\n\n
Nagios Related Tutorials<\/h3>\n\n\n\n