Facebook Twitter Instagram
    TecAdmin
    • Home
    • Ubuntu 20.04
      • Upgrade Ubuntu
      • Install Java
      • Install Node.js
      • Install Docker
      • Install LAMP Stack
    • Tutorials
      • AWS
      • Shell Scripting
      • Docker
      • Git
      • MongoDB
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    Home»Monitoring Tools»Nagios»How to Install Nagios 4.4 on Ubuntu 18.04 & 16.04 LTS

    How to Install Nagios 4.4 on Ubuntu 18.04 & 16.04 LTS

    RahulBy RahulJanuary 15, 20154 Mins ReadUpdated:March 25, 2020

    Nagios is the most popular, open-source, powerful monitoring system for any kind of infrastructure. It enables organizations to identify and resolve IT infrastructure problems before they affect critical business processes. Nagios has the capability of monitoring application, services, entire IT infrastructure.

    Install Nagios

    This article will help you to set up Nagios Monitoring Server on Ubuntu 18.04 LTS, 16.04 LTS, and 14.04 LTS and Debian systems. After completing this article, you will like to follow the below tutorials.

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

    Step 1 – Prerequisite

    We assume that you have fresh installed Ubuntu/Debian systems, So our first requirement is to install Apache and PHP first. Use the following commands to complete it. You can find detailed LAMP setup instruction here.

    Let’s use the following commands to install required packages for Nagios.

    sudo apt-get update
    sudo apt-get install wget build-essential unzip openssl libssl-dev
    sudo apt-get install apache2 php libapache2-mod-php php-gd libgd-dev 
    

    Step 2 – Create Nagios User

    First of all, create a new user account for Nagios in your system and assign a password.

    sudo adduser nagios
    

    Now 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 3 – Install Nagios Core Service

    Now, start with Nagios core installation. Download the latest Nagios core service from the official site.

    cd /opt/
    wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.5.tar.gz
    tar xzf nagios-4.4.5.tar.gz
    

    After extracting naviate to nagios source directory and install using make command.

    cd nagios-4.4.5
    sudo ./configure --with-command-group=nagcmd
    sudo make all
    sudo make install
    sudo make install-init
    sudo make install-daemoninit
    sudo make install-config
    sudo make install-commandmode
    sudo make install-exfoliation
    

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

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

    Step 4 – Setup Apache with Authentication

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

    sudo vi /etc/apache2/conf-available/nagios.conf
    
    /etc/apache2/conf-available/nagios.conf
    ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"
    
    <Directory "/usr/local/nagios/sbin">
       Options ExecCGI
       AllowOverride None
       Order allow,deny
       Allow from all
       AuthName "Restricted Area"
       AuthType Basic
       AuthUserFile /usr/local/nagios/etc/htpasswd.users
       Require valid-user
    </Directory>
    
    Alias /nagios "/usr/local/nagios/share"
    
    <Directory "/usr/local/nagios/share">
       Options None
       AllowOverride None
       Order allow,deny
       Allow from all
       AuthName "Restricted Area"
       AuthType Basic
       AuthUserFile /usr/local/nagios/etc/htpasswd.users
       Require valid-user
    </Directory>
    

    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 a2enconf nagios
    sudo a2enmod cgi rewrite
    sudo service apache2 restart
    

    Step 5 – Installing Nagios Plugins

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

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

    Now compile and install Nagios plugins

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

    Step 6 – Verify Settings

    Use the Nagios commands to verify the Nagios installation and configuration file. After successfully verify start the Nagios core service.

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

    Also configure Nagios to auto start on system boot.

    sudo systemctl enable nagios
    

    Step 7 – Access Nagios Web Interface

    Access your nagios setup by access nagios server using hostname or ip address followed by /nagios.
    [change domain name with your domain or ip]

     http://tecadmin.example.net/nagios/
    

    This will prompt for the Apache authentication. Use nagiosadmin as username and password created in step 4.

    Install Nagios Ubuntu

    After successful login, you will see the Nagios interface like below. Here you can use sidebar button to navigate to see hosts, services, alerts etc.

    Nagios dashboard on ubuntu

    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.

    monitoring nagios nagios server NRPE
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp
    Previous ArticleHow to Enable Logging in Iptables on Linux
    Next Article How to Install Nagios Server on CentOS/RHEL 8/7/6

    Related Posts

    How to Install Nagios Client (NRPE) on Ubuntu 20.04

    3 Mins Read

    How to Install Nagios Server on Ubuntu 20.04

    Updated:June 3, 20213 Mins Read

    How to Install and Configure Sysstat on Ubuntu 20.04

    Updated:July 28, 20204 Mins Read

    How To Install Zabbix Server 5.0 on Ubuntu 20.04

    Updated:August 11, 20205 Mins Read

    How To Install Zabbix Agent on Ubuntu 20.04

    Updated:July 12, 20202 Mins Read

    How To Install NRPE on LinuxMint 19/18

    Updated:December 6, 20182 Mins Read

    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

    Recent Posts
    • How To Install Docker on Ubuntu 22.04
    • How to Install Bower on Ubuntu 22.04 & 20.04
    • How to run “npm start” through Docker
    • Filesystem Hierarchy Structure (FHS) in Linux
    • How to accept user input in Python
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

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