Thursday 2 October 2014

Nagios3 On The Ubuntu

Nagios:-
Nagios is one of the best open source server and network monitoring solutions available. Using the flexible nagios framework, you can monitor pretty much anything (including database and custom application). This tutorial for the how to install the nagios3 servers on the monitoring servers and how we can monitor our client through this nagios monitoring server.

Prerequisite:-
Before starting installation of the nagios3 you should confirm that mysql or postgresql database server  and apache2 server should be installed.

How to install the nagios on the ubuntu:-
 # apt-get install -y nagios3 nagios-nrpe-plugin  
 # usermod -a -G nagios www-data  
 # chmod -R g+x /var/lib/nagios3/  
 # sed -i 's/check_external_commands=0/check_external_commands=1/g' /etc/nagios3/nagios.cfg  
You will be prompted for MySQL root password.

Set Password Protection:-
open the terminal and run this command
 # htpasswd -c /etc/nagios3/htpasswd.users nagiosadmin  
restart the nagios3 server and apache2
 # service nagios3 restart && service apache2 restart  
Make sure to keep this username as "nagiosadmin" - otherwise you would have to change /etc/nagios3/cgi.cfg and redefine authorized admin.
Now you can navigate over to your droplet's Nagios panel at (http://198..168.33.201/nagios3/ for our example) You will be prompted to enter your password, put the admin password and username.

Install NRPE on clients:-
Now we should add our hosts that will be monitored by Nagios. For example, we will setup monitoring for (198.168.33.202), which runs Ubuntu as well. From public ports, we can monitor ping, any open ports such as webserver, e-mail server, etc.
For internal services that are listening on localhost, such as MySQL, memcached, system services, we will need to use NRPE.
Install NRPE on Client
# apt-get install -y nagios-plugins nagios-nrpe-server
This next step is where you get to specify any manual commands that Monitoring server can send via NRPE to these client hosts. Make sure to change allowed_hosts to your own values. Edit /etc/nagios/nrpe.cfg
 allowed_hosts=10.0.0.38,127.0.0.1,192.168.33.201  
add here nagios3 server here and don't forget restart the nrpe service
Now we can test it that your Nagios server by finding and running check_nrpe script (syntax: check_nrpe -H CLIENTIPADDR):
 # usr/lib/nagios/plugins/check_nrpe -H 192.168.33.201  
 # NRPE v2.14  
if the answer is NRPE v2.14 that means nagios server is able to connect with the client.

No comments:

Post a Comment