Vous êtes sur la page 1sur 5

NAGIOS MONITORING

----------------On Master server


1. Go to Nagios working directory
$ cd /usr/local/etc/nagios
2. Copy Nagios sample files
To do this, make sure you are in Nagios working directory from the first
step
There are Nagios's sample files in the directory, which we need to copy
them
as working copies. The easiest is to become temporarily root, and rename
the files:
$ sudo -s
You can then copy the commands below:
cp
cp
cp
cp
cp
cp
cp
cp

cgi.cfg-sample cgi.cfg
nagios.cfg-sample nagios.cfg
resource.cfg-sample resource.cfg
objects/commands.cfg-sample objects/commands.cfg
objects/contacts.cfg-sample objects/contacts.cfg
objects/localhost.cfg-sample objects/localhost.cfg
objects/templates.cfg-sample objects/templates.cfg
objects/timeperiods.cfg-sample objects/timeperiods.cfg
# exit
$

3. Create monitoring configuration files for DNS Servers


While are you still in Nagios working directory, create a new file for
DNS servers monitoring
Change the following below:
xx:
your group number
yy:
group number of your slave server
MYTLD:
your zone name
$ sudo vi objects/dns-servers.cfg
- - - - - - - - - - - - - - - - - cut below - - - - - - - - - - - - - - ### Define the host server
define host{
use
host_name
alias
address
}
define host{
use

freebsd-server
master
master
10.10.xx.1

freebsd-server

host_name
alias
address

cache
cache
10.10.xx.2

}
define host{
use
host_name
alias
address
}

freebsd-server
slave
slave
10.10.yy.1

### Define the group


define hostgroup{
hostgroup_name
alias
members
}

dns-servers
DNS Servers
cache,master,slave

### Define Services


define service {
use
template to use
hostgroup_name
service_description
check_command
}
define service {
use
template to use
hostgroup_name
service_description
check_command
}

generic-service

; Name of service

dns-servers
PING
check_ping!100.0,20%!500.0,60%

generic-service

; Name of service

dns-servers
Check DNS
check_dns!www.MYTLD

- - - - - - - - - - - - - - - - - cut end - - - - - - - - - - - - - - 4. Add check_dns service


By default, Nagios doesn't configure check_dns service, we need to add
line below into commands.cfg
$ sudo vi objects/commands.cfg
- Place this below the check_nt service check definition:
- - - - - - - - - - - - - - - - - cut below - - - - - - - - - - - - - - define command{
command_name
command_line
}

check_dns
$USER1$/check_dns -s $HOSTADDRESS$ -H $ARG1$

- - - - - - - - - - - - - - - - - cut end - - - - - - - - - - - - - - 5. Enable DNS monitoring group in Nagios configuration files

Now you have DNS Server monitoring files (dns-server.cfg) created. We


need to enable on nagios.cfg file for monitoring
$ sudo vi /usr/local/etc/nagios/nagios.cfg
Look for the line "cfg_file=/usr/local/etc/nagios/objects/localhost.cfg"
and add below content
- - - - - - - - - - - - - - - - - cut below - - - - - - - - - - - - - - # Definition for DNS servers
cfg_file=/usr/local/etc/nagios/objects/dns-servers.cfg
- - - - - - - - - - - - - - - - - cut end - - - - - - - - - - - - - - -

6. Enable Nagios service


To enable nagios service add the line below in /etc/rc.conf
nagios_enable="YES"

7. Start Nagios service


To start nagios service
$ sudo service nagios start
Nagios should be running right now without any error report.

8. Create Apache password authentication file for Nagios


Nagios required authentication via http to gain admin access to it web
interface.
Let's create the password file
$ sudo -s
# htpasswd -c /usr/local/etc/apache22/nagios.auth nagiosadmin
# exit
$
Set your desire password (perhaps, use the class password)
Password file is now created
9. Create Nagios' Apache configuration for web interface access
Go to Apache Includes directory
$ cd /usr/local/etc/apache22/Includes
If there already is a nagios.conf file in the directory, we wil
remove and rebuild it. Our new configuration is significantly different.
To do this do:
$ sudo rm nagios.conf

Then edit the file:


$ sudo vi nagios.conf
Add the lines below into the file:
- - - - - - - - - - - - - - - - - cut below - - - - - - - - - - - - - - AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
ScriptAlias /nagios/cgi-bin/ /usr/local/www/nagios/cgi-bin/
Alias /nagios/ /usr/local/www/nagios/
<Directory "/usr/local/www/nagios/cgi-bin">
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthType Basic
Require valid-user
AuthUserFile /usr/local/etc/apache22/nagios.auth
</Directory>
<Directory "/usr/local/www/nagios">
AllowOverride None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthType Basic
Require valid-user
AuthUserFile /usr/local/etc/apache22/nagios.auth
</Directory>
- - - - - - - - - - - - - - - - - cut end - - - - - - - - - - - - - - 10. Now, edit the main apache config.
$ sudo vi /usr/local/etc/apache22/httpd.conf
Find the line:
DirectoryIndex index.html
And change it to:
DirectoryIndex index.html index.php

11. Enable and start Apache web service if required, by adding this
to /etc/rc.conf
$ sudo vi /etc/rc.conf
apache22_enable="YES"
(Save file and exit)

$ sudo service apache22 restart


12.

Access to Nagios web page via http://10.10.xxx.1/nagios/


You will need to user "nagiosadmin" as the user and the password you
specified previously using the "htpasswd" command.
Take a looking around the Nagios interface to see what is being
reported.

Vous aimerez peut-être aussi