<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>how to monitor remote hosts with nagios Archives - Linux Windows and android Tutorials</title>
	<atom:link href="https://www.osradar.com/tag/how-to-monitor-remote-hosts-with-nagios/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.osradar.com</link>
	<description>tutorials and news and Seurity</description>
	<lastBuildDate>Mon, 07 Dec 2020 08:51:16 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.8.12</generator>
	<item>
		<title>How To Monitor Remote Linux Machines With Nagios on Linux</title>
		<link>https://www.osradar.com/how-to-monitor-remote-linux-machines-with-nagios-on-linux/</link>
					<comments>https://www.osradar.com/how-to-monitor-remote-linux-machines-with-nagios-on-linux/#respond</comments>
		
		<dc:creator><![CDATA[sabi]]></dc:creator>
		<pubDate>Wed, 20 May 2020 09:21:49 +0000</pubDate>
				<category><![CDATA[Applications]]></category>
		<category><![CDATA[Business]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[OpenSource]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Servers]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[how to install nagios]]></category>
		<category><![CDATA[how to monitor remote hosts with nagios]]></category>
		<category><![CDATA[nagios guide linux]]></category>
		<category><![CDATA[nagios monitoring tool]]></category>
		<category><![CDATA[nagios network monitoring]]></category>
		<guid isPermaLink="false">https://www.osradar.com/?p=20035</guid>

					<description><![CDATA[<p>Today we are going to learn that how to monitor remote Linux machines with Nagios on Linux. We&#8217;ve previously installed and configured Nagios on Ubuntu 20.04 and now we are moving forward to monitor the remote machines with Nagios. If you didn&#8217;t follow the previous article click on the below link first to set up [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.osradar.com/how-to-monitor-remote-linux-machines-with-nagios-on-linux/">How To Monitor Remote Linux Machines With Nagios on Linux</a> appeared first on <a rel="nofollow" href="https://www.osradar.com">Linux  Windows and android  Tutorials</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Today we are going to learn that <a href="https://www.osradar.com/?p=20035">how to monitor remote Linux machines with Nagios</a> on Linux. We&#8217;ve previously installed and configured Nagios on Ubuntu 20.04 and now we are moving forward to monitor the remote machines with Nagios. If you didn&#8217;t follow the previous article click on the below link first to set up the Nagios on your Ubuntu 20.04 system.</p>



<p><a href="https://www.osradar.com/how-to-install-nagios-on-ubuntu-20-04/">How To Install Nagios on Ubuntu 20.04</a></p>



<p>Here I&#8217;ll add CentOS  machine as a remote host on Ubuntu 20.04. You can also add other Linux remote hosts. For easy setup just follow the below steps.</p>



<h3><strong>Step 1: Update Your System</strong></h3>



<p>As usual we do, first of all update the system to fetch latest updates before going to install any new package.</p>



<pre class="wp-block-verse">sudo apt update &amp;&amp; sudo apt upgrade</pre>



<h3><strong>Step2: Install NRPE Add-on and Nagios Plugins on Ubuntu 20.04</strong></h3>



<p>NRPE (Nagios Remote Plugin Executor) helps you to monitor the remote machines as well as monitor the local resources of the remote machine like CPU usage, Memory usage, Disk and other resources information&#8217;s. Install it by hitting the below command.</p>



<p><strong>On Ubuntu</strong></p>



<pre class="wp-block-verse">sudo apt install -y nagios-nrpe-server nagios-plugins</pre>



<p><strong>On CentOS :</strong></p>



<p>To install Nagios server on CentOS  firstly add EPEL repository.</p>



<pre class="wp-block-verse">sudo rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm</pre>



<p>As Nagios requires some other packages install them by typing</p>



<p></p>



<p>And then run the below command to install it.</p>



<pre class="wp-block-verse">sudo yum install -y nrpe nagios-plugins-all</pre>



<h3><strong>Step 3: Configure NRPE Add-on</strong></h3>



<p>After installing the NRPE Add-on configure it to work best with our environment. Add the Nagios Server IP address by updating the <strong>/etc/nagios/nrpe.cfg</strong> file. Type the command to edit the file.</p>



<pre class="wp-block-verse">sudo nano /etc/nagios/nrpe.cfg</pre>



<p>And then add the Nagios server IP address like below.</p>



<pre class="wp-block-verse">allowed_hosts=192.168.0.10</pre>



<p>You can also add multiple Nagios servers by separating them with commas.</p>



<h3><strong>Step 4: Configuring Nagios Checks</strong></h3>



<p>Nrpe configuration file <strong>/etc/nagios/nrpe.cfg</strong> consists of basic commands to find the CPU, Memory, Disk usage etc.</p>



<p>Given command lines allow you to monitor logged in users, system load, root filesystem usage, swap usage and the total number of the processes by Nagios plugins. Run the below command.</p>



<pre class="wp-block-verse">sudo nano /etc/nagios/nrpe.cfg</pre>



<h3><strong>Commands Explanation For CentOS &amp; Ubuntu </strong></h3>



<pre class="wp-block-verse">command[check_users]=/usr/lib/nagios/plugins/check_users -w 5 -c 10<br>command[check_load]=/usr/lib/nagios/plugins/check_load -w 15,10,5 -c 30,25,20<br>command[check_root]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /<br>command[check_swap]=/usr/lib/nagios/plugins/check_swap -w 20% -c 10%<br>command[check_total_procs]=/usr/lib/nagios/plugins/check_procs -w 150 -c 200</pre>



<p><strong>Note:</strong><br>-w stand for WARNING<br>-c stand for CRITICAL</p>



<p>You can verify the check results by hitting the below command.</p>



<pre class="wp-block-verse">/usr/lib/nagios/plugins/check_procs -w 150 -c 200</pre>



<p><strong>Output:</strong></p>



<p>You&#8217;ll see the similar output</p>



<pre class="wp-block-verse">PROCS CRITICAL: 283 processes | procs=190;150;200;0;</pre>



<p>You can also change the warnings and critical to your own value like </p>



<pre class="wp-block-preformatted">/usr/lib/nagios/plugins/check_procs -w 300 -c 350</pre>



<p><strong>Output:</strong></p>



<pre class="wp-block-verse">PROCS OK: 282 processes | procs=282;300;350;0;</pre>



<p>To enable the monitoring, add the given destinations to the template file on the Nagios Server. Now, restart the NRPE services by hitting the below command.</p>



<pre class="wp-block-verse">sudo systemctl restart nagios-nrpe-server</pre>



<h3><strong>Step 5: Allow Firewall Access</strong></h3>



<p>After setting up the Nagios NRPE allow Nagios server to reach the NRPE server by giving access through firewall. To do this simply fire the below command in your terminal.</p>



<pre class="wp-block-verse">firewall-cmd --permanent --add-port=5666/tcp</pre>



<p>And then reload the firewall by</p>



<pre class="wp-block-verse">firewall-cmd --reload</pre>



<p>Add the following IP Tables rules.</p>



<pre class="wp-block-verse">iptables -I INPUT -p tcp --dport 5666 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT<br>iptables -I OUTPUT -p tcp --sport 5666 -m conntrack --ctstate ESTABLISHED -j ACCEPT<br>/etc/init.d/iptables save</pre>



<h3><strong>Step 6: Installing NRPE Plugin on Nagios Server</strong></h3>



<p>Simply fire the below command to install the NRPE plugin on Nagios server.</p>



<p><strong>On CentOS</strong>:</p>



<pre class="wp-block-verse">sudo rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
sudo yum -y install nagios-plugins-nrpe</pre>



<p><strong>On Ubuntu:</strong></p>



<pre class="wp-block-verse">sudo apt install -y nagios-nrpe-plugin</pre>



<p>Now, edit the <strong>/usr/local/nagios/etc/nagios.cfg</strong> file and uncomment the below line:</p>



<pre class="wp-block-verse">cfg_dir=/usr/local/nagios/etc/servers</pre>



<p>Then make a new config directory.</p>



<p><strong>On CentOS:</strong></p>



<pre class="wp-block-verse">sudo nano /usr/local/nagios/etc/objects/commands.cfg</pre>



<p><strong>On Ubuntu:</strong></p>



<pre class="wp-block-verse">sudo mkdir /usr/local/nagios/etc/servers</pre>



<p>After setting up all these, it&#8217;s time to configure the Nagios server for monitoring the remote client machines. For this you&#8217;ll have to use the check_nrpe plugi. So, here we&#8217;ll add the command definition in order to remotely monitor our hosts. Type the below command.</p>



<p><strong>On CentOS:</strong></p>



<pre class="wp-block-verse">sudo nano /usr/local/nagios/etc/objects/commands.cfg</pre>



<p>Paste the below content into file and save it.</p>



<pre class="wp-block-verse">.check_nrpe. command definition
define command{
command_name check_nrpe
command_line /usr/lib/nagios/plugins/check_nrpe -H $HOSTADDRESS$ -t 30 -c $ARG1$
}</pre>



<p><strong>On Ubuntu:</strong></p>



<p>Create a file.</p>



<pre class="wp-block-verse">sudo nano /usr/local/nagios/etc/objects/commands.cfg</pre>



<p>Then paste the below data</p>



<pre class="wp-block-verse">.check_nrpe. command definition
define command{
command_name check_nrpe
command_line /usr/lib/nagios/plugins/check_nrpe -H $HOSTADDRESS$ -t 30 -c $ARG1$
}</pre>



<h3><strong>Step 7: Adding a Linux Host To Nagios Server</strong></h3>



<p>Now, we&#8217;ll add the remote host to monitor it by creating a client config file for defining the host &amp; services definition of remote Linux host.</p>



<p><strong>On CentOS:</strong></p>



<pre class="wp-block-verse">sudo nano /usr/local/nagios/etc/servers/client.osradar.local.cfg</pre>



<p><strong>On Ubuntu:</strong></p>



<pre class="wp-block-verse">sudo nano /usr/local/nagios/etc/servers/client.osradar.local.cfg</pre>



<p>Then paste the below configuration into the file and save it.</p>



<pre class="wp-block-verse">define host{
use linux-server host_name client.osradar.local alias client.osradar.local address 192.168.135.135
}
define hostgroup{
hostgroup_name linux-server alias Linux Servers members client.osradar.local
}
define service{
use local-service host_name client.osradar.local service_description SWAP Uasge check_command check_nrpe!check_swap
}
define service{
use local-service host_name client.osradar.local service_description Root / Partition check_command check_nrpe!check_root
}
define service{
use local-service host_name client.osradar.local service_description Current Users check_command check_nrpe!check_users
}
define service{
use local-service host_name client.osradar.local service_description Total Processes check_command check_nrpe!check_total_procs
}
define service{
use local-service host_name client.osradar.local service_description Current Load check_command check_nrpe!check_load
}</pre>



<p>After it make sure to verify the Nagios by hitting the below commands.</p>



<p><strong>On CentOS:</strong></p>



<pre class="wp-block-verse">sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg</pre>



<p><strong>On Ubuntu:</strong></p>



<pre class="wp-block-verse">/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg</pre>



<p>And then restart the services.</p>



<pre class="wp-block-verse">sudo systemctl restart nagios</pre>



<h3><strong>Step 8: Monitor Remote Hosts with Nagios .</strong></h3>



<p>Now, access the Nagios Dashboard as we&#8217;ve already installed Nagios in previous article. So, access it by typing<em><strong> IP/nagios/</strong></em> and provide credentials to login.</p>



<p>Here you can see the remote hosts.</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img loading="lazy" width="1024" height="427" src="//1723336065.rsc.cdn77.org/wp-content/uploads/2020/05/1-14-1024x427.png" alt="" class="wp-image-20444" srcset="https://www.osradar.com/wp-content/uploads/2020/05/1-14-1024x427.png 1024w, https://www.osradar.com/wp-content/uploads/2020/05/1-14-300x125.png 300w, https://www.osradar.com/wp-content/uploads/2020/05/1-14-768x320.png 768w, https://www.osradar.com/wp-content/uploads/2020/05/1-14-696x290.png 696w, https://www.osradar.com/wp-content/uploads/2020/05/1-14-1068x445.png 1068w, https://www.osradar.com/wp-content/uploads/2020/05/1-14.png 1288w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure></div>



<p>Wait for a minute and you&#8217;ll see the status of the services running on the remote machine as well as on your local machine.</p>



<figure class="wp-block-image size-large"><img loading="lazy" width="1024" height="427" src="//1723336065.rsc.cdn77.org/wp-content/uploads/2020/05/2-18-1024x427.png" alt="" class="wp-image-20445" srcset="https://www.osradar.com/wp-content/uploads/2020/05/2-18-1024x427.png 1024w, https://www.osradar.com/wp-content/uploads/2020/05/2-18-300x125.png 300w, https://www.osradar.com/wp-content/uploads/2020/05/2-18-768x320.png 768w, https://www.osradar.com/wp-content/uploads/2020/05/2-18-696x290.png 696w, https://www.osradar.com/wp-content/uploads/2020/05/2-18-1068x446.png 1068w, https://www.osradar.com/wp-content/uploads/2020/05/2-18.png 1282w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>So, this is how you can add remote Linux machines to monitor with the help of Nagios.</p>



<p></p>
<p>The post <a rel="nofollow" href="https://www.osradar.com/how-to-monitor-remote-linux-machines-with-nagios-on-linux/">How To Monitor Remote Linux Machines With Nagios on Linux</a> appeared first on <a rel="nofollow" href="https://www.osradar.com">Linux  Windows and android  Tutorials</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.osradar.com/how-to-monitor-remote-linux-machines-with-nagios-on-linux/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
