{"id":819,"date":"2014-10-13T18:24:46","date_gmt":"2014-10-13T21:24:46","guid":{"rendered":"http:\/\/blog.abratel.com.br\/?p=819"},"modified":"2018-08-30T23:11:28","modified_gmt":"2018-08-31T02:11:28","slug":"819","status":"publish","type":"post","link":"https:\/\/blog.abratel.com.br\/?p=819","title":{"rendered":"Install Nagios in CentOS 7"},"content":{"rendered":"<p>So CentOS 7 is out and there are quite some differences from it\u2019s predecessor CentOS 6. This is why i decided to write a new how to installing Nagios Core 4.0.8 on the latest fully updated CentOS 7 minimal installation \u2013 Install Nagios on CentOS 7. The Firewalld and SELinux are both enabled and running in this how to so you should not have any problems with it. If you are not familiar with using Systemd and Firewalld there are couple of commands to get you in the right direction and maybe slowly get used to it \u2013 i sure need\/want to too.<\/p>\n<p>Install Nagios on CentOS 7<\/p>\n<p><strong>Let\u2019s Install Nagios on CentOS 7!<\/strong><\/p>\n<p><strong>1. Install \u201cdeltarpm\u201d package<\/strong><\/p>\n<p>The first step to install nagios on CentOS7 is to install \u201cdeltarpm\u201d. This package creates deltas between RPMs. It is required in future RPM installations.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n\r\nyum install deltarpm -y\r\nyum install lm_sensors -y\r\nyum groupinstall &quot;Development Tools&quot; -y\r\n\r\n\r\nvisudo para adicionar essas permiss\u00f5es ao usu\u00e1rio em quest\u00e3o caso for usar o nagisk (plugin nagios para asterisk)\r\nComo n\u00e3o sei o nome do usu\u00e1rio escolhido na instala\u00e7\u00e3o vou por as duas op\u00e7\u00f5es:\r\n\r\nnagios ALL= NOPASSWD: \/usr\/sbin\/asterisk\r\nnagiosadmin ALL= NOPASSWD: \/usr\/sbin\/asterisk\r\n\r\n<\/pre>\n<p><strong>2. Install Required Dependencies<\/strong><\/p>\n<p>These are the packages we need to install to satisfy Nagios dependency resolution, when compiling it.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n[root@geekpeek ~]# yum install wget httpd php gcc glibc glibc-common gd gd-devel make net-snmp -y\r\n<\/pre>\n<p><strong>3. Download the Latest Version of Nagios Core<\/strong><\/p>\n<p>The latest version of Nagios Core is available for free download at THIS link.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n[root@geekpeek ~]# wget http:\/\/prdownloads.sourceforge.net\/sourceforge\/nagios\/nagios-4.0.8.tar.gz\r\n<\/pre>\n<p><strong>4. Create \u201cnagios\u201d User and add \u201capache\u201d User to Nagios Group<\/strong><\/p>\n<p>Before compiling Nagios Core we need to create \u201cnagios\u201d user and group. When \u201cnagios\u201d user and group is created, add \u201capache\u201d user to this group \u2013 this needs to be done due to some file permissions which enable us to do actions via Nagios web interface.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n[root@geekpeek ~]# useradd nagios\r\n[root@geekpeek ~]# usermod -G nagios apache\r\n<\/pre>\n<p><strong>5. Extract Nagios Tarball<\/strong><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n[root@geekpeek ~]# tar -xvzf nagios-4.0.8.tar.gz\r\n<\/pre>\n<p><strong>6. Run Configure and Make Nagios<\/strong><\/p>\n<p>To install Nagios on CentOS 7 we need to configure and make Nagios.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n[root@geekpeek ~]# cd nagios-4.0.8\r\n[root@geekpeek nagios-4.0.8]# .\/configure\r\n...\r\n...\r\nCreating sample config files in sample-config\/ ...\r\n\r\n\r\n*** Configuration summary for nagios 4.0.8 08-12-2014 ***:\r\n\r\n General Options:\r\n -------------------------\r\n Nagios executable: nagios\r\n Nagios user\/group: nagios,nagios\r\n Command user\/group: nagios,nagios\r\n Event Broker: yes\r\n Install ${prefix}: \/usr\/local\/nagios\r\n Install ${includedir}: \/usr\/local\/nagios\/include\/nagios\r\n Lock file: ${prefix}\/var\/nagios.lock\r\n Check result directory: ${prefix}\/var\/spool\/checkresults\r\n Init directory: \/etc\/rc.d\/init.d\r\n Apache conf.d directory: \/etc\/httpd\/conf.d\r\n Mail program: \/bin\/mail\r\n Host OS: linux-gnu\r\n IOBroker Method: epoll\r\n\r\n Web Interface Options:\r\n ------------------------\r\n HTML URL: http:\/\/localhost\/nagios\/\r\n CGI URL: http:\/\/localhost\/nagios\/cgi-bin\/\r\n Traceroute (used by WAP): \r\n\r\n<\/pre>\n<p>Review the options above for accuracy. If they look okay,<br \/>\ntype &#8216;make all&#8217; to compile the main program and CGIs.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n\r\n[root@geekpeek nagios-4.0.8]# make all\r\n[root@geekpeek nagios-4.0.8]# make install\r\n[root@geekpeek nagios-4.0.8]# make install-init\r\n[root@geekpeek nagios-4.0.8]# make install-commandmode\r\n[root@geekpeek nagios-4.0.8]# make install-config\r\n[root@geekpeek nagios-4.0.8]# make install-webconf\r\n[root@geekpeek nagios-4.0.8]# make install-exfoliation\r\n<\/pre>\n<p><strong>7. Run Nagios Configuration Check<\/strong><\/p>\n<p>You can do this anytime after changing the Nagios configuration to make sure service restart will be OK.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n[root@geekpeek nagios-4.0.8]# \/usr\/local\/nagios\/bin\/nagios -v \/usr\/local\/nagios\/etc\/nagios.cfg\r\n<\/pre>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nNagios Core 4.0.8\r\nCopyright (c) 2009-present Nagios Core Development Team and Community Contributors\r\nCopyright (c) 1999-2009 Ethan Galstad\r\nLast Modified: 08-12-2014\r\nLicense: GPL\r\n\r\nWebsite: http:\/\/www.nagios.org\r\nReading configuration data...\r\n Read main config file okay...\r\n Read object config files okay...\r\n\r\nRunning pre-flight check on configuration data...\r\n\r\nChecking objects...\r\n Checked 8 services.\r\n Checked 1 hosts.\r\n Checked 1 host groups.\r\n Checked 0 service groups.\r\n Checked 1 contacts.\r\n Checked 1 contact groups.\r\n Checked 24 commands.\r\n Checked 5 time periods.\r\n Checked 0 host escalations.\r\n Checked 0 service escalations.\r\nChecking for circular paths...\r\n Checked 1 hosts\r\n Checked 0 service dependencies\r\n Checked 0 host dependencies\r\n Checked 5 timeperiods\r\nChecking global event handlers...\r\nChecking obsessive compulsive processor commands...\r\nChecking misc settings...\r\n\r\nTotal Warnings: 0\r\nTotal Errors: 0\r\n\r\nThings look okay - No serious problems were detected during the pre-flight check\r\n<\/pre>\n<p><strong>8. Create Nagios Web Interface User<\/strong><\/p>\n<p>Beware, we are creating htpasswd.users file with this name on exact location since this location is default in Nagios configuration file \u2013 if you change the file name or location you must edit Nagios configiuration also!<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n[root@geekpeek nagios-4.0.8]# htpasswd -c -B \/usr\/local\/nagios\/etc\/htpasswd.users nagiosadmin\r\nNew password: \r\nRe-type new password: \r\nAdding password for user admin\r\n<\/pre>\n<p><strong>9. Install EPEL Repository and \u201cnagios-plugins-all\u201d<\/strong><\/p>\n<p>We need to install EPEL Repository for CentOS 7 to be able to download \u201cnagios-plugins-all\u201d package. These are all Nagios plugins you might ever need to monitor your Nagios clients. After installing \u201cnagios-plugins-all\u201d we must play around with some links, so Nagios can find the and use plugins \u2013 just follow the guide.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n[root@geekpeek nagios-4.0.8]# rpm -ivh https:\/\/ftp.fau.de\/epel\/beta\/7\/x86_64\/epel-release-7-0.2.noarch.rpm\r\n[root@geekpeek nagios-4.0.8]# yum install nagios-plugins-all -y\r\n[root@geekpeek nagios-4.0.8]# rm -rf \/usr\/local\/nagios\/libexec\r\n[root@geekpeek nagios-4.0.8]# ln -s \/usr\/lib64\/nagios\/plugins\/ \/usr\/local\/nagios\/libexec\r\n[root@geekpeek nagios-4.0.8]# chown -R nagios:nagios \/usr\/local\/nagios\/libexec\/\r\n<\/pre>\n<p><strong>10. Start Apache and Nagios Service<\/strong><\/p>\n<p>Note that Apache (httpd) service is native and is manipulated by \u201cSystemd\u201d (systemctl) but Nagios is not native and therefore still manipulated by \u201cSysV\u201d (chkconfig). We must start both services and make sure they start at boot.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n[root@geekpeek nagios-4.0.8]# systemctl enable httpd\r\n[root@geekpeek nagios-4.0.8]# systemctl start httpd\r\n[root@geekpeek nagios-4.0.8]# chkconfig nagios on\r\n[root@geekpeek nagios-4.0.8]# \/etc\/init.d\/nagios start\r\n<\/pre>\n<p><strong>11. Disable Blocking of Port 80<\/strong><\/p>\n<p>We need to add port 80 (TCP) to \u201cfirewalld\u201d permanent exceptions so we can access Nagios web interface.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n[root@geekpeek nagios-4.0.8]# firewall-cmd --add-port=80\/tcp\r\n [root@geekpeek nagios-4.0.8]# firewall-cmd --permanent --add-port=80\/tcp\r\n<\/pre>\n<p> <strong>12. Access Nagios Web Interface<\/strong><\/p>\n<p>This is the last step in install Nagios on CentOS 7 how to. We must confirm that Nagios Web Interface is reachable by accessing <\/p>\n<p>http:\/\/ip_addr_or_hostname\/nagios. Nagios Web Interface should open up.<\/p>\n<p> <a href=\"http:\/\/blog.abratel.com.br\/wp-content\/uploads\/2014\/10\/nagios-002.png\"><img loading=\"lazy\" src=\"http:\/\/blog.abratel.com.br\/wp-content\/uploads\/2014\/10\/nagios-002-300x213.png\" alt=\"nagios 002\" width=\"300\" height=\"213\" class=\"alignnone size-medium wp-image-822\" srcset=\"https:\/\/blog.abratel.com.br\/wp-content\/uploads\/2014\/10\/nagios-002-300x213.png 300w, https:\/\/blog.abratel.com.br\/wp-content\/uploads\/2014\/10\/nagios-002-600x427.png 600w, https:\/\/blog.abratel.com.br\/wp-content\/uploads\/2014\/10\/nagios-002.png 706w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>So CentOS 7 is out and there are quite some differences from it\u2019s predecessor CentOS 6. This is why i decided to write a new how to installing Nagios Core 4.0.8 on the latest fully updated CentOS 7 minimal installation \u2013 Install Nagios on CentOS&#8230;<\/p>\n","protected":false},"author":1,"featured_media":823,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=\/wp\/v2\/posts\/819"}],"collection":[{"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=819"}],"version-history":[{"count":5,"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=\/wp\/v2\/posts\/819\/revisions"}],"predecessor-version":[{"id":1081,"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=\/wp\/v2\/posts\/819\/revisions\/1081"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=\/wp\/v2\/media\/823"}],"wp:attachment":[{"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=819"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=819"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.abratel.com.br\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=819"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}