{"id":841,"date":"2018-07-02T03:31:06","date_gmt":"2018-07-02T03:31:06","guid":{"rendered":"http:\/\/orissawebhosting.in\/blog\/?p=841"},"modified":"2019-06-27T15:27:09","modified_gmt":"2019-06-27T15:27:09","slug":"how-to-install-and-configure-nagios-on-centos-7","status":"publish","type":"post","link":"https:\/\/orissawebhosting.in\/blog\/how-to-install-and-configure-nagios-on-centos-7\/","title":{"rendered":"How to Install and Configure Nagios on CentOS 7"},"content":{"rendered":"<h4>Install and Configure Nagios<\/h4>\n<p>Nagios Core is free &amp; open source monitoring tool or software which can monitor the resources like servers, network equipment like firewall, network switches and printers etc. Nagios core also provides alerting services, using which nagios informs administrators about issue that has occurred &amp; then trigger alerts again when the issue has been resolved.<br \/>\nNagios provides information like CPU utilization, Disk utilization, Memory utilization &amp; also has support for a number of networking protocols like\u00a0<strong>SMTP<\/strong>,\u00a0<strong>HTTP<\/strong>,\u00a0<strong>POP3<\/strong>,\u00a0<strong>SNMP<\/strong>,\u00a0<strong>ICMP<\/strong>,\u00a0<strong>FTP<\/strong>,\u00a0<strong>SSH<\/strong>\u00a0etc. Nagios shows all the information regarding all the servers on a single screen using its web-interface.<\/p>\n<p><strong>Installing essential packages<\/strong><\/p>\n<p>We need to install some essential packages like apache, php &amp; packages required for building the source packages, use below command to install these packages.<\/p>\n<pre># yum install httpd php gcc glibc glibc-comman gd gd-devel make net-snmp unzip -y<\/pre>\n<h4><span style=\"font-size: 12pt;\">Downloading and extracting the Nagios packages:<\/span><\/h4>\n<p>Next thing to do is to download &amp; extract the nagios &amp; its plugins files. The download links are mentioned below<\/p>\n<pre># wget https:\/\/sourceforge.net\/projects\/nagios\/files\/nagios-4.x\/nagios-4.3.2\/nagios-4.3.2.tar.gz\n# wget https:\/\/nagios-plugins.org\/download\/nagios-plugins-2.2.1.tar.gz<\/pre>\n<p>To extract the packages, run following commands.<\/p>\n<pre># tar -zxvf nagios-4.3.2.tar.gz\n# tar -zxpvf nagios-plugins-2.2.1.tar.gz<\/pre>\n<h4><span style=\"font-size: 12pt;\">Create user and group for Nagios<\/span><\/h4>\n<p>Next step is to create a user named \u2018<strong>nagios<\/strong>\u2018 &amp; a group named \u2018<strong>nagcmd<\/strong>\u2018 for running nagios,<\/p>\n<pre># useradd nagios\n# passwd nagios\n# groupadd nagcmd<\/pre>\n<p>Once the user &amp; group has been added, we will now add the user nagios &amp; apache user to the created group i.e. nagcmd<\/p>\n<pre># usermod -G nagcmd nagios\n# usermod -G nagcmd apache<\/pre>\n<h4><span style=\"font-size: 12pt;\">Installing Nagios core<\/span><\/h4>\n<p>We are now ready to install the nagios on our server, so go to the folder with extracted nagios core files &amp; compile the extracted files.<\/p>\n<pre># cd nagios-4.3.2\n# .\/configure --with-command-group=nagcmd<\/pre>\n<p>Next we will install the compiled nagios package by running,<\/p>\n<pre># make all\n# make install<\/pre>\n<p>After running these, we need to install init scripts, command mode (to make nagios work from CLI) &amp; also need to install some sample Nagios files.<\/p>\n<pre># make install-init\n# make install-commandmode\n# make install-config<\/pre>\n<h4><span style=\"font-size: 12pt;\">Configuring Nagios Core Web-Interface<\/span><\/h4>\n<p>We will now install the web interface for the nagios, as we will be using web interface for monitoring the resources of the client systems. To install web interface, run.<\/p>\n<pre># make install-webconf<\/pre>\n<p>Web interface will be installed with a default user by the name \u2018<strong>nagiosadmin<\/strong>\u2018 but there will be no default password for the user. We will create default password for user by issuing the following command,<\/p>\n<pre># htpasswd -s -c \/usr\/local\/nagios\/etc\/htpasswd.users nagiosadmin\nNew password:\nRe-type new password:\nAdding password for user nagiosadmin<\/pre>\n<h4><span style=\"font-size: 12pt;\">Configuring email alerts<\/span><\/h4>\n<p>Though this is an optional step but consider doing it. By configuring an email to receive alerts on nagios, you will remain informed of all the server activities 24\/7. To configure an email, open\u00a0and enter an email address.<\/p>\n<pre>vi \/usr\/local\/nagios\/etc\/objects\/contacts.cfg<\/pre>\n<p>Next, restart\u00a0 Apache server for changes to take effect.<\/p>\n<pre># systemctl restart httpd<\/pre>\n<h4><span style=\"font-size: 12pt;\">Installing the Nagios Plugins<\/span><\/h4>\n<p>We have now completed installation for nagios core but we need to install plugins as without them we can\u2019t monitor the resources. So open the directory with nagios plugin files &amp; then we will compile &amp; install the plugins.<\/p>\n<pre># cd nagios-plugins-2.2.1\/\n# .\/configure --with-nagios-user=nagios --with-nagios-group=nagios\n# make\n# make install<\/pre>\n<p>Installation of nagios plugins is also complete.<\/p>\n<h4><span style=\"font-size: 12pt;\">Verify Nagios files<\/span><\/h4>\n<p>Last step is now to verify Nagios configuration file against a sample configuration file.<\/p>\n<pre># \/usr\/local\/nagios\/bin\/nagios -v \/usr\/local\/nagios\/etc\/nagios.cfg<\/pre>\n<p>This will ensure that all the settings made to nagios configuration file are correct &amp; if there is any issue with file, it will report that as well. After making sure that config file is error less, we will restart the nagios &amp; apache service to implement the changes.<\/p>\n<pre># systemctl restart\u00a0 nagios\n# systemctl restart httpd<\/pre>\n<p>Also make sure that these services restart after a reboot,<\/p>\n<pre># systemctl enable\u00a0 nagios\n# systemctl enable httpd<\/pre>\n<p><strong>Note:<\/strong>\u00a0In Case OS firewall in enabled on your Nagios server then allow 80 port using beneath commands<\/p>\n<pre># firewall-cmd --permanent --add-port=80\/tcp\n# firewall-cmd --reload<\/pre>\n<h4><span style=\"font-size: 12pt;\">Logging into Nagios Web-interface<\/span><\/h4>\n<p>Now to check the status of the services, login to the nagios web interface by using the ip address of the nagios server followed by \/nagios<\/p>\n<p>http:\/\/100.10.100.10\/nagios<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-845 size-full\" src=\"http:\/\/orissawebhosting.in\/blog\/wp-content\/uploads\/2018\/07\/nagios.jpg\" alt=\"\" width=\"1112\" height=\"655\" srcset=\"https:\/\/orissawebhosting.in\/blog\/wp-content\/uploads\/2018\/07\/nagios.jpg 1112w, https:\/\/orissawebhosting.in\/blog\/wp-content\/uploads\/2018\/07\/nagios-300x177.jpg 300w, https:\/\/orissawebhosting.in\/blog\/wp-content\/uploads\/2018\/07\/nagios-768x452.jpg 768w, https:\/\/orissawebhosting.in\/blog\/wp-content\/uploads\/2018\/07\/nagios-1024x603.jpg 1024w\" sizes=\"(max-width: 1112px) 100vw, 1112px\" \/><\/p>\n<p>You will now be asked to provide the credentials, Use nagiosadmin as user name and password that we set in above steps. \u00a0Once authenticated we can access the home page of nagios server.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Install and Configure Nagios Nagios Core is free &amp; open source monitoring tool or software which can monitor the resources like servers, network equipment like firewall, network switches and printers etc. Nagios core also provides alerting services, using which nagios informs administrators about issue that has occurred &amp; then trigger alerts again when the issue has been resolved. Nagios provides information like CPU utilization, Disk utilization, Memory utilization &amp; also has support for a number of networking protocols like\u00a0SMTP,\u00a0HTTP,\u00a0POP3,\u00a0SNMP,\u00a0ICMP,\u00a0FTP,\u00a0SSH\u00a0etc. Nagios shows all the information regarding all the servers on a&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/orissawebhosting.in\/blog\/wp-json\/wp\/v2\/posts\/841"}],"collection":[{"href":"https:\/\/orissawebhosting.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/orissawebhosting.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/orissawebhosting.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/orissawebhosting.in\/blog\/wp-json\/wp\/v2\/comments?post=841"}],"version-history":[{"count":5,"href":"https:\/\/orissawebhosting.in\/blog\/wp-json\/wp\/v2\/posts\/841\/revisions"}],"predecessor-version":[{"id":1066,"href":"https:\/\/orissawebhosting.in\/blog\/wp-json\/wp\/v2\/posts\/841\/revisions\/1066"}],"wp:attachment":[{"href":"https:\/\/orissawebhosting.in\/blog\/wp-json\/wp\/v2\/media?parent=841"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/orissawebhosting.in\/blog\/wp-json\/wp\/v2\/categories?post=841"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/orissawebhosting.in\/blog\/wp-json\/wp\/v2\/tags?post=841"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}