Translate

miércoles, 14 de marzo de 2012

How-to install Nagios


Vamos a ver hoy un pequeño tutorial de cómo realizar una instalación de Nagios. Nagios es un software del tipo Open Source que nos permite monitorizar sistemas informáticos, incluyendo dentro de este tanto equipos informáticos, servidores, equipos de red, aplicaciones, servicios, etc... Hoy en día está considerado como el estándar en la  monitorización de infraestructuras informáticas, aunque últimamente Zabbix le está suponiendo cierta competencia.

Al ser Open Source es por lo tanto un software libre, aunque tiene versiones de pago que incluyen mayores funcionalidades.  Nagios se instala sobre Linux. En nuestro ejemplo lo haremos sobre Ubuntu, y mas concretamente sobre la versión 11.10

Today we are going to see a breef how-to install Nagios. Nagios is an Open-Source Software used to monitoring a Computer System. It´s include user computers, servers, switches, routers, applications, services, and so on. Actually it is considered as an industry standart for IT Infrastructure Monitoring.

It is free software, but there are a few comercialized versions which includes enhance capabilities. In our example we are going to install it over a Ubuntu 11.10.

Una vez instalado nuestro Ubuntu, y antes de instalar Nagios necesitamos instalar Apache y PHP. Para ello haremos lo siguiente:
Once we have instaled Ubuntu and before installing Nagios we are going to install Apache and PHP.

1º Instalamos Apache / Installing Apache

sudo apt-get install build-essential

sudo apt-get install libgd2-xpm-dev

sudo apt-get install apache2

2º Instalamos PHP para apache2 / Installing PHP for Apache2

sudo apt-get install php5-common php5 libapache2-mod-php5

Configuramos apache abriendo el fichero de configuración:
Now we are going to configure Apache to use PHP editing the apache config file:

sudo gedit /etc/apache2/apache2.conf

y añadimos la siguiente línea / and add the following line:

DirectoryIndex index.html index.php index.cgi

Reiniciamos apache / Restart Apache

sudo  /etc/init.d/apache2   restart


Podemos probar que Apache funciona conectando a la ip del equipo a través de un navegador. Debería aparecer una pantalla como esta:
We could made a try if Apache Works using a web interface heading to the IP of the Nagios´host. We must obtain the following screen:




Una vez instalados y configurados Apache2 y PHP comenzamos a instalar Nagios. Previamente habremos descargado la última versión de core nagios desde la web de Nagios, http://www.nagios.org/download , así como del Nagios plugin que también habremos descargado del mismo sitio.
Once we have instaled and configured Apache2 and PHP we could start to install Nagios. Previously we must download the last versión of Core Nagios from de Nagios Website, http://www.nagios.org/download . Also we must download the Nagios Plugin from the same site.



Una vez descargados los ficheros los descomprimimos y los ubicamos en el directorio home de nuestro sistema de ficheros, pero previamente crearemos un usuario para correr el servicio y un grupo para ejecutar comandos externos:
Once we have downloaded both files we must decompress and place it in the home folder of the  system files. Previously we are going to create a user to run the service and a group to run external commands:


sudo useradd -m nagios
sudo passwd nagios
sudo groupadd nagcmd
sudo usermod -a -G nagcmd nagios
sudo usermod -a -G nagcmd www-data

Ahora vamos a realizar la instalación de Nagios a partir de los ficheros que descaramos anteriormente.
Now we are going to install the Nagios tarballs downloaded previously.

Vamos al directorio en el que extraimos el fichero tar.
Then we move to the folder in we extract the file and install

sudo ./configure --with-command-group=nagcmd

Compilamos el programa principal y las CGIs / This would compile the main program and the CGIs:

sudo make all

Instalamos el programa principal y la CGIs / Install of the main program and CGIs

sudo make install

Instalamos los scripts de inicio en /etc/init.d / Install init scripts in /etc/init.d

sudo make install-init

Instalamos ficheros de ejemplo de configuración en /usr/local/nagios/etc  / Install sample files in /usr/local/nagios/etc

sudo make install-config

Configuramos los permisos de usuarios / Configuring file and directories permissions

sudo make install-commandmode

Instalamos los ficheros de configuración de Apache para la interface web de Nagios / Install the Apache config file for the Nagios web interface

sudo make install-webconf

Creamos la contraseña para el ususario administrator / Let´s create the password for the admin user:

sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

Ahora añadiremos en la configuración de apache el directorio de Nagios, para ello abrimos el fichero apache.conf:
Now we ar going to add the Nagios directory to apache, opening the apache.conf file :

sudo gedit /etc/apache2/apache.conf


y añadimos las siguientes líneas / and add following lines :

ScriptAlias /nagios/cgi-bin /usr/local/nagios/sbin
Alias /nagios /usr/local/nagios/share

Por ultimo grabamos, cerramos el fichero y reiniciamos apache2
Finaly we save and exit, and then restart apache2

sudo  /etc/init.d/apache2 restart

Ahora vamos a proceder a instalar el Segundo fichero que descargamos de la web de Nagios, el Nagios Plugin.
Now we have to install the second file we download from the Nagios site, the Nagios plugins.

Vamos a la carpeta donde hemos extraido el fichero.
Now we move to the folder in wich we have extracted the plugins.

 sudo ./configure --with-nagios-user=nagios --with-nagios-group=nagios
sudo make
sudo make install

Creamos un enlace para iniciar el servicio / Now we are going to create a link to start the service:

sudo ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios 

Verificamos la configuración / Verify the config:

sudo /usr/local/nagios/bin/nagios –v /usr/local/nagios/etc/nagios.cfg

Iniciamos Nagios / And now start Nagios:

sudo /etc/init.d/nagios start

Ahora podemos acceder a Nagios poniendo en el navegador la dirección:
Now you are ready to use Nagios, open your browser and type :

http://hostname/nagios or http://ip/nagios 



El usuario que se nos pide al logearnos será nagiosadmin y la contraseña la que fijásemos en su momento.
The user to log on to the system would be nagiosadmin, with the password we set during the installation process.

Aquí podemos ver un imagen de Nagios monitorizando dos equipos windows, el próximos posts explicaremos como añadir hosts windows y linux.
Here we can see a Nagios monitoring two windows hosts, y further post we could see how to add new linux and windows host to our Nagios.


No hay comentarios: