Nagios Installation and Configuration>Part-1

gpontutorials.com-Nagios Installation and Configuration

Important Notes:
—————————————————————————————————————————-
 Commands preceded with “$” imply that you should execute the command as a general user – not as root.
  Commands preceded with “#” imply that you should be working as root.
  Commands with more specific command lines (e.g. “RTR-GW>” or “mysql>”) imply that you are executing         commands on remote equipment, or within another program.

—————————————————————————————————————————-

Part-1 Start:

Log in to your virtual machine as the sysadm user.

1. Install Nagios Version 3
——————————-

Become the root user:

$ sudo bash
# apt-get install nagios3 nagios3-doc

During installation you will be prompted for the “Nagios web administration password:” – This will be for the Nagios user “nagiosadmin”. When prompted enter in the password you are using your sysadm account.

Note: if you have not already done so, you may be asked to configure the Postfix Mail Transport Agent during the Nagios installation process. Just accept the default “Internet Site”.

2. See Initial Nagios Configuration
—————————————–
Open a browser, and open nagios login page.
At the login prompt, login as:
User Name: nagiosadmin
Password: <standard PASSWORD>
Click on the “Hosts” link on the left of the initial Nagios page to see what has already been configured.

3. Update the File hostgroups_nagios2.cfg
————————————————-
# cd /etc/nagios3/conf.d
# editor hostgroups_nagios2.cfg

COPY and PASTE it.

define hostgroup {
hostgroup_name ping-servers
alias Pingable servers
members rtrX
}

Where “rtrX” is the router for your group. That is, if you are in group 1, then replace “rtrX” with “rtr1”. Now save and exit the from the file.

4. Add Routers, PCs and Switches
—————————————-
We will create three files, routers.cfg, switches.cfg and pcs.cfg and make entries for the hardware in our classroom.

5a. Creating the switches.cfg file
————————————–
# cd /etc/nagios3/conf.d
(just to be sure)
# editor switches.cfg
In this file add the following entry (COPY and PASTE!):
define host {
use generic-host
host_name sw
alias Backbone Switch
address 10.10.0.253
}
Save the file and exit.

5b. Creating the routers.cfg file
————————————
If you have up to 10 total routers. These are rtr1-rtr9 and gw-rtr. And, we have 1 or 2 wireless Access Points (ap1, ap2). We will define entries for each of these. If any of these devices do not exist in your workshop, then do not include
them. Remember, COPY and PASTE!

# editor routers.cfg
define host {
use generic-host
host_name gw-rtr
alias Classrooom Gateway Router
address 10.10.0.254
}
define host {
use generic-host
host_name rtr1
alias Group 1 Gateway Router
address 10.10.1.254
}
define host {
use generic-host
host_name rtr2
alias Group 2 Gateway Router
address 10.10.2.254
}
define host {
use generic-host
host_name rtr3
alias Group 3 Gateway Router
address 10.10.3.254
}
define host {
use generic-host
host_name rtr4
alias Group 4 Gateway Router
address 10.10.4.254
}
define host {
use generic-host
host_name rtr5
alias Group 5 Gateway Router
address 10.10.5.254
}
define host {
use generic-host
host_name rtr6
alias Group 6 Gateway Router
address 10.10.6.254
}
define host {
use generic-host
host_name rtr7
alias Group 7 Gateway Router
address 10.10.7.254
}
define host {
use generic-host
host_name rtr8
alias Group 8 Gateway Router
address 10.10.8.254
}
define host {
use generic-host
host_name rtr9
alias Group 9 Gateway Router
address 10.10.9.254
}
define host {
use generic-host
host_name ap1
alias Wireless Access Point 1
address 10.10.0.251
}
define host {
use generic-host
host_name ap2
alias Wireless Access Point 2
address 10.10.0.252
}
Now save and exit from the file.

5c. Creating the pcs.cfg File
——————————–

Now we will create entries for all the Virtual Machines in our classroom. Below we give you the first few entries. You should complete the file with as many PCs as you wish to add. We recommend that, at least, you add the 4 PCs
that are members of your group as well as an entry for the classroom NOC, and at least one PC from another group (remember to COPY and PASTE!):

# editor pcs.cfg
define host {
use generic-host
host_name noc
alias Workshop NOC machine
address 10.10.0.250
}
——————-
# Group 1
——————-
define host {
use generic-host
host_name pc1
alias pc1
address 10.10.1.1
}
define host {
use generic-host
host_name pc2
alias pc2
address 10.10.1.2
}
define host {
use generic-host
host_name pc3
alias pc3
address 10.10.1.3
}
define host {
use generic-host
host_name pc4
alias pc4
address 10.10.1.4
}
———————————-
Another PC (example only!)
———————————-
define host {
use generic-host
host_name pc20
alias pc20
address 10.10.5.20
}
You can save and exit from the file now, or you can continue to add more PC entries. If you have not added PCs for your group be sure to do that before you exit from the file.

STEPS 6a – 6c SHOULD BE REPEATED WHENEVER YOU UPDATE THE CONFIGURATION!
=================================================================
6a. Verify that your configuration files are OK
—————————————————–
# nagios3 -v /etc/nagios3/nagios.cfg
You should get some warnings like :
Checking services…
Checked 7 services.
Checking hosts…
Warning: Host ‘gw-rtr’ has no services associated with it!
Warning: Host ‘rtr1’ has no services associated with it!
Warning: Host ‘rtr2’ has no services associated with it!
etc….
Total Warnings: N
Total Errors: 0
Things look okay – No serious problems were detected during the check. Nagios is saying that it’s unusual to monitor a device just for its existence on the network, without also monitoring some service.

6b. Reload/Restart Nagios
——————————-
# service nagios3 restart
HINT: You will be doing this a lot. If you do it all on one line, like this, then you can hit cursor-up and rerun all in one go:
# nagios3 -v /etc/nagios3/nagios.cfg && /etc/init.d/nagios3
restart
The ‘&&’ ensures that the restart only happens if the config is valid.

6c. Verify via the Web Interface
————————————-
Go to the web interface (http://pcN.ws.xyz.org/nagios3) and check that the hosts you just added are now visible in the interface. Click on the “Hosts” item on the left of the Nagios screen to see this. You may see it in “PENDING” status until the check is carried out.

7. View Status Map
———————-
Go to http://pcN.ws.xyz.org/nagios3
Click on the “Map” item on the left. You should see all your hosts with the Nagios process in the middle. The “?” are because we have not told Nagios what type of host each items is (router, switch, AP, PC running Linux, etc…)

****END of Part-1 Configuration*****

 

Be the first to comment

Leave a Reply

Your email address will not be published.


*


For security, use of Google's reCAPTCHA service is required which is subject to the Google Privacy Policy and Terms of Use.

I agree to these terms.