{"id":4452,"date":"2019-10-19T09:40:19","date_gmt":"2019-10-19T06:40:19","guid":{"rendered":"https:\/\/kifarunix.com\/?p=4452"},"modified":"2024-03-12T22:13:53","modified_gmt":"2024-03-12T19:13:53","slug":"install-nagios-server-on-centos-8","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/install-nagios-server-on-centos-8\/","title":{"rendered":"Install Nagios Server on CentOS 8"},"content":{"rendered":"\n<p>In this guide, you will learn how to install Nagios Server on CentOS 8. <a rel=\"noreferrer noopener\" aria-label=\"Nagios (opens in a new tab)\" href=\"https:\/\/www.nagios.org\/about\/\" target=\"_blank\">Nagios<\/a>&nbsp;provides enterprise-class Open Source IT monitoring, network monitoring, server and applications monitoring.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Installing Nagios Server on CentOS 8<\/h2>\n\n\n\n<p>To install Nagios Server, follow through the steps below;<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Run System Update<\/h3>\n\n\n\n<p>Resynchronize your system packages to their latest versions.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>dnf update<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Install Required Build Tools<\/h3>\n\n\n\n<p>In this guide, we are going to build Nagios Core from the source code. As such there are packages and build tools that you need to install. Run the command below to install them.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>dnf install gcc glibc glibc-common perl httpd php php-cli wget net-snmp gd gd-devel<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Download Nagios Core Source Code<\/h3>\n\n\n\n<p>Navigate to the <a rel=\"noreferrer noopener\" aria-label=\"Nagios Core downloads page (opens in a new tab)\" href=\"https:\/\/www.nagios.org\/downloads\/nagios-core\/thanks\/?skip=1&amp;product_download=nagioscore-source\" target=\"_blank\">Nagios Core downloads page<\/a> and grab the latest Nagios core source code. You can simplify this step by just using wget.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>wget https:\/\/assets.nagios.com\/downloads\/nagioscore\/releases\/nagios-4.4.5.tar.gz<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Extract the Nagios Source Code<\/h3>\n\n\n\n<p>Once the Nagios source is downloaded, extract it by running the command;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>tar xzf nagios-4.4.5.tar.gz<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Installing Nagios Core<\/h3>\n\n\n\n<p>Next, navigate to the Nagios source code directory.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>cd nagios-4.4.5\/<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Configure Nagios Core on CentOS 8<\/h4>\n\n\n\n<p>Run the configuration script to adapt Nagios to your system and check if all required dependencies and build tools are in place.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>.\/configure<\/code><\/pre>\n\n\n\n<p>If the configuration is successful, you will be provided with the summary;<\/p>\n\n\n\n<pre class=\"scroll-box\"><code>\n...\n*** Configuration summary for nagios 4.4.5 2019-08-20 ***:\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\/httpd\/conf.d\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):  \n\n\nReview the options above for accuracy.  If they look okay,\ntype 'make all' to compile the main program and CGIs.\n<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Compile Nagios Core<\/h4>\n\n\n\n<p>Next, proceed to compile Nagios Main program and CGIs.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>make all<\/code><\/pre>\n\n\n\n<p>If the main program and CGIs compiled without any errors, proceed to install Nagios and its configurations.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Create Nagios User and Group<\/h4>\n\n\n\n<p>Nagios runs as non-privileged <code>nagios<\/code> user. As such, you need to create a Nagios system user and group.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>make install-groups-users<\/code><\/pre>\n\n\n\n<p>Add Apache user to the Nagios group.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>usermod -aG nagios apache<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Install Nagios Core on CentOS 8<\/h4>\n\n\n\n<p>Install Nagios main program, CGIs, and HTML files.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>make install<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Install Nagios Service<\/h4>\n\n\n\n<p>Install Nagios Systemd initialization scripts.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>make install-daemoninit<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Install Nagios Commands<\/h4>\n\n\n\n<p>Install and configure the external command file as well as the permissions on the directory holding the external commands file.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>make install-commandmode<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Install Nagios Configuration Files<\/h4>\n\n\n\n<p>Install Nagios Sample configuration file.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>make install-config<\/code><\/pre>\n\n\n\n<p>This command installs Nagios sample configuration files in <strong><code>\/usr\/local\/nagios\/etc<\/code><\/strong>.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Install Nagios Apache Configuration files<\/h4>\n\n\n\n<p>Next, install the&nbsp;Apache&nbsp;HTTP&nbsp;server&nbsp;configuration files for Nagios.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>make install-webconf<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Setup Nagios Apache Authentication<\/h4>\n\n\n\n<p>To setup Nagios Web authentication, you need to create an Apache user for authentication. This can be done using the&nbsp;<strong><code>htpasswd<\/code><\/strong>&nbsp;command.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>htpasswd -c \/usr\/local\/nagios\/etc\/htpasswd.users nagiosadmin<\/code><\/pre>\n\n\n\n<p>The user,&nbsp;<code>nagiosadmin<\/code>, is used by default.<\/p>\n\n\n\n<p>If you need to use a different user, you need to replace all the occurences of&nbsp;<code>nagiosadmin<\/code>&nbsp;on the&nbsp;<code>\/usr\/local\/nagios\/etc\/cgi.cfg<\/code>&nbsp;file with the user you created.<\/p>\n\n\n\n<p>For example, if you use a user like&nbsp;<code>monadmin<\/code>, replace&nbsp;<code>nagiosadmin<\/code>&nbsp;as shown below.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sed -i 's\/nagiosadmin\/monadmin\/g' \/usr\/local\/nagios\/etc\/cgi.cfg<\/code><\/pre>\n\n\n\n<p>If you also want to use a different authentication user file instead of,&nbsp;<code>\/usr\/local\/nagios\/etc\/htpasswd.users<\/code>, ensure you edit the Nagios Apache configuration file,&nbsp;<code>\/etc\/httpd\/conf.d\/nagios.conf<\/code><strong>&nbsp;<\/strong>and change the value of&nbsp;<code>AuthUserFile<\/code>.<\/p>\n\n\n\n<p>Set the ownership of the Nagios Apache authentication configuration file to web-server user,&nbsp;<strong><code>apache<\/code><\/strong>.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>chown apache:apache \/usr\/local\/nagios\/etc\/htpasswd.users<\/code><\/pre>\n\n\n\n<p>Adjust the file permissions appropriately such that the owner (apache) have read write access, the group has read access.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>chmod 640 \/usr\/local\/nagios\/etc\/htpasswd.users<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Start Apache Web server<\/h4>\n\n\n\n<p>Once you are done with configuration, start and enable Apache to run on system boot.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>systemctl enable httpd --now<\/code><\/pre>\n\n\n\n<p>If firewallD is running on your system, be sure to enable external access to Apache.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>firewall-cmd --add-port=80\/tcp --permanent\nfirewall-cmd --reload<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Start Nagios Core service<\/h4>\n\n\n\n<p>Start and enable Nagios service to run on system boot.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>systemctl enable nagios --now<\/code><\/pre>\n\n\n\n<p>To check the status<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>systemctl status nagios<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>\n\u25cf nagios.service - Nagios Core 4.4.5\n   Loaded: loaded (\/usr\/lib\/systemd\/system\/nagios.service; enabled; vendor preset: disabled)\n   Active: active (running) since Sat 2019-10-19 01:58:43 EDT; 27s ago\n     Docs: https:\/\/www.nagios.org\/documentation\n  Process: 31542 ExecStart=\/usr\/local\/nagios\/bin\/nagios -d \/usr\/local\/nagios\/etc\/nagios.cfg (code=exited, status=0\/SUCCESS)\n  Process: 31540 ExecStartPre=\/usr\/local\/nagios\/bin\/nagios -v \/usr\/local\/nagios\/etc\/nagios.cfg (code=exited, status=0\/SUCCESS)\n Main PID: 31543 (nagios)\n    Tasks: 6 (limit: 24012)\n   Memory: 2.7M\n   CGroup: \/system.slice\/nagios.service\n           \u251c\u250031543 \/usr\/local\/nagios\/bin\/nagios -d \/usr\/local\/nagios\/etc\/nagios.cfg\n           \u251c\u250031544 \/usr\/local\/nagios\/bin\/nagios --worker \/usr\/local\/nagios\/var\/rw\/nagios.qh\n           \u251c\u250031545 \/usr\/local\/nagios\/bin\/nagios --worker \/usr\/local\/nagios\/var\/rw\/nagios.qh\n           \u251c\u250031546 \/usr\/local\/nagios\/bin\/nagios --worker \/usr\/local\/nagios\/var\/rw\/nagios.qh\n           \u251c\u250031547 \/usr\/local\/nagios\/bin\/nagios --worker \/usr\/local\/nagios\/var\/rw\/nagios.qh\n           \u2514\u250031548 \/usr\/local\/nagios\/bin\/nagios -d \/usr\/local\/nagios\/etc\/nagios.cfg\n\ufeff<\/code><\/pre>\n\n\n\n<p>You can check Nagios logs at <code>\/usr\/local\/nagios\/var\/nagios.log<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Accessing Nagios on CentOS 8<\/h2>\n\n\n\n<p>You can now access your Nagios server from the browser using the address <strong><code>http:\/\/&lt;server-IP or HOSTNAME&gt;\/nagios<\/code><\/strong>.<\/p>\n\n\n\n<p>You will be prompted to enter username and password created above to login.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"450\" height=\"261\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2019\/10\/nagios-apache-auth.png\" alt=\"Install Nagios Server on CentOS 8\" class=\"wp-image-4455\" title=\"\"><\/figure><\/div>\n\n\n<p>Enter the authentication credentials and proceed to Nagios web interface.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2019\/10\/nagios-web-ui.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1347\" height=\"613\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2019\/10\/nagios-web-ui.png\" alt=\"Install Nagios Server on CentOS 8\" class=\"wp-image-4456\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2019\/10\/nagios-web-ui.png?v=1571466509 1347w, https:\/\/kifarunix.com\/wp-content\/uploads\/2019\/10\/nagios-web-ui-768x350.png?v=1571466509 768w\" sizes=\"(max-width: 1347px) 100vw, 1347px\" \/><\/a><\/figure>\n\n\n\n<p>Huraay!! Nagios is installed on CentOS 8. So what is next?<\/p>\n\n\n\n<p>The next step would now be to start monitoring your end points with nagios. This involves installing Nagios plugins and the NRPE plugins.<\/p>\n\n\n\n<p>If you can check, even the status of the localhost and services are down since no Nagios plugins are installed by default.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2019\/10\/host-state.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1358\" height=\"316\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2019\/10\/host-state.png\" alt=\"Nagios Server CentOS 8 host state\" class=\"wp-image-4457\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2019\/10\/host-state.png?v=1571466809 1358w, https:\/\/kifarunix.com\/wp-content\/uploads\/2019\/10\/host-state-768x179.png?v=1571466809 768w\" sizes=\"(max-width: 1358px) 100vw, 1358px\" \/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2019\/10\/service-state.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1347\" height=\"453\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2019\/10\/service-state.png\" alt=\"Nagios Server CentOS 8 services state\" class=\"wp-image-4458\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2019\/10\/service-state.png?v=1571466818 1347w, https:\/\/kifarunix.com\/wp-content\/uploads\/2019\/10\/service-state-768x258.png?v=1571466818 768w\" sizes=\"(max-width: 1347px) 100vw, 1347px\" \/><\/a><\/figure>\n\n\n\n<p>Next, install Nagios plugins so as to monitor state of the host and services.<\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/install-nagios-plugins-on-centos-8\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">Install Nagios Plugins on CentOS 8<\/a><\/p>\n\n\n\n<p>That marks the end of our tutorial on how to install Nagios Server.<\/p>\n\n\n\n<p>You can also check other Nagios Tutorials by following the links below;<\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/kifarunix.com\/install-nagios-core-on-debian-10-buster\/\" target=\"_blank\">Install Nagios Core on Debian 10 Buster<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/monitor-linux-hosts-using-nagios-check_by_ssh-plugin\/\">Monitor Linux Hosts using Nagios check_by_ssh Plugin<\/a><\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/kifarunix.com\/how-to-install-and-configure-nagios-core-on-ubuntu-18-04\/\" target=\"_blank\">How to Install and Configure Nagios Core From repo Ubuntu 18.04<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/how-to-install-and-configure-nagios-core-from-the-source-ubuntu-18-04\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">How to Install and Configure Nagios Core From the Source Ubuntu 18.04<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this guide, you will learn how to install Nagios Server on CentOS 8. Nagios&nbsp;provides enterprise-class Open Source IT monitoring, network monitoring, server and applications<\/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":[1142,75,76,145,1158],"class_list":["post-4452","post","type-post","status-publish","format-standard","hentry","category-howtos","category-monitoring","category-nagios","tag-centos-8","tag-nagios","tag-nagios-core","tag-nagios-monitoring","tag-nagios-server-on-centos-8","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50"],"_links":{"self":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/4452"}],"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=4452"}],"version-history":[{"count":6,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/4452\/revisions"}],"predecessor-version":[{"id":21225,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/4452\/revisions\/21225"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=4452"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=4452"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=4452"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}