{"id":3764,"date":"2019-07-25T20:55:31","date_gmt":"2019-07-25T17:55:31","guid":{"rendered":"https:\/\/kifarunix.com\/?p=3764"},"modified":"2019-08-05T12:08:46","modified_gmt":"2019-08-05T09:08:46","slug":"install-nagios-core-on-debian-10-buster","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/install-nagios-core-on-debian-10-buster\/","title":{"rendered":"Install Nagios Core on Debian 10 Buster"},"content":{"rendered":"\n

In this guide, we are going to learn how to install Nagios Core on Debian 10 Buster from the source. Nagios<\/a> is an opensource tool that provides an enterprise-class central monitoring engine for IT monitoring, network monitoring, server and applications monitoring. It also provides a web interface for viewing current status, historical logs, and basic reports.<\/p>\n\n\n\n

Install Nagios Core on Debian 10 Buster<\/h2>\n\n\n\n

Prerequisites<\/h3>\n\n\n\n

Since we are In this guide, we are going to build Nagios from the source. As such, there are some dependencies and build tools that are required. These include some components of LAMP\/LEMP Stack, Apache\/Nginx and PHP. Run the command below to install them.<\/p>\n\n\n\n

apt install build-essential unzip openssl libssl-dev apache2 php libapache2-mod-php php-gd libgd-dev<\/code><\/pre>\n\n\n\n

If you need to see how to install LEMP\/LAMP stack on Debian 10 Buster, follow the links below;<\/p>\n\n\n\n

Install LEMP Stack on Debian 10 Buster<\/a><\/p>\n\n\n\n

Install LAMP Stack with MariaDB 10 on Debian 10 Buster<\/a><\/p>\n\n\n\n

Download Nagios 4 Source code<\/h3>\n\n\n\n

Once the installation above completes, navigate to Nagios downloads page<\/a> and download the latest stable release. Get the download link as download it as follows.<\/p>\n\n\n\n

wget https:\/\/assets.nagios.com\/downloads\/nagioscore\/releases\/nagios-4.4.3.tar.gz -P \/tmp<\/code><\/pre>\n\n\n\n

Extract the Source code<\/h4>\n\n\n\n

Once the download is completes, navigate to download dir, \/tmp<\/strong> in this guide and extract Nagios Core as follows.<\/p>\n\n\n\n

cd \/tmp\ntar xzf nagios-4.4.3.tar.gz<\/code><\/pre>\n\n\n\n

Compile Nagios Core<\/h3>\n\n\n\n

Navigate to the Nagios source code directory and run configure script to adapt Nagios to your system. You can also configure Nagios to use Apache web server by specifying Apache configuration directory.<\/p>\n\n\n\n

cd nagios-4.4.3\/\n.\/configure --with-httpd-conf=\/etc\/apache2\/sites-enabled<\/code><\/pre>\n\n\n\n

Once the configure script completes, it should give you a summary as shown below;<\/p>\n\n\n\n

...\n*** Configuration summary for nagios 4.4.3 2019-01-15 ***:\n\n General Options:\n -------------------------\n        Nagios executable:  nagios\n        Nagios user\/group:  nagios,nagios\n       Command user\/group:  nagios,nagios\n             Event Broker:  yes\n        Install ${prefix}:  \/usr\/local\/nagios\n    Install ${includedir}:  \/usr\/local\/nagios\/include\/nagios\n                Lock file:  \/run\/nagios.lock\n   Check result directory:  \/usr\/local\/nagios\/var\/spool\/checkresults\n           Init directory:  \/lib\/systemd\/system\n  Apache conf.d directory:  \/etc\/apache2\/sites-enabled\n             Mail program:  \/bin\/mail\n                  Host OS:  linux-gnu\n          IOBroker Method:  epoll\n\n Web Interface Options:\n ------------------------\n                 HTML URL:  http:\/\/localhost\/nagios\/\n                  CGI URL:  http:\/\/localhost\/nagios\/cgi-bin\/\n Traceroute (used by WAP):  \/usr\/sbin\/traceroute\n\n\nReview the options above for accuracy.  If they look okay,\ntype 'make all' to compile the main program and CGIs.<\/code><\/pre>\n\n\n\n

To compile Nagios Core main program and CGIs, execute the command below;<\/p>\n\n\n\n

make all<\/code><\/pre>\n\n\n\n

If the compilation is successful, proceed to setup Nagios as follows;<\/p>\n\n\n\n

Create Nagios User and Group<\/h3>\n\n\n\n

TO create dedicated Nagios user and group, run the make command with install-groups-users<\/strong> option as shown below;<\/p>\n\n\n\n

make install-groups-users<\/code><\/pre>\n\n\n\n

The command above above simply executes, groupadd -r nagios<\/strong> and useradd -g nagios nagios<\/strong> commands.<\/p>\n\n\n\n

Next, add the web server user, www-data<\/strong> to Nagios group just created.<\/p>\n\n\n\n

usermod -aG nagios www-data<\/code><\/pre>\n\n\n\n

Install Nagios<\/h3>\n\n\n\n

Run the make install<\/strong> command to install Nagios main program, CGIs and HTML files.<\/p>\n\n\n\n

make install<\/code><\/pre>\n\n\n\n

Install Nagios Service<\/h3>\n\n\n\n

To install Nagios service configuration files and enable them to run on system boot.<\/p>\n\n\n\n

make install-daemoninit<\/code><\/pre>\n\n\n\n

Install Command Mode<\/h3>\n\n\n\n

Run the command below install and configure permissions on the directory for holding external command file.<\/p>\n\n\n\n

make install-commandmode<\/code><\/pre>\n\n\n\n

Install Nagios Configuration Files<\/h3>\n\n\n\n

To setup Nagios configuration files, run the make<\/strong> command with install-config<\/strong> option.<\/p>\n\n\n\n

make install-config<\/code><\/pre>\n\n\n\n

This installs sample config files in \/usr\/local\/nagios\/etc<\/p>\n\n\n\n

Install Nagios Apache Config files<\/h3>\n\n\n\n

To install Apache configuration files for Nagios web interface, execute;<\/p>\n\n\n\n

make install-webconf<\/code><\/pre>\n\n\n\n

Enable Apache rewrite and CGI modules.<\/p>\n\n\n\n

a2enmod rewrite cgi<\/code><\/pre>\n\n\n\n

Nagios with Apache web server is now configured.<\/p>\n\n\n\n

Setup Nagios Apache Authentication<\/h3>\n\n\n\n

To setup Nagios Web authentication, you need to create an Apache user for authentication. This can be done using the htpasswd<\/strong> command. <\/p>\n\n\n\n

htpasswd -c \/usr\/local\/nagios\/etc\/htpasswd.users nagiosadmin<\/code><\/pre>\n\n\n\n

The user, nagiosadmin<\/strong>, is used by default. If you need to use a different user, you need to replace all the occurences of nagiosadmin<\/strong> on the \/usr\/local\/nagios\/etc\/cgi.cfg<\/strong> file with the user you created. For example, if you use like admin<\/strong>, replace nagiosadmin<\/strong> as shown below.<\/p>\n\n\n\n

sed -i 's\/nagiosadmin\/admin\/g' \/usr\/local\/nagios\/etc\/cgi.cfg<\/code><\/pre>\n\n\n\n

If you also want to use a different authentication user file instead of, \/usr\/local\/nagios\/etc\/htpasswd.users<\/strong>, ensure you edit the Nagios Apache configuration file, \/etc\/apache2\/sites-enabled\/nagios.conf <\/strong>and change the value of AuthUserFile<\/strong>.<\/p>\n\n\n\n

Set the ownership of the Nagios Apache authentication configuration file to web-server user, www-data<\/strong>.<\/p>\n\n\n\n

chown www-data.www-data \/usr\/local\/nagios\/etc\/htpasswd.users<\/code><\/pre>\n\n\n\n

Adjust the file permissions appropriately such that the owner (www-data) have read write access, the group has read access.<\/p>\n\n\n\n

chmod 640 \/usr\/local\/nagios\/etc\/htpasswd.users<\/code><\/pre>\n\n\n\n

Start Apache Web server<\/h3>\n\n\n\n

Once you are done with configuration, restart Apache.<\/p>\n\n\n\n

systemctl restart apache2<\/code><\/pre>\n\n\n\n

If any firewall is running on your system, be sure to enable Apache through it.<\/p>\n\n\n\n

ufw allow 80<\/code><\/pre>\n\n\n\n

Start Nagios Core service<\/h3>\n\n\n\n

Start Nagios Core service by running the command below;<\/p>\n\n\n\n

systemctl start nagios.service<\/code><\/pre>\n\n\n\n

To check the status<\/p>\n\n\n\n

systemctl status nagios.service<\/code><\/pre>\n\n\n\n
\u25cf nagios.service - Nagios Core 4.4.3\n   Loaded: loaded (\/lib\/systemd\/system\/nagios.service; enabled; vendor preset: enabled)\n   Active: active (running) since Thu 2019-07-25 03:56:52 EDT; 2s ago\n     Docs: https:\/\/www.nagios.org\/documentation\n  Process: 5238 ExecStartPre=\/usr\/local\/nagios\/bin\/nagios -v \/usr\/local\/nagios\/etc\/nagios.cfg (code=exited, status=0\/SUCCESS)\n  Process: 5239 ExecStart=\/usr\/local\/nagios\/bin\/nagios -d \/usr\/local\/nagios\/etc\/nagios.cfg (code=exited, status=0\/SUCCESS)\n Main PID: 5240 (nagios)\n    Tasks: 5 (limit: 4701)\n   Memory: 1.9M\n   CGroup: \/system.slice\/nagios.service\n           \u251c\u25005240 \/usr\/local\/nagios\/bin\/nagios -d \/usr\/local\/nagios\/etc\/nagios.cfg\n           \u251c\u25005241 \/usr\/local\/nagios\/bin\/nagios --worker \/usr\/local\/nagios\/var\/rw\/nagios.qh\n           \u251c\u25005242 \/usr\/local\/nagios\/bin\/nagios --worker \/usr\/local\/nagios\/var\/rw\/nagios.qh\n           \u251c\u25005243 \/usr\/local\/nagios\/bin\/nagios --worker \/usr\/local\/nagios\/var\/rw\/nagios.qh\n           \u2514\u25005244 \/usr\/local\/nagios\/bin\/nagios --worker \/usr\/local\/nagios\/var\/rw\/nagios.qh<\/code><\/pre>\n\n\n\n

If you need to go through the Nagios logs, the log file is;<\/p>\n\n\n\n

\/usr\/local\/nagios\/var\/nagios.log<\/code><\/pre>\n\n\n\n

Accessing Nagios on Debian 10 Buster<\/h2>\n\n\n\n

Once you are done with the configuration, navigate to the browser and access your Nagios with the address http:\/\/<server-IP>\/nagios<\/strong>. You will be prompted to enter username and password created above to login.<\/p>\n\n\n\n

\"Install<\/a><\/figure>\n\n\n\n

By default, Nagios doesn’t monitor the status of hosts and services without Nagios plugins, which are not installed by default. If you check the current status of the hosts, localhost server shows state as DOWN.<\/p>\n\n\n\n

\"Nagios<\/a><\/figure>\n\n\n\n

If you need to monitor your endpoints or even including your nagios server itself you need to install Nagios plugins.<\/p>\n\n\n\n

Install Nagios Plugins<\/h3>\n\n\n\n

To monitor your local system (Nagios server), just install the plugins as shown below;<\/p>\n\n\n\n

Download the Nagios Plugins<\/p>\n\n\n\n

wget https:\/\/nagios-plugins.org\/download\/nagios-plugins-2.2.1.tar.gz -P \/tmp\/<\/code><\/pre>\n\n\n\n

Extract and install the plugins.<\/p>\n\n\n\n

cd \/tmp\ntar xzf nagios-plugins-2.2.1.tar.gz<\/code><\/pre>\n\n\n\n

Compile and install the plugins. Add <\/p>\n\n\n\n

cd nagios-plugins-2.2.1\/\n.\/configure --with-nagios-user=nagios --with-nagios-group=nagios<\/code><\/pre>\n\n\n\n
make && make install<\/code><\/pre>\n\n\n\n

If the installation is successful, the plugins are installed under \/usr\/local\/nagios\/libexec<\/strong>.<\/p>\n\n\n\n

Restart Nagios.<\/p>\n\n\n\n

systemctl restart nagios<\/code><\/pre>\n\n\n\n

If you login to your Nagios web UI, you should now be able to check the status of the host and services being monitored.<\/p>\n\n\n\n

Host Status<\/p>\n\n\n\n

\"Nagios<\/a><\/figure>\n\n\n\n

Host Services<\/p>\n\n\n\n

\"Nagios<\/a><\/figure>\n\n\n\n

There you go. You have successfully install and configured Nagios on Debian 10 Buster. If you need to monitor you Linux\/Windows Hosts or any other device, see out links below;<\/p>\n\n\n\n

Monitor Linux Hosts using Nagios check_by_ssh Plugin<\/a><\/p>\n\n\n\n

How to Install Nagios Plugins and NRPE agents on CentOS 7\/RHEL 7\/Fedora 29<\/a><\/p>\n\n\n\n

How to Install Nagios Plugins From Source RHEL\/CentOS\/Oracle Linux<\/a><\/p>\n\n\n\n

How to Install and Configure NSClient++ Nagios Agent on Windows System<\/a><\/p>\n\n\n\n

How to Install and Configure Nagios Core From the Source Ubuntu 18.04<\/a><\/p>\n\n\n\n

Install and Configure SNMP on Ubuntu 18.04 and CentOS 7<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"

In this guide, we are going to learn how to install Nagios Core on Debian 10 Buster from the source. Nagios is an opensource tool<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[121,72,73],"tags":[997,1039,75,76,145,149],"class_list":["post-3764","post","type-post","status-publish","format-standard","hentry","category-howtos","category-monitoring","category-nagios","tag-debian-10","tag-debian-10-buster","tag-nagios","tag-nagios-core","tag-nagios-monitoring","tag-nagios-plugins","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50"],"_links":{"self":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/3764"}],"collection":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/comments?post=3764"}],"version-history":[{"count":17,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/3764\/revisions"}],"predecessor-version":[{"id":3860,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/3764\/revisions\/3860"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=3764"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=3764"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=3764"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}