<?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>SupportSages &#187; NRPE</title>
	<atom:link href="http://www.supportsages.com/blog/tag/nrpe/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.supportsages.com/blog</link>
	<description>Technical Support and Server Management : Musings in the fox hole.</description>
	<lastBuildDate>Thu, 05 Jan 2012 03:05:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>Monitoring with Nagios and NRPE</title>
		<link>http://www.supportsages.com/blog/2009/05/monitoring-with-nagios-and-nrpe/</link>
		<comments>http://www.supportsages.com/blog/2009/05/monitoring-with-nagios-and-nrpe/#comments</comments>
		<pubDate>Fri, 01 May 2009 20:47:50 +0000</pubDate>
		<dc:creator>Sam</dc:creator>
				<category><![CDATA[Howtos]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Nagios]]></category>
		<category><![CDATA[NRPE]]></category>

		<guid isPermaLink="false">http://www.supportsages.com/blog/?p=131</guid>
		<description><![CDATA[<strong>Nagios</strong>

Nagios is a versatile and functional network management tool with a GUI (graphicuser interface) comparable to other commercial tools. It is a system and network monitoring application. It watches hosts and services that you specify, alerting you when things go bad and when they get better. Nagios was originally designed to run under Linux, but now it also runs well on other Unix variants.

<strong>Nagios Installation Guides</strong>:

This blog is intended to provide you with simple instructions on how to install Nagios from source (code) in Fedora.

<strong>Prerequisites</strong>:

Before installing Nagios,you need to install the following packages:
Apache
GCC compiler
GD development libraries

You can use yum to ...]]></description>
			<content:encoded><![CDATA[<p><strong>Nagios</strong></p>
<p>Nagios is a versatile and functional network management tool with a GUI (graphicuser interface) comparable to other commercial tools. It is a system and network monitoring application. It watches hosts and services that you specify, alerting you when things go bad and when they get better. Nagios was originally designed to run under Linux, but now it also runs well on other Unix variants.</p>
<p><strong>Nagios Installation Guides</strong>:</p>
<p>This blog is intended to provide you with simple instructions on how to install Nagios from source (code) in Fedora.</p>
<p><strong>Prerequisites</strong>:</p>
<p>Before installing Nagios,you need to install the following packages:<br />
Apache<br />
GCC compiler<br />
GD development libraries</p>
<p>You can use yum to install these packages by running the following commands (as root):</p>
<blockquote><p>yum install  httpd<br />
yum install  gcc<br />
yum install  glibc glibc-common<br />
yum install  gd gd-devel</p></blockquote>
<p>1) <em>Create Account Information</em></p>
<p>Create a new nagios user account.</p>
<blockquote><p>/usr/sbin/useradd -m nagios</p></blockquote>
<p>Create a new nagcmd group for allowing external commands to be submitted through the web interface. Add both the nagios user and the apache user to the group.</p>
<blockquote><p>/usr/sbin/groupadd nagcmd<br />
/usr/sbin/usermod -a -G nagcmd nagios<br />
/usr/sbin/usermod -a -G nagcmd apache</p></blockquote>
<p>2) <em>Download Nagios</em>:</p>
<p>Create a directory for storing the downloads.</p>
<blockquote><p>mkdir ~/ssages<br />
cd ~/ssages<br />
wget http://osdn.dl.sourceforge.net/sourceforge/nagios/nagios-3.0.6.tar.gz</p></blockquote>
<p>3) <em>Compile and Install Nagios</em></p>
<p>Extract the Nagios source code tarball.</p>
<blockquote><p>tar xzf nagios-3.0.6.tar.gz<em><br />
</em>cd nagios-3.0.6<br />
./configure &#8211;with-command-group=nagcmd<br />
make install<br />
make install-init<br />
make install-config<br />
make install-commandmode<br />
nagios-3.0.6</p></blockquote>
<p>4) <em>Configure the Web Interface<br />
</em><br />
Install the Nagios web config file in the Apache conf.d directory.</p>
<blockquote><p>make install-webconf</p></blockquote>
<p>Create a nagiosadmin account for logging into the Nagios web interface.</p>
<blockquote><p>htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin</p></blockquote>
<p>Edit the file<em> /usr/local/apache/conf/includes/pre_virtualhost_global.conf</em> and append the following lines to the virtual host directories.</p>
<blockquote><p>AuthName &#8220;Nagios&#8221;<br />
AuthType Basic<br />
AuthUserFile /usr/local/nagios/etc/htpasswd.users<br />
Require valid-user</p></blockquote>
<p>Restart Apache to make the new settings take effect.</p>
<blockquote><p>service httpd restart</p></blockquote>
<p>5)<strong> </strong><em>Compile and Install the Nagios Plugins</em></p>
<blockquote><p>wget http://osdn.dl.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.11.tar.gz</p>
<p>cd ~/ssages</p>
<p>tar xzf nagios-plugins-1.4.11.tar.gz<br />
cd nagios-plugins-1.4.11</p></blockquote>
<p>Compile and install the plugins.</p>
<blockquote><p>./configure &#8211;with-nagios-user=nagios &#8211;with-nagios-group=nagios<br />
make<br />
make install<em><br />
</em></p></blockquote>
<p>6) Start Nagios</p>
<p>Add Nagios to the list of system services and have it automatically start when the system boots.<br />
<em></em></p>
<blockquote><p>chkconfig &#8211;add nagios<br />
chkconfig nagios on</p></blockquote>
<p>Verify the sample Nagios configuration files.</p>
<blockquote><p>/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg</p></blockquote>
<p>If there are no errors, start Nagios.</p>
<blockquote><p>service nagios start</p></blockquote>
<p>you can check the Nagios in your browser typing the following url:</p>
<blockquote><p><em>http://localhost/nagios</em></p></blockquote>
<p>You should now be able to access the Nagios web interface at the URL below. You&#8217;ll be prompted for the username (nagiosadmin) and password you specified earlier.</p>
<p><em><strong>NRPE Installation and Configuration</strong></em></p>
<p>The NRPE addon is designed to allow you to execute Nagios plugins on remote Linux/Unix machines. The main reason for doing this is to allow Nagios to monitor &#8220;local&#8221; resources (like CPU load, memory usage, etc.) on remote machines. Since these public resources are not usually exposed to external machines, an agent like NRPE must be installed on the remote Linux/Unix machines.</p>
<p><em>The NRPE addon consists of two pieces</em>:</p>
<p>The check_nrpe plugin, which resides on the local monitoring machine.<br />
The NRPE daemon, which runs on the remote Linux/Unix machine.</p>
<p><em>When Nagios needs to monitor a resource of service from a remote Linux/Unix machine</em>:<br />
Nagios will execute the check_nrpe plugin and tell it what service needs to bechecked.<br />
The check_nrpe plugin contacts the NRPE daemon on the remote host over an (optionally) SSL-protected connection.<br />
The NRPE daemon runs the appropriate Nagios plugin to check the service or resource.<br />
The results from the service check are passed from the NRPE daemon back to thecheck_nrpe plugin, which then returns the check results to the Nagios process.</p>
<p><strong>INSTALLATION</strong></p>
<p><em>Remote Host Setup</em>:</p>
<p>Create a new nagios user account.</p>
<blockquote><p>/usr/sbin/useradd nagios</p></blockquote>
<p>Create a directory for storing the downloads.</p>
<blockquote><p>mkdir ~/ssages<br />
cd ~/ssages</p>
<p>wget http://osdn.dl.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.11.tar.gz</p></blockquote>
<p>Extract the Nagios plugins source code tarball.</p>
<blockquote><p>tar xzf nagios-plugins-1.4.11.tar.gz<br />
cd nagios-plugins-1.4.11</p></blockquote>
<p>Compile and install the plugins.</p>
<blockquote><p>./configure<br />
make<br />
make install</p></blockquote>
<p>The permissions on the plugin directory and the plugins will need to be fixed at this point, for this run the following commands.</p>
<blockquote><p>chown nagios.nagios /usr/local/nagios<br />
chown -R nagios.nagios /usr/local/nagios/libexec</p></blockquote>
<p><strong>I</strong><em><strong>nstall the NRPE daemon</strong></em>:</p>
<blockquote><p>cd ~/ssages<br />
wget http://osdn.dl.sourceforge.net/sourceforge/nagios/nrpe-2.8.tar.gz</p>
<p>tar xzf nrpe-2.8.tar.gz<br />
cd nrpe-2.8<br />
Compile the NRPE addon.<br />
./configure<br />
make all</p></blockquote>
<p><em>Install the NRPE plugin (for testing), daemon, and sample daemon config file</em>.</p>
<blockquote><p>make install-plugin</p>
<p>make install-daemon</p>
<p>make install-daemon-config</p></blockquote>
<p>Add the following entry for the NRPE daemon to the /etc/services file.</p>
<blockquote><p>nrpe            5666/tcp# NRPE</p></blockquote>
<p>Next we add an init script for nrpe. For this,</p>
<blockquote><p>cd nrp-2.12/<br />
cp ./src/nrpe /usr/sbin/<br />
cp ./sample-config/nrpe.cfg /etc /<br />
cat init-script.in &gt; /etc/init.d/nrpe<br />
mod a+x /etc/init.d/nrpe<br />
open  the /etc/init.d/nrpe and edit<br />
NrpeBin=/usr/sbin/nrpe<br />
NrpeCfg=/usr/local/nagios/etc/nrpe.conf</p></blockquote>
<p>Then restart nrpe services</p>
<blockquote><p>/etc/init.d/nrpe restart</p></blockquote>
<p>Then edit the nrpe configuration file and allow the monitoring hoast ipaddress.</p>
<blockquote><p>allowed_hosts=ipaddress of monitoring host</p></blockquote>
<p>Next to open nrpe port in the firewall.</p>
<blockquote><p>vi  /etc/apf/conf.apf</p></blockquote>
<p>edit the follwing section and add the port number 5666</p>
<blockquote><p>IG_tcp_cports=&#8221;5666,20&#8230;&#8230;&#8230;..etc&#8221;</p></blockquote>
<p>Restart the services</p>
<blockquote><p>/etc/init.d/apf restart</p></blockquote>
<p>Make sure the nrpe daemon is running under xinetd.</p>
<blockquote><p>netstat -at | grep nrpe</p></blockquote>
<p>The output out this command should show something like this:</p>
<blockquote><p>tcp         0           0 *:nrpe    *:*          LISTEN</p></blockquote>
<p><em>Monitoring Host Setup</em></p>
<p>For monitoring remote host, you need to install nrpe plugin to the monitoring host. For this,</p>
<blockquote><p>cd ~/ssages<br />
wget http://osdn.dl.sourceforge.net/sourceforge/nagios/nrpe-2.8.tar.gz</p>
<p>tar xzf nrpe-2.8.tar.gz<br />
cd nrpe-2.8/</p></blockquote>
<p><em>Compile the NRPE addon.</em></p>
<blockquote><p>./configure<br />
make all</p></blockquote>
<p>Install the NRPE plugin.</p>
<blockquote><p>make install-plugin</p></blockquote>
<p>Create a command definition</p>
<blockquote><p>vi /usr/local/nagios/etc/commands.cfg</p></blockquote>
<p>and add the following definition to the file:</p>
<blockquote><p>define command{<br />
command_name         check_nrpe<br />
command_line         $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$<br />
}</p></blockquote>
<p>You can insert each remote system services in one file. For that you have to edit the configuration file</p>
<blockquote><p>vi /usr/local/nagios/etc/nagios.cfg</p></blockquote>
<p>and append the following line.</p>
<blockquote><p>cfg_file=/usr/local/nagios/etc/objects/remotehost.cfg</p></blockquote>
<p><em>Create host and service definitions</em></p>
<p>First create a new template for each different type of host you&#8217;ll be monitoring. Let&#8217;s create a new template for linux boxes.<br />
edit <em>/usr/local/nagios/etc/objects/templates.cfg</em> and add the following lines,</p>
<blockquote><p>define host{<br />
name                  linux-box             ; Name of this template<br />
use                   generic-host          ; Inherit default values<br />
check_period          24&#215;7<br />
check_interval        5<br />
retry_interval        1<br />
max_check_attempts    10<br />
check_command         check-host-alive<br />
notification_period   24&#215;7<br />
notification_interval 30<br />
notification_options  d,r<br />
contact_groups        admins<br />
register              0 ; DONT REGISTER THIS &#8211; ITS A TEMPLATE<br />
}</p></blockquote>
<p>Notice that the linux-box template definition is inheriting default values from the generic-host template, which is defined in the localhost.cfg file.</p>
<p>Next, define a new host for the remote Linux/Unix box that references the newly created linux-box host template.<br />
For this edit<em> /usr/local/nagios/etc/objects/remotehost.cfg</em></p>
<blockquote><p>define host{<br />
use       linux-box  ; Inherit default values from a template<br />
host_name remotehost  ; The name we&#8217;re giving to this server<br />
address   192.168.0.1  ; IP address of the server<br />
check_command check-host-alive<br />
}</p></blockquote>
<p>Then define contact name and contact goup name in same file</p>
<blockquote><p>define contact{<br />
contact_name clientcontact<br />
host_name remote_host<br />
use generic-contact<br />
alias Nagios client<br />
email remotehost@gmail.com<br />
}<br />
define contactgroup{<br />
contactgroup_name groupname<br />
host_name remote_host<br />
alias Nagios group<br />
members clientcontact,membersof remote_host<br />
}</p></blockquote>
<p>Now define some services to monitor the remote Linux/Unix box. These service definitions will use the commands that have been defined in the nrpe.cfg file in the remote host.</p>
<p>The following service will monitor the CPU load in the remote host. The &#8220;check_load&#8221; argument that is passed to the check_nrpe command definition tells the NRPE daemon to run the &#8220;check_load&#8221; command as defined in the nrpe.cfg file.</p>
<blockquote><p>define service{<br />
use                 generic-service<br />
host_name           remotehost<br />
service_description CPU Load<br />
check_command       check_nrpe!check_load<br />
}</p></blockquote>
<p>The following service will monitor the the number of currently logged-in users in the remote host.</p>
<blockquote><p>define service{<br />
use                         generic-service<br />
host_name                   remotehost<br />
service_description         Current Users<br />
check_command               check_nrpe!check_users<br />
}</p></blockquote>
<p>The following service will monitor the free drive space on /dev/hda1 in the remote host.</p>
<blockquote><p>define service{<br />
use                         generic-service<br />
host_name                   remotehost<br />
service_description         /dev/hda1 Free Space<br />
check_command               check_nrpe!check_hda1<br />
}</p></blockquote>
<p>The following service will monitor the total number of processes in the remote host.</p>
<blockquote><p>define service{<br />
use                        generic-service<br />
host_name                  remotehost<br />
service_description        Total Processes<br />
check_command              check_nrpe!check_total_procs<br />
}</p></blockquote>
<blockquote><p>The following service will monitor the number of zombie processes in the remote host.</p>
<p>define service{<br />
use                        generic-service<br />
host_name                  remotehost<br />
service_description        Zombie Processes<br />
check_command              check_nrpe!check_zombie_procs<br />
}</p></blockquote>
<p>The following service will monitor http status in the remote host.</p>
<blockquote><p>define service{<br />
use generic-service<br />
host_name remote_host<br />
service_description HyperVM<br />
check_command check_nrpe!check_http<br />
}</p></blockquote>
<p><em>Restarting Nagios</em>:</p>
<p>Verify your Nagios configuration files.</p>
<blockquote><p>/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg</p></blockquote>
<p>If there are errors, fix them. If everything is fine, restart Nagios.</p>
<blockquote><p>service nagios restart</p></blockquote>
<p><em>Remote Host Configuration</em>:</p>
<p>Edit the nrpe configuration file and add the folowing lines:</p>
<blockquote><p>vi /usr/local/nagios/etc/nrpe.cfg<br />
command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10<br />
command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20<br />
command[check_hda1]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/hda1<br />
command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Z<br />
command[check_http]=/usr/local/nagios/libexec/check_http -H 127.0.0.1 -w 5 -c 10</p></blockquote>
<p><em>Restart the nrpe: </em></p>
<blockquote><p>/etc/init.d/nrpe restart</p></blockquote>
<div class="tweetthis" style="text-align:left;"><p> <a  class="tt" href="http://twitter.com/home/?status=Monitoring+with+Nagios+and+NRPE+http%3A%2F%2Fwww.supportsages.com%2Fblog%2F131" title="Post to Twitter"><img class="nothumb" src="http://www.supportsages.com/blog/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter3.png" alt="Post to Twitter" /></a> <a  class="tt" href="http://twitter.com/home/?status=Monitoring+with+Nagios+and+NRPE+http%3A%2F%2Fwww.supportsages.com%2Fblog%2F131" title="Post to Twitter">Tweet This Post</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.supportsages.com/blog/2009/05/monitoring-with-nagios-and-nrpe/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

