“No tengo miedo a los ordenadores. A lo que tengo miedo es a la falta de ellos“
Isaac Asimov acerca de Multivac
Uno de los aspectos más importantes en la labor de un SysAdmin, conforme a nuestras Tres Leyes, es monitorear nuestros sistemas de una forma automatizada, para tenerlos bajo una vigilancia constante que permita un seguimiento del desempeño de cada uno. En lo personal, siempre me he regido bajo un principio de que lo más simple y funcional es lo mejor.
Para esta labor de monitoreo, considero 2 formas de realizarlo:
- Interno
- Externo
En este post, trataremos la manera externa, y con esto me refiero a una herramienta que centralice el monitoreo del performance de mis equipos y, en caso de detectar alguna caída o incremento considerable pueda notificármelo vía correo.
He utilizado algunas herramientas y las que más me ha gustado por su simpleza y escalabilidad es xymon.
Su instalación puede ser llevada a cabo mediante paquete, ya sea .deb o .rpm, dependiendo la distribución del servidor que utilicemos. En este caso, veremos la instalación desde el código fuente.
Para ello, descargamos dicho código de la página de sourceforge:
http://sourceforge.net/projects/xymon/
En mi caso el servidor será un RHEL 6.4, y descomprimiré el código en el path de trabajo: /var/tmp/tools:
[root@isengard tools]# tar xzvf xymon-4.3.11.tar.gz
Antes de compilar, conforme a las instrucciones de instalación de xymon, se debe crear un usuario para que administre el servicio, por lo que lo creamos:
[root@isengard tools]# groupadd -g 1000 xymon [root@isengard tools]# useradd -u 1000 -g 1000 -c "xymon user" -d /opt/xymon -m xymon
En estas mismas instrucciones, nos indican que deben estar instaladas las dependencias:
- PCRE
- RRDtools
- OpenSSL
- OpenLDAP
Por lo que, también, las instalamos antes de compilar:
[root@isengard tools]# yum -y install pcre-devel pcre-static [root@isengard tools]# yum -y install rrdtool rrdtool-devel rrdtool-perl rrdtool-php rrdtool-python
Con estos paquetes instalados, podemos proceder a compilar:
[root@isengard tools]# cd xymon-4.3.11 [root@isengard xymon-4.3.11]# ./configure Configuration script for Xymon This script asks a few questions and builds a Makefile to compile Xymon Checking your make-utility Checking pre-requisites for building Xymon Checking for fping ... Xymon has a built-in ping utility (xymonping) However, it is not yet fully stable and therefore it may be best to use the external fping utility instead. I could not find fping on your system Do you want to use xymonping [Y/n] ? y OK, I will use xymonping. Checking for PCRE ... Compiling with PCRE library works OK Linking with PCRE library works OK Checking for RRDtool ... Not RRDtool 1.0.x, checking for 1.2.x Compiling with RRDtool works OK Linking with RRDtool works OK Checking for OpenSSL ... Compiling with SSL library works OK Linking with SSL library works OK Checking if your SSL library has SSLv2 enabled Will support SSLv2 when testing SSL-enabled network services Xymon can use the OpenSSL library to test SSL-enabled services like https-encrypted websites, POP3S, IMAPS, NNTPS and TELNETS. If you have the OpenSSL library installed, I recommend that you enable this. Do you want to be able to test SSL-enabled services (y) ? y Checking for LDAP ... Compiling with LDAP works OK LBER library not needed Linking with LDAP works OK Xymon can use your OpenLDAP LDAP client library to test LDAP servers. Do you want to be able to test LDAP servers (y) ? y Checking for clock_gettime() requiring librt ... clock_gettime() requires librt Checking for Large File Support ... Large File Support OK Setting up for a Xymon server What userid will be running Xymon [xymon] ? Found passwd entry for user xymon:x:1000:1000:xymon user:/opt/xymon:/bin/bash Where do you want the Xymon installation [/opt/xymon] ? OK, will configure to use /opt/xymon as the Xymon toplevel directory What URL will you use for the Xymon webpages [/xymon] ? Where to put the Xymon CGI scripts [/opt/xymon/cgi-bin] ? (Note: This is the filesystem directory - we will get to the URL shortly) What is the URL for the Xymon CGI directory [/xymon-cgi] ? (Note: This is the URL - NOT the filesystem directory) Where to put the Xymon Administration CGI scripts [/opt/xymon/cgi-secure] ? (Note: This is the filesystem directory - we will get to the URL shortly) What is the URL for the Xymon Administration CGI directory [/xymon-seccgi] ? (Note: This is the URL - NOT the filesystem directory) To generate Xymon availability reports, your webserver must have write-access to a directory below the Xymon top-level directory. I can set this up if you tell me what group-ID your webserver runs with. This is typically 'nobody' or 'apache' or 'www-data' What group-ID does your webserver use [nobody] ? Where to put the Xymon logfiles [/var/log/xymon] ? What is the name of this host [isengard.redhat.com] ? What is the IP-address of this host [127.0.0.1] ? 192.168.122.1 Where should I install the Xymon man-pages (/usr/local/man) ? Using Linux Makefile settings Created Makefile with the necessary information to build Xymon Some defaults are used, so do look at the Makefile before continuing. Configuration complete - now run make (GNU make) to build the tools [root@isengard xymon-4.3.11]#
Después de compilar, daremos make y make install, para finalizar con la compilación e instalación:
[root@isengard xymon-4.3.11]# make ... [root@isengard xymon-4.3.11]# make install
Copiamos de nuestro directorio de compilación el script de inicialización del servicio en el directorio /etc/init.d, modificamos el path donde se encuentra instalado el server (home de xymon) y lo agregamos como servicio para que levante cuando arranque el sistema:
[root@isengard xymon-4.3.11]# cp rpm/xymon-init.d /etc/init.d/xymon [root@isengard xymon-4.3.11]# chmod 500 /etc/init.d/xymon [root@isengard xymon-4.3.11]# grep opt /etc/init.d/xymon DAEMON=/opt/xymon/server/bin/xymon.sh [root@isengard xymon-4.3.11]# chkconfig --add xymon [root@isengard xymon-4.3.11]# chkconfig xymon on [root@isengard xymon-4.3.11]# chkconfig --list xymon xymon 0:off 1:off 2:on 3:on 4:on 5:on 6:off [root@isengard xymon-4.3.11]#
Configuramos apache con las definiciones de xymon y generamos la contraseña para la administración:
[root@isengard xymon-4.3.11]# ln -s /opt/xymon/server/etc/xymon-apache.conf /etc/httpd/conf.d/ [root@isengard xymon-4.3.11]# /usr/bin/htpasswd -c /opt/xymon/server/etc/xymonpasswd admin New password: Re-type new password: Adding password for user admin [root@isengard xymon-4.3.11]#
Como estamos en un servidor RHEL 6.4, debemos configurar los contextos correspondientes, para que SELinux nos permita la ejecución de los cgi’s y la publicación del monitoreo:
[root@isengard xymon]# semanage fcontext -a -f "" -t httpd_sys_content_t '/opt/xymon/server/www(/.*)?' [root@isengard xymon]# semanage fcontext -a -f "" -t httpd_sys_script_exec_t '/opt/xymon/cgi-secure(/.*)?' [root@isengard xymon]# semanage fcontext -a -f "" -t httpd_sys_script_exec_t '/opt/xymon/cgi-bin(/.*)?' [root@isengard xymon]# semanage fcontext -a -f "" -t httpd_sys_script_exec_t '/opt/xymon/server/bin/(/.*)?' [root@isengard xymon]# restorecon -RFvv /opt/xymon/server/www [root@isengard xymon]# restorecon -RFvv /opt/xymon/cgi-secure [root@isengard xymon]# restorecon -RFvv /opt/xymon/cgi-bin [root@isengard xymon]# restorecon -RFvv /opt/xymon/server/bin
Para arrancar el servicio ejecutamos:
[root@isengard xymon]# service xymon start Xymon started [root@isengard xymon]#
Para los clientes, dentro del home de xymon, existe un directorio client, que debemos transferir a los clientes en el home de xymon, que debe ser el mismo que en el server, en este caso /opt/xymon, para arrancar el servicio en el cliente se ejecuta el script dentro de este directorio:
[root@lab ~]# /opt/xymon/client/runclient.sh start Xymon client for linux started on lab.isengard.redhat.com [root@lab ~]#
En el server, los clientes los damos de alta en el archivo hosts.cfg dentro del directorio /opt/xymon/server/etc:
[root@isengard xymon]# cat server/etc/hosts.cfg page server Server group-compress <font size="+1">Server</font> 192.168.122.1 isengard.redhat.com # conn ssh TRENDS=* page lab Lab group-compress <font size="+1">Lab</font> 192.168.122.100 lab.isengard.redhat.com # conn ssh TRENDS=* 192.168.122.155 srv.isengard.redhat.com # conn ssh TRENDS=* [root@isengard xymon]#
Después de un rato ya podemos visualizar el perfomance de nuestro server:
En el siguiente post, veremos como personalizar nuestro xymon.
Espero les sirva.
[…] con el post anterior de monitoreo, una vez que tenemos instalado correctamente el server, debemos configurar y personalizar los […]