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 copy.
# cp cgi.cfg-sample cgi.cfg
# cp nagios.cfg-sample nagios.cfg
# cp resource.cfg-sample resource.cfg
# cp objects/commands.cfg-sample objects/commands.cfg
# cp objects/contacts.cfg-sample objects/contacts.cfg
# cp objects/localhost.cfg-sample objects/localhost.cfg
# cp objects/templates.cfg-sample objects/templates.cfg
# cp objects/timeperiods.cfg-sample objects/timeperiods.cfg
3. Create monitoring configuration files for DNS Servers
While are you still in Nagios working directory, create a new file for DNS servers monitoring
** Remember to change xxx to your group
# Edit objects/dns-servers.cfg
- - - - - - - - - - - - - - - - - cut below - - - - - - - - - - - - - - -
### Define the host server
define host{
use freebsd-server
host_name cache
alias cache
address 10.10.xxx.2
}
define host{
use freebsd-server
host_name auth
alias auth
address 10.10.xxx.3
}
### Define the group
define hostgroup{
hostgroup_name dns-servers
alias DNS Servers
members cache, auth
}
### Define Services
define service {
use generic-service ; Name of service template to use
host_name cache
service_description PING
check_command check_ping!100.0,20%!500.0,60%
}
define service {
use generic-service ; Name of service template to use
host_name auth
service_description PING
check_command check_ping!100.0,20%!500.0,60%
}
define service {
use generic-service ; Name of service template to use
host_name auth
service_description Check DNS
check_command check_dns!noc.ws.nsrc.org
}
define service {
use generic-service ; Name of service template to use
host_name cache
service_description Check DNS
check_command check_dns!noc.ws.nsrc.org
}
- - - - - - - - - - - - - - - - - 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
# Edit objects/commands.cfg
- - - - - - - - - - - - - - - - - cut below - - - - - - - - - - - - - - -
define command{
command_name check_dns
command_line $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
# Edit /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
# /usr/local/etc/rc.d/nagios start
Nagios should be running right now without any error report.
#. 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
# htpasswd -c /usr/local/etc/apache22/nagios.auth nagiosadmin
Set your desire password
Password file is now created
#. Create Nagios' Apache configuration for web interface access
Go to Apache directory
# cd /usr/local/etc/apache22
Create a new file
# Edit Includes/nagios.conf
Add the line below info 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/
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
AllowOverride None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthType Basic
Require valid-user
AuthUserFile /usr/local/etc/apache22/nagios.auth
- - - - - - - - - - - - - - - - - cut end - - - - - - - - - - - - - - -
# In /usr/local/etc/apache22/httpd.conf, find the line:
DirectoryIndex index.html
And change it to:
DirectoryIndex index.html index.php
# Enable and start Apache web service
Add into /etc/rc.conf
apache22_enable="YES"
# /usr/local/etc/rc.d/apache22 start
Access to Nagios web page via http://10.10.xxx.1/nagios/index.php