{"id":1464,"date":"2017-06-09T11:45:11","date_gmt":"2017-06-09T06:15:11","guid":{"rendered":"https:\/\/pheonixsolutions.com\/blog\/?p=1464"},"modified":"2017-06-09T11:45:11","modified_gmt":"2017-06-09T06:15:11","slug":"install-configure-nagios-server","status":"publish","type":"post","link":"https:\/\/pheonixsolutions.com\/blog\/install-configure-nagios-server\/","title":{"rendered":"Install and Configure Nagios Server"},"content":{"rendered":"<h4>Install and Configure Nagios Server<\/h4>\n<p><strong>Date Posted: 08-06-2017<\/strong><\/p>\n<p>Nagios is an open source monitor tool widely used to monitor client machines. Here, we are going to explain on how to install and configure nagios server.<\/p>\n<h4>Prerequisites:<\/h4>\n<ol>\n<li>Centos 7.0 Server &#8211; In this post, we are using centos server 7.0. We can use Ubuntu host as well to install nagios server.<\/li>\n<\/ol>\n<h4>Implementation:<\/h4>\n<p>We assumes that this is a fresh centos server. Let&#8217;s start with disabling selinux.<\/p>\n<p><code>setenforce 0<\/code><\/p>\n<p>Disable selinux permanently.<\/p>\n<p><code>vi \/etc\/selinux\/config<\/code><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">SELINUX=disabled<\/pre>\n<p>Install dependencies.<\/p>\n<p><code>yum install -y httpd php gcc glibc glibc-common gd gd-devel make net-snmp<\/code><\/p>\n<p>Create a nagios user and group nagcmd<\/p>\n<p><code>useradd nagios<br \/>\ngroupadd nagcmd<\/code><\/p>\n<p>Add the users nagios and apache to nagcmd<\/p>\n<p><code>usermod -G nagcmd nagios<br \/>\nusermod -G nagcmd apache<\/code><\/p>\n<p>Download the nagios-server and nagios-plugins<\/p>\n<p><code>cd \/usr\/local\/src\/<br \/>\nwget https:\/\/sourceforge.net\/projects\/nagios\/files\/nagios-4.x\/nagios-4.3.2\/nagios-4.3.2.tar.gz<\/code><\/p>\n<p><code>wget https:\/\/nagios-plugins.org\/download\/nagios-plugins-2.2.1.tar.gz<\/code><\/p>\n<p>Extract the files nagios-server file and nagios plugin file.<\/p>\n<p><code>tar -xzf nagios-4.3.2.tar.gz<br \/>\ntar -xzf nagios-plugins-2.2.1.tar.gz<\/code><\/p>\n<p>Change the directory.<\/p>\n<p><code>cd nagios-4.3.2<\/code><\/p>\n<p>Configure the nagios.<\/p>\n<p><code>.\/configure --with-command-group=nagcmd<\/code><\/p>\n<p>Make and make install.<\/p>\n<p><code>make all<br \/>\nmake install<\/code><\/p>\n<p>Create init script and command mode<\/p>\n<p><code>make install-init<\/code><\/p>\n<p><code>make install-commandmode<\/code><\/p>\n<p>Create nagios configuration<\/p>\n<p><code>make install-config<\/code><\/p>\n<p>The above command will create basic configuration file.<\/p>\n<h4>Configuring Nagios:<\/h4>\n<p>Open\u00a0<em>contacts.cfg\u00a0<\/em> and update the email address where we want to receive notification.<\/p>\n<p><code>vi\u00a0\/usr\/local\/nagios\/etc\/objects\/contacts.cfg<\/code><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">email                           nagios@domain.tld<\/pre>\n<p>Install web-conf<\/p>\n<p><code>make install-webconf<\/code><\/p>\n<p>Create a nagiosadmin user to maintain authentication page on nagios interface<\/p>\n<p><code>htpasswd -s -c \/usr\/local\/nagios\/etc\/htpasswd.users nagiosadmin<\/code><\/p>\n<p>Enter the password and repeat the password.<\/p>\n<p>Start the httpd service<\/p>\n<p><code>service httpd start<\/code><\/p>\n<p>Now, install the nagios plugin which we downloaded already.<\/p>\n<p><code>cd \/usr\/local\/src\/nagios-plugins-2.2.1<\/code><\/p>\n<p>Configure the plugins.<\/p>\n<p><code>.\/configure --with-nagios-user=nagios --with-nagios-group=nagios<\/code><\/p>\n<p>Make &amp; Make install the configured plugin<\/p>\n<p><code>make &amp;&amp; make install<\/code><\/p>\n<p>Enable both nagios and httpd service on startup.<\/p>\n<p><code>systemctl enable nagios<\/code><br \/>\n<code>systemctl enable httpd<\/code><\/p>\n<p>Start the nagios service<\/p>\n<p><code>service nagios start<\/code><\/p>\n<h4>Additional Information:<\/h4>\n<p>Now, we create a configuration directory for the client hosts.<\/p>\n<p><code>mkdir \/usr\/local\/nagios\/etc\/servers<\/code><\/p>\n<p>Add the configuration directory\u00a0<em>nagios.cfg<\/em><\/p>\n<p><code>vi \/usr\/local\/nagios\/etc\/nagios.cfg<\/code><\/p>\n<p>Uncomment the following line,<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">cfg_dir=\/usr\/local\/nagios\/etc\/servers<\/pre>\n<p>Add the NRPE\u00a0<em>command_line\u00a0<\/em>to check remote hosts.<\/p>\n<p><code>vi\u00a0\/usr\/local\/nagios\/etc\/objects\/commands.cfg<\/code><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">###############################################################################\r\n# NRPE CHECK COMMAND\r\n#\r\n# Command to use NRPE to check remote host systems\r\n###############################################################################\r\ndefine command{\r\ncommand_name check_nrpe\r\ncommand_line $USER1$\/check_nrpe -H $HOSTADDRESS$ -c $ARG1$\r\n}<\/pre>\n<p>Verify the nagios configuration for syntax error.<\/p>\n<p><code>\/usr\/local\/nagios\/bin\/nagios -v \/usr\/local\/nagios\/etc\/nagios.cfg<\/code><\/p>\n<p>Restart the nagios service.<\/p>\n<p><code>\/etc\/init.d\/nagios restart<\/code><\/p>\n<p>Access the nagios URL on the browser.<\/p>\n<p><strong><em>http:\/\/IPADDRESS\/nagios<\/em><\/strong><\/p>\n<p>Enter the password which we created using htpasswd.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Install and Configure Nagios Server Date Posted: 08-06-2017 Nagios is an open source monitor tool widely used to monitor client [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1019],"tags":[161,346],"class_list":["post-1464","post","type-post","status-publish","format-standard","hentry","category-cloud-aws","tag-centos","tag-nagios","psol-cat-cloud-aws"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/phn2x7-nC","jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/1464","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=1464"}],"version-history":[{"count":0,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/1464\/revisions"}],"wp:attachment":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=1464"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=1464"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=1464"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}