Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Monitoring Tools»Nagios»How To Install Nagios Server In Ubuntu & Debian

    How To Install Nagios Server In Ubuntu & Debian

    By RahulFebruary 8, 20234 Mins Read

    Nagios is an open-source monitoring tool that is used to monitor hosts, services, and network devices. It provides real-time monitoring, alerting, and reporting capabilities to help you proactively identify and resolve issues in your IT environment. In this article, we will show you how to install Nagios Server on Ubuntu & Debian, including the prerequisites, installation process, and configuration steps.

    Advertisement

    Nagios Server is the central component of the Nagios monitoring system. It collects data from remote hosts, services, and network devices, and displays the information in a web interface. Nagios Server can be installed on a variety of operating systems, including Ubuntu & Debian. In this article, we will focus on installing Nagios Server on Ubuntu & Debian systems.

    How to Monitor remote Linux host using Nagios
    How to Monitor remote Windows host using Nagios

    Prerequisites

    Before installing Nagios Server, you should have the following prerequisites:

    • A fresh installation of Ubuntu or Debian.
    • A non-root user with sudo privileges.
    • Internet connection to download the required packages.

    Step 1: Update the System

    Before installing any new packages, it is always recommended to update the system with the latest security patches and bug fixes. Run the following command to update the system:

    sudo apt update && sudo apt upgrade 
    

    Step 2: Install Required Packages

    Before installing Nagios, you need to install some required packages including Apache, PHP, and GCC. Run the following command to install them:

    sudo apt install -y build-essential libgd2-xpm-dev openssl libssl-dev apache2 apache2-utils 
    

    Step 3: Create a Nagios User and Group

    First of all, create a nagios user using the following command:

    sudo adduser nagios 
    

    Then create a group for Nagios setup “nagcmd” and add nagios user to this group. Also, add nagios user in the Apache group.

    sudo groupadd nagcmd 
    sudo usermod -a -G nagcmd nagios 
    sudo usermod -a -G nagcmd www-data 
    

    Step 4: Download Nagios Core

    You can download Nagios Core from the official website using the wget command. Run the following command to download the latest version of Nagios Core:

    wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.10.tar.gz 
    

    After downloading the package, extract it using the tar command. Run the following command to extract the package:

    tar xzf nagios-4.4.10.tar.gz 
    

    Step 5: Compile and Install Nagios Core

    Go to the extracted directory and run the following commands to compile and install Nagios Core:

    cd nagios-4.4.10 
    sudo ./configure --with-command-group=nagcmd --with-httpd-conf=/etc/apache2/sites-enabled 
    sudo make all 
    sudo make install 
    sudo make install-init 
    sudo make install-config 
    sudo make install-commandmode 
    

    Now create an Apache configuration file for your Nagios server as below:

    sudo make install-webconf 
    

    Now copy event handlers scripts under libexec directory. These binaries provides multiple events triggers for your Nagios web interface.

    sudo cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/ 
    sudo chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers 
    

    Step 6: Configure Apache Web Server

    We need to setup apache authentication for user nagiosadmin. Until more specific reason use this username as “nagiosadmin” else you would require more changes in configuration.

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

    Now enable Apache configuration and restart Apache service to make the new settings take effect.

    sudo a2enmod cgi rewrite 
    sudo systemctl restart apache2  
    

    Step 7: Install Nagios Plugins

    After installing and configuring Nagios core service, Download latest nagios-plugins source and install using the following commands.

    wget http://www.nagios-plugins.org/download/nagios-plugins-2.4.3.tar.gz 
    tar xzf nagios-plugins-2.4.3.tar.gz 
    cd nagios-plugins-2.4.3 
    

    Now compile and install Nagios plugins

    sudo ./configure --with-nagios-user=nagios --with-nagios-group=nagcmd --with-openssl 
    sudo make 
    sudo make install 
    

    Step 8: Start Nagios Service

    Use the Nagios commands to verify the Nagios installation and configuration file.

    /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg 
    

    After successfully verify start the Nagios core service and enable auto-start on system boot..

    sudo systemctl start nagios 
    sudo systemctl enable nagios 
    

    Step 9: Access Nagios Web Interface

    You can access the Nagios web interface by opening a web browser and entering the following URL:

  • http://system-ip-or-hostname/nagios/
  • You will be prompted to enter a username and password. Use the credentials you created in step 6 (nagiosadmin/password) to log in.

    Installing Nagios Server on Ubuntu & Debian
    Nagios user authentication

    Once you are logged in, you will see the Nagios dashboard that displays the status of all the hosts and services being monitored.

    Install Nagios Server on Ubuntu & Debian
    Nagios dashboard

    Finally, You have successfully installed and configured Nagios Monitoring Server core service in your system. Now visit net article to monitor Linux host and Windows host using Nagios server.

    Conclusion

    In this article, we have introduced Nagios Server, its importance, and the installation process for Ubuntu & Debian systems. Installing Nagios Server will allow you to monitor your IT environment and ensure that critical systems and services are functioning correctly. By following the steps outlined in this article, you can get started with Nagios Server and take the first step towards proactively managing your IT environment.

    monitoring nagios nagios server NRPE
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    Bash Script to Monitor Disk Space and Notify

    Shell Script to Monitor Disk Space and Send Alert

    How to Install Nagios Client (NRPE) on Ubuntu 20.04

    Installing Nagios on Ubuntu

    How to Install Nagios Server on Ubuntu 20.04

    View 26 Comments

    26 Comments

    1. Vasil German on December 22, 2019 6:22 pm

      bro, let me know why you don’t just keep it simple ?
      apt update && apt install nagios3
      on ubuntu 1604 works fine

      Reply
    2. Steven on August 31, 2019 11:49 am

      Thank you for your clear instructions for installing Nagios on Ubuntu. Can you also provide instructions on upgrading Nagios. Thank you.

      Reply
    3. Mubarak on June 6, 2019 9:36 am

      Please I can’t install, I’ve error while using command $ sudo make install

      That’s what my prompt show me:

      [email protected]:/opt/nagios-4.4.3# make install
      cd ./base && make install
      make[1] : on entre dans le répertoire « /opt/nagios-4.4.3/base »
      make install-basic
      make[2] : on entre dans le répertoire « /opt/nagios-4.4.3/base »
      /usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/bin
      /usr/bin/install: utilisateur «nagios» incorrect
      Makefile:183: recipe for target ‘install-basic’ failed
      make[2]: *** [install-basic] Error 1
      make[2] : on quitte le répertoire « /opt/nagios-4.4.3/base »
      Makefile:176: recipe for target ‘install’ failed
      make[1]: *** [install] Error 2
      make[1] : on quitte le répertoire « /opt/nagios-4.4.3/base »
      Makefile:276: recipe for target ‘install’ failed
      make: *** [install] Error 2
      [email protected]:/opt/nagios-4.4.3#

      How could I fix it?

      Reply
      • Luana Patricia on September 20, 2019 8:20 am

        Same problem… There isn’t nagios folder in usr. Did you fix this?

        Reply
      • services on October 11, 2019 10:42 am

        bonjour ,fait la mise ajours et relance ,je pense cela pouvait passe

        Reply
    4. sandeep on May 12, 2019 3:38 am

      dont we need nrpe too? I cannot find check_nrpe in the server

      Reply
    5. james H on April 25, 2019 7:30 pm

      Great work – a clear and accurate guide that got Nagios up and working on my server within 20 minutes. Thank you!

      Reply
    6. gchris96 on April 22, 2019 8:32 pm

      Bless up good man

      Reply
    7. AMA on March 14, 2019 5:24 pm

      You are a guru. I install cacti and Nagios on the same server . Things are functionning well as for now .

      Reply
    8. Wahab on March 12, 2019 11:30 am

      Dear Rahul.

      Need some experts opinion regarding my problem i.e. my nagios statumap is mess up , i have number of switches to monitor, but problem is that they are so much congested that , cant even read there name properly. What i want is that my statusmap should be scattered around the rrot Host.
      thanks

      Reply
    9. Antoine on March 2, 2019 1:31 pm

      when I finish all configurations and then get start web server, after autehtification
      I get this massage
      “Unable to get process status” I’m using nagios 4.3.4 in ubuntu 18.04

      Need help

      Reply
    10. rohit on February 24, 2019 11:34 am

      Nagios is running on cli but when I am hitting in browser it is not loading say took too long to respond

      Reply
      • D.mohankrishna on April 16, 2022 4:25 pm

        Give Nagios default port number 80 to your server then retry.

        Reply
    11. pipa on January 12, 2019 1:21 am

      Hi,

      Have installed it and working but getting error when adding devices. Can you please tell me where to added on this template and a basic format. Want to add one device for ping.

      Thanks..

      Pipa

      Reply
      • Rahul on January 16, 2019 4:52 am

        For ping check, nothing required to install on remote devices. You can try with NagiosQL, which provides an easy to configure interface for Nagios

        https://tecadmin.net/install-nagiosql-with-nagios-core-on-centos-rhel/

        Reply
    12. Smuv on December 5, 2018 4:46 am

      Thanks for the walkthrough tutorial, I was able to install the following:
      nagios-4.4.2.tar.gz
      nagios-plugins-2.2.1.tar.gz

      Reply
      • Rahul on December 6, 2018 4:07 am

        Thanks Smuv, Article has been updated with the latest stable release version.

        Reply
    13. Neil on April 24, 2018 8:20 pm

      Everything worked until I went to select Hosts, Service or anything like that. It prompts me what to do with the .cgi file.

      The frustrating thing of upgrading from an older version of Nagios is EVERYONE DOES THE INSTALL DIFFERENTLY!! Yes, I am meaning to yell. You get used to placing checks in certain places and then and upgrade breaks that.

      How do I fix the .cgi issue??

      Reply
    14. Richard J Campbell on November 21, 2017 7:42 pm

      A great walk-through. I’ve been through a couple over the last week and this one was the most concise. the only issue was not having NAGIOS service so I couldn’t complete steps 6B & C. I was able to resolve this by (I used VIM text editor and then did ESC : wq).

      Create the nagios.service file

      # vi /etc/systemd/system/nagios.service
      [Unit]
      Description=Nagios
      BindTo=network.target

      [Install]
      WantedBy=multi-user.target

      [Service]
      User=nagios
      Group=nagios
      Type=simple
      ExecStart=/usr/local/nagios/bin/nagios /usr/local/nagios/etc/nagios.cfg
      # systemctl enable /etc/systemd/system/nagios.service
      # systemctl start nagios
      # systemctl status nagios

      After that you need to restart the Nagios Service.

      # /etc/init.d/nagios restart
      That’s it you should now be able to access Nagios WEBUI.

      It didn’t work initially, but a reboot resolved it.

      Reply
    15. Patrick on March 31, 2017 8:11 pm

      This worked pretty well for me. There were two kinks I had to work out and then it worked awesome.

      First: the makefile needs “unzip” and that was not installed on my system (Ubuntu 16.04). May I suggest adding that to the list of prerequisites.
      Second: “make install-init” did not install the service for systemd. I had to do that by hand. That’s obviously not a criticism of this tutorial, but a warning to others that install from source.

      Nice job, Rahul.

      Reply
    16. jashir on November 8, 2016 5:24 pm

      When i try to login to Nagios in my web browser and after having repeatedly enter my login and password on my Nagios page , i get this :

      Authorization Required

      This server could not verify that you are authorized to access the document requested. Either you supplied the wrong credentials (e.g., bad password), or your browser doesn’t understand how to supply the credentials required. Apache/2.2.15 (Red Hat) Server at 127.0.0.1 Port 80

      Reply
    17. jashir on November 8, 2016 9:54 am

      I had followed your instruction and completed the installation but i am unable to login in to nagios web interface because of apache2 authentication is not accepting username and password. what is the default username here ?

      Reply
    18. Dharxan on October 13, 2016 1:03 pm

      Thanks Rahul, best instructions I have seen so far and worked for me.

      I am running ubuntu 14.04 in VMware Fusion (mac install)

      Though I had a small make install error but cleared after I run,
      apt-get install unzip.

      Reply
    19. Sean on November 28, 2015 4:33 pm

      Couldnt do it !
      Failed @ $ htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

      Also could not restart apache2 server -[fail]

      Reply
      • Rahul on December 1, 2015 1:35 pm

        Hi Sean

        What error are you getting with htpasswd command ?

        Reply
    20. Venkatraman on April 19, 2015 2:46 am

      @ackbote:

      i have created a script for auto-installation, for “nagios-core 4.0.8 with plugins 2.0.3” and auto-configuration on ubuntu machin, within 10 mins, just have to add password to default user: nagiosadmin, try this git:

      $ sudo git clone https://github.com/slktechlabs/nagios /tmp/nagios && cd /tmp/nagios && sh nagios.sh

      Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • How to List Manually Installed Packages in Ubuntu & Debian
    • 10 Bash Tricks Every Developer Should Know
    • How to Validate Email Address in JavaScript
    • Firewalld: Common Firewall Rules and Commands
    • 12 Apk Commands in Alpine Linux Package Management
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.