{"id":398,"date":"2018-08-18T01:52:00","date_gmt":"2018-08-17T22:52:00","guid":{"rendered":"http:\/\/kifarunix.com\/?p=398"},"modified":"2024-03-10T17:43:30","modified_gmt":"2024-03-10T14:43:30","slug":"how-to-install-and-configure-nagios-core-from-the-source-ubuntu-18-04","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/how-to-install-and-configure-nagios-core-from-the-source-ubuntu-18-04\/","title":{"rendered":"Install and Configure Nagios Core From Source on Ubuntu 18.04"},"content":{"rendered":"\n<p>In this tutorial we are going to learn how to install and Configure <a href=\"https:\/\/www.nagios.org\/projects\/nagios-core\/\" target=\"_blank\" rel=\"noopener noreferrer\">Nagios Core<\/a> from source on Ubuntu 18.04 for server resource consumption and availability monitoring.<\/p>\n\n\n\n<div class=\"wp-block-rank-math-toc-block\" id=\"rank-math-toc\"><h2>Table of Contents<\/h2><nav><ul><li><a href=\"#configure-nagios-core-from-source-on-ubuntu-18-04\">Configure Nagios Core From Source\u00a0 on Ubuntu 18.04<\/a><ul><li><a href=\"#run-system-update\">Run System Update<\/a><\/li><li><a href=\"#install-required-build-tools-and-packages\">Install Required Build Tools and Packages<\/a><\/li><li><a href=\"#download-nagios-core-source-code\">Download Nagios Core Source Code<\/a><\/li><li><a href=\"#extract-nagios-core-source-code\">Extract Nagios Core Source Code<\/a><\/li><li><a href=\"#compile-and-install-nagios\">Compile and Install Nagios<\/a><\/li><li><a href=\"#create-nagios-user-and-group\">Create Nagios User and Group<\/a><\/li><li><a href=\"#install-nagios-core-on-ubuntu-18-04\">Install Nagios Core on Ubuntu 18.04<\/a><\/li><li><a href=\"#create-nagios-core-basic-web-auth-user\">Create Nagios Core Basic Web Auth User<\/a><\/li><li><a href=\"#start-nagios-and-apache\">Start Nagios and Apache<\/a><\/li><li><a href=\"#accessing-nagios-web-interface\">Accessing Nagios Web Interface<\/a><\/li><li><a href=\"#install-nagios-plugins-on-ubuntu-18-04\">Install Nagios Plugins on Ubuntu 18.04<\/a><\/li><li><a href=\"#restart-nagios-core-service\">Restart Nagios Core service<\/a><\/li><li><a href=\"#other-tutorials\">Other Tutorials<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"configure-nagios-core-from-source-on-ubuntu-18-04\"><span class=\"section-title\">Configure Nagios Core From Source\u00a0 on Ubuntu 18.04<\/span><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"run-system-update\">Run System Update<\/h3>\n\n\n\n<p>Update your system package cache;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apt update<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"install-required-build-tools-and-packages\">Install Required Build Tools and Packages<\/h3>\n\n\n\n<p>Installation from the source ensures that we get latest features, security updates, and bug fixes.<\/p>\n\n\n\n<p>Follow through this tutorial to build Nagios and its components from the source.<\/p>\n\n\n\n<p>Install the necessary Nagios build tools and development libraries<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>apt install -y autoconf gcc libc6 make wget unzip apache2 php \\\nlibapache2-mod-php libgd-dev openssl libssl-dev<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"download-nagios-core-source-code\">Download Nagios Core Source Code<\/h3>\n\n\n\n<p>Download the source code of the latest stable release of Nagios Core from <a href=\"https:\/\/www.nagios.org\/downloads\/nagios-core\/thanks\/?skip=1&amp;product_download=nagioscore-source\" target=\"_blank\" rel=\"noopener noreferrer\">here<\/a>.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>wget https:\/\/assets.nagios.com\/downloads\/nagioscore\/releases\/nagios-4.4.11.tar.gz -P \/tmp<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"extract-nagios-core-source-code\">Extract Nagios Core Source Code<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>cd \/tmp<\/code><\/pre>\n\n\n\n<pre id=\"block-1cf06004-67bb-4339-be06-3671e410f7c8\" class=\"wp-block-preformatted\">tar xzf nagios-4.4.11.tar.gz<\/code><\/pre>\n\n\n\n<pre id=\"block-1684d250-3774-42b6-8989-2ab9fbf29854\" class=\"wp-block-preformatted\">cd nagios-4.4.11<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"compile-and-install-nagios\">Compile and Install Nagios<\/h3>\n\n\n\n<p>Compile Nagios;<\/p>\n\n\n\n<pre id=\"block-12d28204-4728-4be9-b9e5-48caf182c479\" class=\"wp-block-preformatted\">.\/configure --with-httpd-conf=\/etc\/apache2\/sites-enabled<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>\nCreating sample config files in sample-config\/ ...\n\n\n*** Configuration summary for nagios 4.4.11 2023-04-14 ***:\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):  \n\n\nReview the options above for accuracy.  If they look okay,\ntype 'make all' to compile the main program and CGIs.\n\n<\/code><\/pre>\n\n\n\n<p>Compile Nagios program and CGIs<\/p>\n\n\n\n<pre id=\"block-b2dffae1-f691-444e-9eaf-e0c6c303e66b\" class=\"wp-block-preformatted\">make all<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>\n*** Compile finished ***\n\nIf the main program and CGIs compiled without any errors, you\ncan continue with testing or installing Nagios as follows (type\n'make' without any arguments for a list of all possible options):\n\n  make test\n     - This runs the test suite\n\n  make install\n     - This installs the main program, CGIs, and HTML files\n\n  make install-init\n     - This installs the init script in \/lib\/systemd\/system\n\n  make install-daemoninit\n     - This will initialize the init script\n       in \/lib\/systemd\/system\n\n  make install-groups-users\n     - This adds the users and groups if they do not exist\n\n  make install-commandmode\n     - This installs and configures permissions on the\n       directory for holding the external command file\n\n  make install-config\n     - This installs *SAMPLE* config files in \/usr\/local\/nagios\/etc\n       You'll have to modify these sample files before you can\n       use Nagios.  Read the HTML documentation for more info\n       on doing this.  Pay particular attention to the docs on\n       object configuration files, as they determine what\/how\n       things get monitored!\n\n  make install-webconf\n     - This installs the Apache config file for the Nagios\n       web interface\n\n  make install-exfoliation\n     - This installs the Exfoliation theme for the Nagios\n       web interface\n\n  make install-classicui\n     - This installs the classic theme for the Nagios\n       web interface\n\n\n*** Support Notes *******************************************\n\nIf you have questions about configuring or running Nagios,\nplease make sure that you:\n\n     - Look at the sample config files\n     - Read the documentation on the Nagios Library at:\n           <blockquote class=\"wp-embedded-content\" data-secret=\"XwJLvoAcDa\"><a href=\"https:\/\/library.nagios.com\/\" target=\"_blank\" rel=\"noopener\">Nagios Library<\/a><\/blockquote><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;Nagios Library&#8221; &#8212; Nagios Library\" src=\"https:\/\/library.nagios.com\/embed\/#?secret=XwJLvoAcDa\" data-secret=\"XwJLvoAcDa\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n\nbefore you post a question to one of the mailing lists.\nAlso make sure to include pertinent information that could\nhelp others help you.  This might include:\n\n     - What version of Nagios you are using\n     - What version of the plugins you are using\n     - Relevant snippets from your config files\n     - Relevant error messages from the Nagios log file\n\nFor more information on obtaining support for Nagios, visit:\n\n       <blockquote class=\"wp-embedded-content\" data-secret=\"ypwQzHFMZw\"><a href=\"https:\/\/support.nagios.com\/\" target=\"_blank\" rel=\"noopener\">Nagios Support Home<\/a><\/blockquote><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;Nagios Support Home&#8221; &#8212; Nagios Support\" src=\"https:\/\/support.nagios.com\/embed\/#?secret=5t4CiX7nhX#?secret=ypwQzHFMZw\" data-secret=\"ypwQzHFMZw\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n\n*************************************************************\n\nEnjoy.\n\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"create-nagios-user-and-group\">Create Nagios User and Group<\/h3>\n\n\n\n<p>Create a user and a group that will be used to run Nagios. Add apache user to the nagios group<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>make install-groups-users<\/code><\/pre>\n\n\n\n<pre id=\"block-47e94670-a7ca-451e-ac32-366f4f231855\" class=\"wp-block-preformatted\">usermod -aG nagios www-data<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"install-nagios-core-on-ubuntu-18-04\">Install Nagios Core on Ubuntu 18.04<\/h3>\n\n\n\n<p>Install Nagios Core binaries, CGIs and HTML files.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>make install<\/code><\/pre>\n\n\n\n<p>Install the init scripts for Nagios services\/daemon<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>make install-daemoninit<\/code><\/pre>\n\n\n\n<p>Install and configure permissions on the directory for holding the external command file<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>make install-commandmode<\/code><\/pre>\n\n\n\n<p>Install sample Nagios configuration files in <strong>\/usr\/local\/nagios\/etc<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>make install-config<\/code><\/pre>\n\n\n\n<p>Install and configure apache web server configuration files and enable apache rewrite and cgi modules<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>make install-webconf<\/code><\/pre>\n\n\n\n<pre id=\"block-8ec76c98-c981-47da-a3fa-af87a84cc90b\" class=\"wp-block-preformatted\">a2enmod rewrite cgi<\/pre>\n\n\n\n<p>If firewall is running, allow apache through it.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>ufw allow Apache<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"create-nagios-core-basic-web-auth-user\">Create Nagios Core Basic Web Auth User<\/h3>\n\n\n\n<p>Create a user account for logging into the Nagios web interface.<\/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>where <strong>nagiosadmin<\/strong> is the username for logging in to Nagios Web interface and file <strong>htpasswd.users<\/strong> stores user credentials.<\/p>\n\n\n\n<p>When adding more users, omit option -c to avoid replacing existing users.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"start-nagios-and-apache\">Start Nagios and Apache<\/h3>\n\n\n\n<p>Restart and enable both Apache and Nagios services as follows:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>systemctl restart apache2;systemctl enable apache2<\/code><\/pre>\n\n\n\n<pre id=\"block-72dd6507-d6bd-444c-b18b-2a9854da35cd\" class=\"wp-block-preformatted\">systemctl restart nagios;systemctl enable nagios<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"accessing-nagios-web-interface\">Accessing Nagios Web Interface<\/h3>\n\n\n\n<p>Now access the Nagios web interface using the following URL, <strong>http:\/\/&lt;ip-address-OR-hostname&gt;\/nagios<\/strong>.<\/p>\n\n\n\n<p>You will be prompted to login. So login with admin user created above. Once you login, this the Nagios dashboard that welcomes you.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1883\" height=\"929\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2023\/05\/nagios-dashboard.png\" alt=\"\" class=\"wp-image-16548\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2023\/05\/nagios-dashboard.png?v=1683838840 1883w, https:\/\/kifarunix.com\/wp-content\/uploads\/2023\/05\/nagios-dashboard-768x379.png?v=1683838840 768w, https:\/\/kifarunix.com\/wp-content\/uploads\/2023\/05\/nagios-dashboard-1536x758.png?v=1683838840 1536w\" sizes=\"(max-width: 1883px) 100vw, 1883px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"install-nagios-plugins-on-ubuntu-18-04\">Install Nagios Plugins on Ubuntu 18.04<\/h3>\n\n\n\n<p>By default, Nagios just monitors itself. However, no plugin has been installed. Thus, <a href=\"https:\/\/www.nagios.org\/downloads\/nagios-plugins\/\" target=\"_blank\" rel=\"noreferrer noopener\">download<\/a>, compile and install Nagios plugins;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>wget https:\/\/nagios-plugins.org\/download\/nagios-plugins-2.4.4.tar.gz -P \/tmp<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>cd \/tmp<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>tar xzf nagios-plugins-2.4.4.tar.gz<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>cd nagios-plugins-2.4.4\/<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>.\/configure --with-nagios-user=nagios --with-nagios-group=nagios<\/code><\/pre>\n\n\n\n<p>Compile and install;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>make<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>make install<\/code><\/pre>\n\n\n\n<p>The plugins are now installed;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ls \/usr\/local\/nagios\/libexec\/ | column<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>\ncheck_apt\t\tcheck_dns\t\tcheck_ifstatus\t\tcheck_nagios\t\tcheck_overcr\t\tcheck_spop\t\tcheck_uptime\ncheck_breeze\t\tcheck_dummy\t\tcheck_imap\t\tcheck_nntp\t\tcheck_ping\t\tcheck_ssh\t\tcheck_users\ncheck_by_ssh\t\tcheck_file_age\t\tcheck_ircd\t\tcheck_nntps\t\tcheck_pop\t\tcheck_ssl_validity\tcheck_wave\ncheck_clamd\t\tcheck_flexlm\t\tcheck_jabber\t\tcheck_nt\t\tcheck_procs\t\tcheck_ssmtp\t\tnegate\ncheck_cluster\t\tcheck_ftp\t\tcheck_load\t\tcheck_ntp\t\tcheck_real\t\tcheck_swap\t\tremove_perfdata\ncheck_dhcp\t\tcheck_http\t\tcheck_log\t\tcheck_ntp_peer\t\tcheck_rpc\t\tcheck_tcp\t\turlize\ncheck_dig\t\tcheck_icmp\t\tcheck_mailq\t\tcheck_ntp_time\t\tcheck_sensors\t\tcheck_time\t\tutils.pm\ncheck_disk\t\tcheck_ide_smart\t\tcheck_mrtg\t\tcheck_nwstat\t\tcheck_simap\t\tcheck_udp\t\tutils.sh\ncheck_disk_smb\t\tcheck_ifoperstatus\tcheck_mrtgtraf\t\tcheck_oracle\t\tcheck_smtp\t\tcheck_ups\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"restart-nagios-core-service\">Restart Nagios Core service<\/h3>\n\n\n\n<p>Now restart Nagios core service to start using the plugins.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>systemctl restart nagios<\/code><\/pre>\n\n\n\n<p>Congratulations! You Nagios server is now ready and running.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1893\" height=\"522\" src=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2023\/05\/nagios-localhost-monitoring.png\" alt=\"\" class=\"wp-image-16550\" title=\"\" srcset=\"https:\/\/kifarunix.com\/wp-content\/uploads\/2023\/05\/nagios-localhost-monitoring.png?v=1683839700 1893w, https:\/\/kifarunix.com\/wp-content\/uploads\/2023\/05\/nagios-localhost-monitoring-768x212.png?v=1683839700 768w, https:\/\/kifarunix.com\/wp-content\/uploads\/2023\/05\/nagios-localhost-monitoring-1536x424.png?v=1683839700 1536w\" sizes=\"(max-width: 1893px) 100vw, 1893px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"other-tutorials\">Other Tutorials<\/h3>\n\n\n\n<p><a title=\"Add Hosts to Nagios Server For Monitoring\" href=\"https:\/\/kifarunix.com\/add-hosts-to-nagios-server-for-monitoring\/\" target=\"_blank\" rel=\"bookmark noopener noreferrer\">Add Hosts to Nagios Server For Monitoring<\/a><\/p>\n\n\n\n<p><a title=\"Install Nagios NRPE Agent on CentOS 8\" href=\"https:\/\/kifarunix.com\/install-nagios-nrpe-agent-on-centos-8\/\" target=\"_blank\" rel=\"bookmark noopener noreferrer\">Install Nagios NRPE Agent on CentOS 8<\/a><\/p>\n\n\n\n<p><a title=\"Monitor SSL\/TLS Certificates Expiry with Nagios\" href=\"https:\/\/kifarunix.com\/monitor-ssl-tls-certificates-expiry-with-nagios\/\" target=\"_blank\" rel=\"bookmark noopener noreferrer\">Monitor SSL\/TLS Certificates Expiry with Nagios<\/a><\/p>\n\n\n\n<p><a title=\"Configure Nagios Email Notification Using Gmail\" href=\"https:\/\/kifarunix.com\/configure-nagios-email-notification-using-gmail\/\" target=\"_blank\" rel=\"bookmark noopener noreferrer\">Configure Nagios Email Notification Using Gmail<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial we are going to learn how to install and Configure Nagios Core from source on Ubuntu 18.04 for server resource consumption and<\/p>\n","protected":false},"author":1,"featured_media":16550,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[72,121,73],"tags":[78,1554,1555,74,76,1556,67],"class_list":["post-398","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-monitoring","category-howtos","category-nagios","tag-buld-from-source","tag-install-nagios-from-source-on-ubuntu-18-04","tag-install-nagios-on-ubuntu-18-04","tag-monitoring","tag-nagios-core","tag-nagios-monitoring-ubuntu-18-04","tag-ubuntu-18-04","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\/398"}],"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=398"}],"version-history":[{"count":9,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/398\/revisions"}],"predecessor-version":[{"id":20952,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/398\/revisions\/20952"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media\/16550"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=398"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=398"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=398"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}