Changes

Jump to: navigation, search

How to Setup and configure Nagios

4,647 bytes added, 07:49, 24 November 2010
no edit summary
Congratulations! You sucessfully installed Nagios. Your journey into monitoring is just beginning. You have just completed the basic configuration of the Nagios Server. You'll no doubt want to monitor more than just your local machine, so keep reading and you will find how to configure the client machine with some modifications on Nagios server.
If you did everything as per specifications, the following page will be displayed upon initial access of the Nagios Server GUI:
 
 
 
 
== 3.0 Additional Server configuration ==
 
'''3.1 Downlad and Install NRPE Plugin for Nagios Server'''
 
1. Create a Nagios_NRPE folder.
 
 
<code>mkdir -p ~/Nagios/Nagios_NRPE</code>
 
<code>cd ~/Nagios/Nagios_NRPE</code>
 
2. Save file to directory ~/Nagios
 
http://www.nagios.org/download/download.php
 
3. Extract the Files:
 
<code>tar -xzf nrpe-2.12.tar.gz</code>
 
<code>cd nrpe-2.12</code>
 
'''3.2 Compile and Configure NRPE'''
 
<pre>Note: you have to be root to issue make install command.</pre>
 
<code>./configure</code>
 
<code>make all</code>
 
<code>make install-plugin</code>
 
'''3.3 Test Connection to NRPE daemon on Remote Server'''
 
Make sure that the NRPE on your Nagios server can talk to the NRPE daemon on the remote server we want to monitor. Replace “<IP of Remote Server>” with the remote servers IP address.
 
<code>/usr/local/nagios/libexec/check_nrpe -H 142.204.133.90 NRPE v2.12</code>
 
'''3.4 Create NRPE Command Definition'''
 
<pre>
Note: The command.cfg file does not exist in /usr/local/nagios/etc/ directory so it has to be created, and the script block has to be added to the aformentioned file.
</pre>
 
1. A command definition needs to be created in order for the check_nrpe plugin to be used by nagios.
 
<code>vi /usr/local/nagios/etc/objects/commands.cfg</code>
 
2. Add the following at the end of the file:
 
<pre>define command{
 
command_name check_nrpe
 
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
 
}
</pre>
 
'''3.5 Create host and service definitions'''
 
You'll need to create some object definitions in order to monitor the remote Linux/Unix machine. These definitions can be placed in their own file or added to an already exiting object configuration file.
 
First, create a new template for each different type of host you'll be monitoring. Let's create a new template for Linux boxes.
 
1. Create new linux-box-remote object template file:
 
<code>vi /usr/local/nagios/etc/objects/linux-box-remote.cfg</code>
 
 
<pre>Note: Information below is just an example of the template file.</pre>
 
<pre>
define host{
name linux-box-remote ; Name of this template
use generic-host ; Inherit default values
check_period 24x7
check_interval 5
retry_interval 1
max_check_attempts 10
check_command check-host-alive
notification_period 24x7
notification_interval 30
notification_options d,r
contact_groups admins
register 0 ; DONT REGISTER THIS - ITS A TEMPLATE
}
 
define host{
use linux-box-remote ; Inherit default values from a template
host_name Centos5 ; The name we're giving to this server
alias Centos5 ; A longer name for the server
address 142.204.133.90 ; IP address of the server
}
 
define service{
use generic-service
host_name Centos5
service_description CPU Load
check_command check_nrpe!check_load
}
define service{
use generic-service
host_name Centos5
service_description Current Users
check_command check_nrpe!check_users
}
define service{
use generic-service
host_name Centos5
service_description /dev/hda1 Free Space
check_command check_nrpe!check_hda1
}
define service{
use generic-service
host_name Centos5
service_description Total Processes
check_command check_nrpe!check_total_procs
}
define service{
use generic-service
host_name Centos5
service_description Zombie Processes
check_command check_nrpe!check_zombie_procs
}
</pre>
 
2. Activate the linux-box-remote.cfg template:
 
<code>vi /usr/local/nagios/etc/nagios.cfg</code>
 
And add the following lines:
 
<code># Definitions for monitoring remote Linux machine </code>
 
<code>cfg_file=/usr/local/nagios/etc/objects/linux-box-remote.cfg </code>
 
3. Verify Nagios Configuration Files:
 
If there are errors, fix them. If everything is fine, restart Nagios.
 
<code>/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg </code>
 
You have to have no warnings or errors:
 
<pre>
Total Warnings: 0
 
Total Errors: 0
</pre>
 
4. Restart Nagios:
 
<code>service nagios restart</code>
1
edit

Navigation menu