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: # 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 Change the following below: xx: your group number yy: group number of your slave server MYTLD: your zone name # Edit objects/dns-servers.cfg - - - - - - - - - - - - - - - - - cut below - - - - - - - - - - - - - - - ### Define the host server define host{ use freebsd-server host_name master alias master address 10.10.xx.1 } define host{ use freebsd-server host_name cache alias cache address 10.10.xx.2 } define host{ use freebsd-server host_name slave alias slave address 10.10.YY.1 } ### Define the group define hostgroup{ hostgroup_name dns-servers alias DNS Servers members cache,master,slave } ### Define Services define service { use generic-service ; Name of service template to use hostgroup_name dns-servers service_description PING check_command check_ping!100.0,20%!500.0,60% } define service { use generic-service ; Name of service template to use hostgroup_name dns-servers service_description Check DNS check_command 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 # Edit objects/commands.cfg - Place this below the check_nt service check definition: - - - - - - - - - - - - - - - - - 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 (perhaps, use the class password) Password file is now created #. Create Nagios' Apache configuration for web interface access Go to Apache Include directory # cd /usr/local/etc/apache22/Include There is already a nagios.conf file. We need to update this. The simplest method is to remove and rebuild the file as our new configuration is significantly different. To do this do: # rm nagios.conf Then edit the file: # Edit Includes/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/ 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 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.