YouTube Icon

Code Playground.

How to Install and Configure Nagios on Debian 9

CFG

How to Install and Configure Nagios on Debian 9

Nagios is a mainstream open-source checking programming. It keeps a stock of your whole IT foundation and guarantees your organizations, workers, applications, administrations, and cycles are going. If there should be an occurrence of disappointment of a basic foundation part Nagios sends warning cautions. 

This instructional exercise discloses how to introduce and design the most recent rendition of Nagios Core on Debian 9. 

Prerequisites

You'll should be signed in as a client with sudo admittance to have the option to introduce bundles. 

Installing Nagios on Debian

The accompanying advances depicts how to introduce the most recent rendition of Nagios Core from source. 

sudo apt update && sudo apt upgrade
sudo apt install autoconf gcc libc6 make wget unzip apache2 php libapache2-mod-php7.0 libgd-dev
sudo apt install libmcrypt-dev libssl-dev bc gawk dc build-essential libnet-snmp-perl gettext

sudo able introduce libmcrypt-dev libssl-dev bc ogle dc fabricate basic libnet-snmp-perl gettext 

1. Downloading Nagios

Explore to the/usr/src catalog and download the most recent variant of Nagios from the task Github storehouse with wget : 

cd /usr/src/
sudo wget https://github.com/NagiosEnterprises/nagioscore/archive/nagios-4.4.3.tar.gz

Once the download is finished concentrate the tar document : 

sudo tar zxf nagios-*.tar.gz

Prior to proceeding with the following stages, ensure you change to the Nagios source catalog by composing: 

cd nagioscore-nagios-*/

2. Compiling Nagios

Start the manufacture cycle by running the arrange content: 

sudo ./configure --with-httpd-conf=/etc/apache2/sites-enabled

Upon fruitful culmination, you will see the accompanying message: 

*** Configuration summary for nagios 4.4.3 2019-01-15 ***:

 General Options:
 -------------------------
        Nagios executable:  nagios
        Nagios user/group:  nagios,nagios
       Command user/group:  nagios,nagios
             Event Broker:  yes
        Install ${prefix}:  /usr/local/nagios
    Install ${includedir}:  /usr/local/nagios/include/nagios
                Lock file:  /run/nagios.lock
   Check result directory:  /usr/local/nagios/var/spool/checkresults
           Init directory:  /lib/systemd/system
  Apache conf.d directory:  /etc/apache2/sites-enabled
             Mail program:  /usr/sbin/sendmail
                  Host OS:  linux-gnu
          IOBroker Method:  epoll

 Web Interface Options:
 ------------------------
                 HTML URL:  http://localhost/nagios/
                  CGI URL:  http://localhost/nagios/cgi-bin/
 Traceroute (used by WAP):  /usr/sbin/traceroute


Review the options above for accuracy.  If they look okay,
type 'make all' to compile the main program and CGIs.

Run the make order to begin the fabricate cycle: 

sudo make all

The gathering may take some time, contingent upon your framework. When the fabricate cycle is finished, you will see something like this: 

*** Compile finished ***
...
Enjoy.

3. Creating Nagios User And Group

To make another framework nagios client and gathering type: 

sudo make install-groups-users

Add the Apache www-information client to the nagios gathering: 

sudo usermod -a -G nagios www-data

4. Install Nagios Binaries

Run the accompanying order to introduce Nagios paired documents, CGIs, and HTML records: 

sudo make install

You should see the accompanying yield: 

*** Main program, CGIs and HTML files installed ***

5. Creating External Command Directory

Make the outside order index and set the correct consents by composing: 

sudo make install-commandmode
*** External command directory configured ***

6. Install Nagios Configuration Files

Introduce the example Nagios setup records with: 

sudo make install-config
*** Config files installed ***

Remember, these are *SAMPLE* config files.  You'll need to read
the documentation for more information on how to actually define
services, hosts, etc. to fit your particular needs.

7. Install Apache Configuration Files

The order underneath will make the Apache design records: 

sudo make install-webconf
*** Nagios/Apache conf file installed ***

Ensure Apache revamp and cgi modules are empowered: 

sudo a2enmod rewrite
sudo a2enmod cgi

8. Creating Systemd Unit File

The accompanying order introduces a systemd unit document and empowers the Nagios administration to begin on boot. 

sudo make install-daemoninit
...
*** Init script installed ***

9. Creating User Account

To have the option to get to the Nagios web interface you'll have to make an administrator client. 

In this instructional exercise we will make a client named nagiosadmin: 

sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

You will be incited to enter and affirm the client's secret phrase. 

New password: 
Re-type new password: 
Adding password for user nagiosadmin

Restart the Apache administration for changes to produce results: 

sudo systemctl restart apache2

10. Configuring Firewall

The firewall will make sure about your worker against undesirable traffic. 

In the event that you don't have a firewall designed on your worker, you can check our guide about how to arrangement a firewall with ufw on Debian 

Open the Apache ports by composing: 

sudo ufw allow Apache

Installing Nagios Plugins

Switch back to the/usr/src index and download the most recent rendition of the Nagios Plugins from the undertaking Github storehouse : 

album/usr/src/ 

sudo wget -O nagios-plugins.tar.gz https://github.com/nagios-plugins/nagios-plugins/archive/release-2.2.1.tar.gz

Once the download is finished concentrate the tar record by composing: 

sudo tar zxf nagios-plugins.tar.gz

Change to the modules source registry: 

cd nagios-plugins-release-2.2.1

Show the accompanying orders balanced to aggregate and introduce the Nagios modules: 

sudo ./tools/setup
sudo ./configure
sudo make
sudo make install

Starting Nagios

Since You have Nagios introduced on your Debian worker, start it with: 

sudo systemctl start nagios

To confirm that Nagios is running, check the administration status: 

sudo systemctl status nagios

The yield should look something like underneath demonstrating that Nagios administration is dynamic and running. 

? nagios.service - Nagios Core 4.4.3
   Loaded: loaded (/lib/systemd/system/nagios.service; enabled; vendor preset: enabled)
   Active: active (running) since Sun 2019-02-10 17:07:21 CST; 9s ago
     Docs: https://www.nagios.org/documentation
  Process: 26241 ExecStart=/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg (code=exited, status=0/SUCCESS)
  Process: 26239 ExecStartPre=/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg (code=exited, status=0/SUCCESS)
 Main PID: 26243 (nagios)
    Tasks: 6 (limit: 4915)
   CGroup: /system.slice/nagios.service

Accessing the Nagios Web Interface

To get to the Nagios web interface open your number one program and type your worker's space name or public IP address followed by/nagios: 

http(s)://your_domain_or_ip_address/nagios

Enter the nagiosadmin client login certifications and you will be diverted to the default Nagios landing page as appeared on the picture underneath: 

Conclusion

You have effectively introduced the most recent Nagios rendition from source on your Debian framework. 

You should now visit the Nagios Documentation and study how to arrange and utilize Nagios. 

On the off chance that you hit an issue or have input, leave a remark underneath.




CFG