{"id":9269,"date":"2021-06-22T23:26:05","date_gmt":"2021-06-22T20:26:05","guid":{"rendered":"https:\/\/kifarunix.com\/?p=9269"},"modified":"2024-03-18T20:28:56","modified_gmt":"2024-03-18T17:28:56","slug":"install-nagios-server-on-rocky-linux-8","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/install-nagios-server-on-rocky-linux-8\/","title":{"rendered":"Install Nagios Server on Rocky Linux 8"},"content":{"rendered":"\n<p>In this guide, you will learn how to install Nagios Server on Rocky Linux 8.&nbsp;<a rel=\"noreferrer noopener\" 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 Rocky Linux 8<\/h2>\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&nbsp;<a rel=\"noreferrer noopener\" href=\"https:\/\/www.nagios.org\/downloads\/nagios-core\/thanks\/?skip=1&amp;product_download=nagioscore-source\" target=\"_blank\">Nagios Core downloads page<\/a>&nbsp;and grab the latest Nagios core source code. Nagios v4.4.6 is the current stable release as of this guide.<\/p>\n\n\n\n<p>Get the latest stable release version number and substitute the value of the <strong>$VER<\/strong> variable below and use wget to download the file.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>VER=4.4.6<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>wget https:\/\/assets.nagios.com\/downloads\/nagioscore\/releases\/nagios-$VER.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-$VER.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-$VER\/<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Configure Nagios Core on Rocky Linux 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...\nCreating sample config files in sample-config\/ ...\n\n\n*** Configuration summary for nagios 4.4.6 2020-04-28 ***:\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 on Rocky Linux 8<\/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&nbsp;<code>nagios<\/code>&nbsp;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 Rocky Linux 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&nbsp;<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> 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.6\n   Loaded: loaded (\/usr\/lib\/systemd\/system\/nagios.service; enabled; vendor preset: disabled)\n   Active: active (running) since Tue 2021-06-22 22:16:24 EAT; 18s ago\n     Docs: https:\/\/www.nagios.org\/documentation\n  Process: 60128 ExecStart=\/usr\/local\/nagios\/bin\/nagios -d \/usr\/local\/nagios\/etc\/nagios.cfg (code=exited, status=0\/SUCCESS)\n  Process: 60126 ExecStartPre=\/usr\/local\/nagios\/bin\/nagios -v \/usr\/local\/nagios\/etc\/nagios.cfg (code=exited, status=0\/SUCCESS)\n Main PID: 60129 (nagios)\n    Tasks: 6 (limit: 11389)\n   Memory: 2.4M\n   CGroup: \/system.slice\/nagios.service\n           \u251c\u250060129 \/usr\/local\/nagios\/bin\/nagios -d \/usr\/local\/nagios\/etc\/nagios.cfg\n           \u251c\u250060130 \/usr\/local\/nagios\/bin\/nagios --worker \/usr\/local\/nagios\/var\/rw\/nagios.qh\n           \u251c\u250060131 \/usr\/local\/nagios\/bin\/nagios --worker \/usr\/local\/nagios\/var\/rw\/nagios.qh\n           \u251c\u250060132 \/usr\/local\/nagios\/bin\/nagios --worker \/usr\/local\/nagios\/var\/rw\/nagios.qh\n           \u251c\u250060133 \/usr\/local\/nagios\/bin\/nagios --worker \/usr\/local\/nagios\/var\/rw\/nagios.qh\n           \u2514\u250060134 \/usr\/local\/nagios\/bin\/nagios -d \/usr\/local\/nagios\/etc\/nagios.cfg\n\nJun 22 22:16:24 localhost.localdomain nagios[60129]: qh: core query handler registered\nJun 22 22:16:24 localhost.localdomain nagios[60129]: qh: echo service query handler registered\nJun 22 22:16:24 localhost.localdomain nagios[60129]: qh: help for the query handler registered\nJun 22 22:16:24 localhost.localdomain nagios[60129]: wproc: Successfully registered manager as @wproc with query handler\nJun 22 22:16:24 localhost.localdomain nagios[60129]: wproc: Registry request: name=Core Worker 60130;pid=60130\nJun 22 22:16:24 localhost.localdomain nagios[60129]: wproc: Registry request: name=Core Worker 60131;pid=60131\nJun 22 22:16:24 localhost.localdomain nagios[60129]: wproc: Registry request: name=Core Worker 60132;pid=60132\nJun 22 22:16:24 localhost.localdomain nagios[60129]: wproc: Registry request: name=Core Worker 60133;pid=60133\nJun 22 22:16:26 localhost.localdomain nagios[60129]: Successfully launched command file worker with pid 60134\nJun 22 22:16:26 localhost.localdomain nagios[60129]: HOST ALERT: localhost;DOWN;SOFT;1;(No output on stdout) stderr: execvp(\/usr\/local\/nagios\/libexec\/check_ping\n<\/code><\/pre>\n\n\n\n<p>You can check Nagios logs at&nbsp;<code>\/usr\/local\/nagios\/var\/nagios.log<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Accessing Nagios on Rocky Linux 8<\/h2>\n\n\n\n<p>You can now access your Nagios server from the browser using the address&nbsp;<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 size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"450\" height=\"261\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2021\/06\/nagios-apache-auth.png\" alt=\"Install Nagios Server on CentOS 8\" class=\"wp-image-9273\" 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 size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1626\" height=\"922\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2021\/06\/nagios-dashboard.png\" alt=\"\" class=\"wp-image-9283\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2021\/06\/nagios-dashboard.png?v=1624392812 1626w, https:\/\/kifarunix.com\/wp-content\/uploads\/2021\/06\/nagios-dashboard-768x435.png?v=1624392812 768w, https:\/\/kifarunix.com\/wp-content\/uploads\/2021\/06\/nagios-dashboard-1536x871.png?v=1624392812 1536w\" sizes=\"(max-width: 1626px) 100vw, 1626px\" \/><\/figure>\n\n\n\n<p>Huraay!! Nagios is installed on Rocky Linux 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 size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1625\" height=\"426\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2021\/06\/hosts-state.png\" alt=\"\" class=\"wp-image-9284\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2021\/06\/hosts-state.png?v=1624392828 1625w, https:\/\/kifarunix.com\/wp-content\/uploads\/2021\/06\/hosts-state-768x201.png?v=1624392828 768w, https:\/\/kifarunix.com\/wp-content\/uploads\/2021\/06\/hosts-state-1536x403.png?v=1624392828 1536w\" sizes=\"(max-width: 1625px) 100vw, 1625px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1707\" height=\"432\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2021\/06\/service-state-1.png\" alt=\"\" class=\"wp-image-9285\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2021\/06\/service-state-1.png?v=1624392843 1707w, https:\/\/kifarunix.com\/wp-content\/uploads\/2021\/06\/service-state-1-768x194.png?v=1624392843 768w, https:\/\/kifarunix.com\/wp-content\/uploads\/2021\/06\/service-state-1-1536x389.png?v=1624392843 1536w\" sizes=\"(max-width: 1707px) 100vw, 1707px\" \/><\/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-rocky-linux-8\/\" target=\"_blank\" rel=\"noreferrer noopener\">Install Nagios Plugins on Rocky Linux 8<\/a><\/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 href=\"https:\/\/kifarunix.com\/monitor-ssl-tls-certificates-expiry-with-nagios\/\" target=\"_blank\" rel=\"noreferrer noopener\">Monitor SSL\/TLS Certificates Expiry with Nagios<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/configure-nagios-email-notification-using-gmail\/\" target=\"_blank\" rel=\"noreferrer noopener\">Configure Nagios Email Notification Using Gmail<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/add-hosts-to-nagios-server-for-monitoring\/\" target=\"_blank\" rel=\"noreferrer noopener\">Add Hosts to Nagios Server For Monitoring<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this guide, you will learn how to install Nagios Server on Rocky Linux 8.&nbsp;Nagios&nbsp;provides enterprise-class Open Source IT monitoring, network monitoring, server and applications<\/p>\n","protected":false},"author":3,"featured_media":9278,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[72,121,73],"tags":[3729,75,76,1161,3730,3587],"class_list":["post-9269","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-monitoring","category-howtos","category-nagios","tag-install-nagios-rocky-linux-8","tag-nagios","tag-nagios-core","tag-nagios-server","tag-nagios-server-rocky-linux","tag-rocky-linux-8","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50","resize-featured-image"],"_links":{"self":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/9269"}],"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\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/comments?post=9269"}],"version-history":[{"count":6,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/9269\/revisions"}],"predecessor-version":[{"id":21769,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/9269\/revisions\/21769"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media\/9278"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=9269"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=9269"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=9269"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}