nagios configuration
DESCRIPTION
This document is for nagios setup on server side and client side.TRANSCRIPT
Nagios Quick Installation Guide
yum install httpd php
yum install gcc glibc glibc-common
yum install gd gd-devel
1) Create Account Information
/usr/sbin/useradd -m nagios
passwd nagios
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.
/usr/sbin/groupadd nagcmd
/usr/sbin/usermod -a -G nagcmd nagios
/usr/sbin/usermod -a -G nagcmd apache
2) Download Nagios and the Plugins
http://www.nagios.org/download/
3) Compile and Install Nagios
Extract the Nagios source code tarball.
cd ~/downloads
tar xzf nagios-3.2.3.tar.gz
cd nagios-3.2.3
Run the Nagios configure script, passing the name of the group you created earlier like so:
./configure --with-command-group=nagcmd
Compile the Nagios source code.
make all
Install binaries, init script, sample config files and set permissions on the external command directory.
make install
make install-init
make install-config
make install-commandmode
Don't start Nagios yet - there's still more that needs to be done...
4) Customize Configuration
Sample configuration files have now been installed in the /usr/local/nagios/etc directory. These sample files should work fine for getting started with Nagios. You'll need to make just one change before you proceed...
Edit the /usr/local/nagios/etc/objects/contacts.cfg config file with your favorite editor and change the email address associated with the nagiosadmin contact definition to the address you'd like to use for receiving alerts.
vi /usr/local/nagios/etc/objects/contacts.cfg
5) Configure the Web Interface
Install the Nagios web config file in the Apache conf.d directory.
make install-webconf
Create a nagiosadmin account for logging into the Nagios web interface. Remember the password you assign to this account - you'll need it later.
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Restart Apache to make the new settings take effect.
service httpd restart
6) Compile and Install the Nagios Plugins
Extract the Nagios plugins source code tarball.
cd ~/downloads
tar xzf nagios-plugins-1.4.11.tar.gz
cd nagios-plugins-1.4.11
Compile and install the plugins.
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install
7) Start Nagios
Add Nagios to the list of system services and have it automatically start when the system boots.
chkconfig --add nagios
chkconfig nagios on
Verify the sample Nagios configuration files.
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
If there are no errors, start Nagios.
service nagios start
9) Login to the Web Interface
You should now be able to access the Nagios web interface at the URL below. You'll be prompted for the username (nagiosadmin) and password you specified earlier.
http://localhost/nagios/
Monitoring Linux/Unix Machines
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 "local" 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.
Remote Host Setup
1) /usr/sbin/useradd nagios
passwd nagios
2) Download the source code tarball of the Nagios plugins (visit http://www.nagios.org/download/
3) Extract the Nagios plugins source code tarball.tar xzf nagios-plugins-1.4.6.tar.gzcd nagios-plugins-1.4.6
4) Compile and install the plugins../configuremakemake install
5) Change permissionschown nagios.nagios /usr/local/nagioschown -R nagios.nagios /usr/local/nagios/libexec
6) Install xinetdyum install xinetd
7) Install the NRPE daemonDownload the source code tarball of the NRPE addon (visit http://www.nagios.org/download/
8) Extract the NRPE source code tarball.tar xzf nrpe-2.8.tar.gzcd nrpe-2.89) Compile the NRPE addon../configuremake allInstall the NRPE plugin (for testing), daemon, and sample daemon config file.make install-pluginmake install-daemonmake install-daemon-configInstall the NRPE daemon as a service under xinetd.make install-xinetd
10) Edit the /etc/xinetd.d/nrpe file and add the IP address of the monitoring server to the only_from directive.only_from = 127.0.0.1 <nagios_ip_address>
11) Add the following entry for the NRPE daemon to the /etc/services file.nrpe 5666/tcp # NRPE
12) Restart the xinetd service.service xinetd restart
13) Test the NRPE daemon locally
netstat -at | grep nrpeThe output out this command should show something like this:tcp 0 0 *:nrpe *:* LISTEN
14) Next, check to make sure the NRPE daemon is functioning properly/usr/local/nagios/libexec/check_nrpe -H localhost
You should get a string back that tells you what version of NRPE is installed, like this:NRPE v2.8
Monitoring Host Setup15) Install the check_nrpe plugin
Download the source code tarball of the NRPE addon (visit http://www.nagios.org/download/
16) tar xzf nrpe-2.8.tar.gz
cd nrpe-2.8
Compile the NRPE addon../configuremake allInstall the NRPE plugin.make install-plugin
17) Test communication with the NRPE daemon
Make sure the check_nrpe plugin can talk to the NRPE daemon on the remote host.
/usr/local/nagios/libexec/check_nrpe -H RemoteHostIP
You should get a string back that tells you what version of NRPE is installed on the remote host, like this:NRPE v2.8
18) Create a command definition
You'll need to create a command definition in one of your Nagios object configuration files in order to use thecheck_nrpe plugin
vi /usr/local/nagios/etc/commands.cfg
and add the following definition to the file:
define command{command_name check_nrpecommand_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$}
19) Create host and service definitions
You'll need to create some object definitions in order to monitor the remote Linux/Unix machine. These definitionscan be placed in their own file or added to an already exiting object configuration file.
define host{use linux-box ; Inherit default values from a templatehost_name remotehost ; The name we're giving to this serveralias Fedora Core 6 ; A longer name for the serveraddress remoteIP ; IP address of the server}
define service{use generic-servicehost_name remotehostservice_description CPU Loadcheck_command check_nrpe!check_load}
define service{use generic-servicehost_name remotehostservice_description Current Userscheck_command check_nrpe!check_users}
define service{use generic-servicehost_name remotehostservice_description /dev/hda1 Free Spacecheck_command check_nrpe!check_hda1}
21) Add host and service definitions to nagios.cfg
cfg_file=/usr/local/nagios/etc/objects/remotehost.cfg
20) Verify your Nagios configuration files./usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
21) If there are errors, fix them. If everything is fine, restart Nagios.service nagios restart