Changes

Jump to: navigation, search

How to Setup and configure Nagios

10,951 bytes added, 08:39, 8 December 2010
no edit summary
<code>service nagios restart</code>
 
 
== 4.0 Server Installation (using yum utility)==
 
Make sure you've installed the following packages on your Fedora 13 installation before continuing.
 
<pre>Note: you have to be root to install the following packages.</pre>
 
1. Install the following packages using yum install utility.
 
<code>yum -y install httpd gcc glib glibc-common gd gd-devel </code>
 
<code>yum -y install nagios </code>
 
<code>yum -y install nagios-plugin-all </code>
 
<code>yum -y install nrpe </code>
 
'''4.2 Create Account Information'''
 
1. While you still have root privilages from a previous step, create a new nagios user account and give it a password.
 
<code>useradd -m nagios </code>
 
<code>passwd senecaCdot </code>
 
2. 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.
 
groupadd nagcmd
 
<code>usermod -a -G nagcmd nagios </code>
 
<code>usermod -a -G nagcmd apache </code>
 
 
'''4.3 Configure the Web Interface'''
 
1. Create a nagiosadmin account for logging into the Nagios web interface.
 
<code>htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin </code>
 
 
Type the password: (your password is here)
 
<pre>Note: When you have installed all the required plugins, using the “yum” utility, you will have to exhibit due diligence by ensuring that the “ check_nrpe” plugin and check_nagios plugin is located in the /usr/lib64/nagios/plugins directory. If the check_nrpe plugin is not present you will have either copy it from a compatible machine that holds it on the its system, or try uninstalling the previous installation of the nagios plugins and proceed to re-installing the plugins again, using yum install. </pre>
 
Here is view of what your configuration files should like, in order to have successfully installed and configured version of Nagios. The following lines were either added or modified for the nagios.cfg file on the monitoring host.
 
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Need add the info !!!!!!!!!!!!!!!!!!!!!!
 
'''4.4 Nagios Configuration File'''
 
1. Open nagios.cfg and edit it with your favourite editor.
 
<code>vi /etc/nagios/nagios.cfg</code>
 
<pre>
#Definitions for monitoring the local (Linux) host
 
<code>cfg_file=/etc/nagios/objects/localhost.cfg</code>
 
#Definitions for monitoring a Remote (Linux) machine
 
<code>cfg_file=/etc/nagios/objects/linux-remote.cfg</code>
 
#Definitions for monitoring second Remote (Linux) machine
 
<code>cfg_file=/etc/nagios/objects/linux-romania.cfg</code>
 
2. Open nrpe.cfg and edit it with your favourite editor.
 
<code>vi /etc/nagios/nrpe.cfg</code>
<pre>
Note: In the nrpe.cfg the following lines can be modified to meet the current system needs
</pre>
<code>#Allowed_hosts=127.0.0.1</code> is typically altered on the Remote host ONLY changes in IP address that allows a host to access the nrpe daemon system depends on an entities/organizations network requirements.
 
<pre>
Note: The following examples use hardcoded command arguments
</pre>
 
<code>command[check_users]=/usr/lib64/nagios/plugins/check_users -w 5 -c 10</code>
 
<code>command[check_load]=/usr/lib64/nagios/plugins/check_load -w 15,10,5 -c 30,25,20</code>
 
<code>command[check_hda1]=/usr/lib64/nagios/plugins/check_disk -w 20% -c 10% -p /dev/$</code>
 
<code>command[check_zombie_procs]=/usr/lib64/nagios/plugins/check_procs -w 5 -c 10 -s$</code>
 
<code>command[check_total_procs]=/usr/lib64/nagios/plugins/check_procs -w 700 -c 900</code>
 
<pre>Note: If you're running the NRPE daemon as a standalone daemon you'll need to restart it. If you're running it under the inetd/xinetd superserver you don't need to do anything more.</pre>
 
'''4.5 Create a command definition'''
 
<pre>Note: You'll need to create a command definition in one of your Nagios object configuration files in order to use the check_nrpe plugin. Open the sample commands.cfg file for editing...</pre>
 
<code>vi /usr/local/nagios/etc/commands.cfg</code>
 
and add the following definition to the file:
 
 
<code>define command{</code>
 
<code> command_name check_nrpe</code>
 
<code> command_line /usr/lib64/nagios/plugins/check_nrpe -H $HOSTADDRESS$ -c $ARG1$</code>
 
<code>}</code>
 
You are now ready to start adding services that should be monitored on the remote machine to the Nagios configuration...
 
'''4.6 Edit localhost.cfg file'''
 
<pre>Note: The localhost .cfg file can be created from one of the templates.cfg files located in the /etc/nagios/objects directory, here is a brief view of how your localhost.cfg file should appear</pre>
 
<pre>
# Define a host for the local machine
 
define host{
 
use linux-server ; Name of host template$
 
; This host definition $
 
; in (or inherited by) $
 
host_name localhost
 
alias chile #Example machine in this scenario
 
check_interval 5
 
retry_interval 1
 
max_check_attempts 10
 
check_command check-host-alive
 
notification_period 24x7
 
notification_interval 24x7
 
notification_options d,r
 
contact_groups admins
 
address 127.0.0.1
 
}
</pre>
 
'''4.7 Contacts Configuration File'''
 
1. Edit contacts.cfg file is pretty straight forward and easy to decipher.
 
<code>vi /usr/local/nagios/etc/objects/contacts.cfg</code>
 
<pre>
#CONTACTS################################################################
 
# Just one contact defined by default - the Nagios admin (that's you)
 
# This contact definition inherits a lot of default values from the 'generic-contact'
 
# template which is defined elsewhere.
 
define contact{
 
contact_name nagiosadmin ; Short name of user
 
use generic-contact ; Inherit default values from generic-contact template(defined above)
 
alias Nagios Admin ; Full name of user
 
email email@learn.senecac.on.ca ; ß CHANGE THIS TO YOUR EMAIL ADDRESS ******
 
}
 
</pre>
 
'''4.8 ScriptAlias NAGIOS.CFG'''
 
<pre>Note: ScriptAlias directory path will differ based on what version of OS (Operating System) you are running on your machine.</pre>
 
1. Edit nagios.cfg file.
 
<code>vi /etc/httpd/conf.d/nagios.cfg </code>
 
<pre>Note: The current machine has Fedora 13, however, for a machine running Fedora 12 it may differ eg. ScriptAlias /nagios/cgi-bin “/usr/lib64/nagios/cgi-bin/”
 
It's important that these directory paths exist and contain the appropriate content.
</pre>
<code>ScriptAlias /nagios/cgi-bin/ "/usr/local/sbin/"</code>
 
<code><Directory "/usr/local/sbin"></code>
 
<code># SSLRequireSSL</code>
 
<code> Options ExecCGI Indexes</code>
 
<code> AllowOverride None</code>
 
<code> Order allow,deny</code>
 
<code> Allow from all</code>
 
<code># Order deny,allow</code>
 
<code># Deny from all</code>
 
<code># Allow from 127.0.0.1</code>
 
<code> AuthName "Nagios Access"</code>
 
<code> AuthType Basic</code>
 
<code> AuthUserFile /etc/nagios/htpasswd.users</code>
 
<code> Require valid-user</code>
 
<code></Directory></code>
 
<code>Alias /nagios "/usr/share/nagios/html"</code>
 
<code><Directory "/usr/share/nagios/html"></code>
 
<code># SSLRequireSSL</code>
 
<code> Options Indexes</code>
 
<code> AllowOverride None</code>
 
<code> Order allow,deny</code>
 
<code> Allow from all</code>
 
<code># Order deny,allow</code>
 
<code># Deny from all</code>
 
<code># Allow from 127.0.0.1</code>
 
<code> AuthName "Nagios Access"</code>
 
<code> AuthType Basic</code>
 
<code> AuthUserFile /etc/nagios/htpasswd.users</code>
 
<code> Require valid-user</code>
 
<code></Directory></code>
 
'''4.9 Installation On Arm 4-1'''
 
<pre>Note: nrpe daemon/ nrpe addon & required plugins</pre>
 
The nrpe.d directory is located in /etc/nagios/nrpe.d
 
The nagios plugins are located in directory path /usr/lib/nagios/plugins
 
1. Ensure that the required plugins are located in current directory paths.
 
Open nrpe.cfg and edit it with your favourite editor.
 
<code>vi /etc/nagios/nrpe.cfg</code>
 
<code>allowed_hosts=<IP Address to that of the monitoring hosts></code>
 
comment out the line:
 
<code>#allowed_hosts=127.0.0.1</code>
 
2. Change ownership on the plugins directory to reflect ownership to nagios.
 
<code>chown nagios.nagios /usr/lib64/nagios/plugins</code>
 
 
Normal 0 false false false EN-US X-NONE X-NONE 5.0 Setting up the Remote Host (using yum utility)
 
 
Note: This part will show how to setup the remote hosst with the nrpe daemon/nrpe addon & required plugins.
 
 
1. To install the nrpe daemon and nagios plugins run the following commands.
 
yum –y install nrpe
 
yum -y install Nagios-plugins-all
 
 
2. Open nrpe.cfg and edit it with your favourite editor.
 
 
vi /etc/nagios/nrpe.cfg
 
 
Add an allowed_hosts IP Address to nrpe.cfg file eg. 142.204.133.123 (chile’s IP Address):
 
 
Allowed_hosts=142.204.133.123
 
 
3. Test the nrpe daemon locally using the command:
 
 
netstat -at | grep nrpe
 
 
Note: The output of the command should look something like this:
 
 
tcp 0 0 *:nrpe *:* LISTEN
 
 
4. Add a firewall rule to the INPUT chain
 
 
iptables -I INPUT -p tcp -m tcp --dport 5666 –j ACCEPT
 
 
5. Save the firewall settings so it survives reboot
 
 
service iptables save
 
 
Note: Files locations after install:
 
/etc/nagios -> contains the nrpe.cfg
 
/etc/nrpe.d -> contains the daemon
 
/usr/lib64/nagios/plugins -> contains all plugins added during install
 
/usr/sbin/nrpe -> contains the nrpe execution file
 
/usr/share/docs/nrpe-2.12 -> contains the related README, Changelog files and .pdf etc
 
 
6. Check to make sure the NRPE daemon is functioning properly. To accomplish this, run the check_nrpe plugin that was installed for testing purposes. The directory make be different depending OS.
 
 
/usr/local/nagios/libexec/check_nrpe -H localhost <ip of the Remote host>
 
 
Or
 
 
/usr/lib64/naigos/plugins/check_nrpe -H localhost <ip of the Remote host>
 
 
7. Some of these commands can be executed on the Remote host for testing daemon functionality
 
 
/usr/local/nagios/libexec/check_nrpe -H localhost -c check_users
 
/usr/local/nagios/libexec/check_nrpe -H localhost -c check_load
 
/usr/local/nagios/libexec/check_nrpe -H localhost -c check_hda1
 
/usr/local/nagios/libexec/check_nrpe -H localhost -c check_total_procs
 
/usr/local/nagios/libexec/check_nrpe -H localhost -c check_zombie_procs
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
== 4.0 IRC Notification Bot Configuration (Server configuration) ==
1
edit

Navigation menu