informatica:linux:zabbix
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
informatica:linux:zabbix [2015/03/13 14:42] – [Compilar fuentes] javi | informatica:linux:zabbix [2015/03/31 13:36] (current) – removed jose | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ======= zabbix ======= | ||
- | monitor snmp graphs | ||
- | |||
- | ====== Instalacion ====== | ||
- | ===== Por repositorio ===== | ||
- | Fuente: https:// | ||
- | Nos descargamos el paquete de configuración: | ||
- | http:// | ||
- | Y lo instalamos: | ||
- | dpkg -i zabbix-release_2.0-1squeeze_all.deb | ||
- | |||
- | |||
- | Esto crea la siguiente entrada en los repositorios: | ||
- | / | ||
- | |||
- | deb http:// | ||
- | deb-src http:// | ||
- | |||
- | |||
- | |||
- | |||
- | ===== Resumen de maquinas: ===== | ||
- | |||
- | |||
- | ^ Hostname ^ Comentarios ^ | ||
- | | monitor-1.dev.jj.com | Servidor Zabbix | | ||
- | | mysql-1.dev.jj.com | Servidor de bases de datos | | ||
- | | www-1.dev.jj.com | Frontend web para el servidor zabbix | | ||
- | |||
- | **NOTA** ahora mismo el paquete ' | ||
- | |||
- | ===== Servidor Zabbix ===== | ||
- | |||
- | ==== Version 2.0.2 repositorio no oficial ==== | ||
- | |||
- | 1. (monitor-1.dev.jj.com) Anyadir al sources list el repositorio de http:// | ||
- | |||
- | sudo su | ||
- | echo "deb http:// | ||
- | |||
- | 2. Anyadir sus claves. A mi no me funciono, me sigue dando un warning: | ||
- | |||
- | wget -q -O - http:// | ||
- | |||
- | 3. Actualizar e instalar el paquete (probablemente dara un warning): | ||
- | |||
- | sudo aptitude update; sudo aptitude install zabbix-server-mysql | ||
- | |||
- | Indicar que se quiere instalar la base de datos en local, y asignarle un usuario y una contrasenya. Luego haremos unos cambios para apuntar a ' | ||
- | |||
- | Quiza haya que reconfigurar el paquete: | ||
- | |||
- | sudo dpkg-reconfigure zabbix-server-mysql | ||
- | |||
- | 4. Para el servidor zabbix: | ||
- | |||
- | sudo / | ||
- | |||
- | 5. Hacer un volcado de la base de datos (el nombre se especifica en el paso 3, asumo que es ' | ||
- | |||
- | sudo mysqldump --add-drop-table -e zabbix > / | ||
- | |||
- | Le anyadimos que use la base de datos zabbix: | ||
- | |||
- | sudo vim / | ||
- | | ||
- | Teclear al inicio: | ||
- | |||
- | use zabbix; | ||
- | |||
- | 6. Copiar el volcado a la base de datos (mysql-1.dev.jj.com en el ejemplo): | ||
- | |||
- | scp / | ||
- | |||
- | 7. Desinstalar mysql server y dependencias: | ||
- | |||
- | sudo aptitude remove mysql-server libhtml-template-perl mysql-server mysql-server-5.1 mysql-server-core-5.1 | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | ==== Compilar fuentes ==== | ||
- | |||
- | http:// | ||
- | |||
- | 1. Descargar | ||
- | |||
- | http:// | ||
- | |||
- | 2. Descomprimir | ||
- | |||
- | tar xvfz zabbix-2.0.2.tar.gz | ||
- | |||
- | 3. (Opcional) Instalar dependencias | ||
- | |||
- | sudo aptitude update; sudo aptitude install build-essential libmysqlclient-dev libcurl4-openssl-dev libsnmp-dev snmp-mibs-downloader | ||
- | |||
- | 4. Crear usuario y grupo: | ||
- | |||
- | sudo groupadd zabbix; sudo useradd -g zabbix zabbix | ||
- | |||
- | 5. Configurar | ||
- | |||
- | cd / | ||
- | ./configure --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl | ||
- | |||
- | 6. Instalar | ||
- | |||
- | sudo make install | ||
- | |||
- | 7. Crear el script de arranque: | ||
- | |||
- | sudo ln -s / | ||
- | | ||
- | 8. Editar el archivo de configuracion (importante ajustar entre otros los valores de la conexion a la BD): | ||
- | |||
- | sudo vim / | ||
- | |||
- | 9. Arrancar | ||
- | |||
- | sudo / | ||
- | |||
- | ===== Servidor de Bases de Datos ===== | ||
- | |||
- | https:// | ||
- | |||
- | 1. (mysql-1.dev.jj.com) Instalar mysql server: | ||
- | |||
- | sudo aptitude update; sudo aptitude install mysql-server | ||
- | |||
- | 2. Crear la base de datos: | ||
- | |||
- | mysql -u root -p | ||
- | create database zabbix; | ||
- | |||
- | 3. Crear el usuario ' | ||
- | |||
- | grant usage on *.* to ' | ||
- | grant all on zabbix.* to ' | ||
- | flush privileges; | ||
- | |||
- | 4. Permito conectividad desde todas las maquinas (se puede hacer mas restrictivo si se quiere): | ||
- | |||
- | sudo cp / | ||
- | sudo vim / | ||
- | |||
- | Y anyado/ | ||
- | |||
- | bind-address | ||
- | |||
- | 5. Ingesta inicial del volcado de la base de datos del servidor Zabbix: | ||
- | |||
- | mysql -u root -p < / | ||
- | |||
- | 5.1 Si lo hemos instalado de la versión oficial, ejecutamos el volcado de los ficheros de: | ||
- | / | ||
- | En el siguiente orden: | ||
- | mysql zabbix -u zabbix -p < schema.sql | ||
- | mysql zabbix -u zabbix -p < images.sql | ||
- | mysql zabbix -u zabbix -p < data.sql | ||
- | |||
- | 6. Reinicio la base de datos: | ||
- | |||
- | sudo / | ||
- | |||
- | 7. (monitor-1.dev.jj.com) Ajusto la configuracion del servidor Zabbix para que apunte a la basae de datos: | ||
- | |||
- | sudo cp / | ||
- | sudo vim / | ||
- | |||
- | Y anyado/ | ||
- | |||
- | < | ||
- | DBHost=mysql-1.dev.jj.com | ||
- | DBName=zabbix | ||
- | DBUser=zabbix | ||
- | DBPassword=contrasenya | ||
- | </ | ||
- | |||
- | 8. Reinicio el servidor Zabbix y le echo un vistazo a los logs a ver si todo va bien: | ||
- | |||
- | sudo / | ||
- | sudo tail -F / | ||
- | |||
- | |||
- | |||
- | ===== Frontend web ===== | ||
- | |||
- | |||
- | ==== Compilando fuentes ==== | ||
- | |||
- | 1. Repetir los pasos 1. y 2. del Servidor Zabbix (Compilar fuentes) | ||
- | |||
- | 2. Crear un enlace simbólico del Document Root de Apache (asumimos '/ | ||
- | |||
- | cd /srv/www; sudo ln -s cd / | ||
- | sudo chown -R www-data: | ||
- | |||
- | 3. Ajustar la configuración de la Base de Datos: | ||
- | |||
- | cd / | ||
- | sudo vim zabbix.conf.php | ||
- | |||
- | Con el siguiente contenido: | ||
- | |||
- | < | ||
- | $DB[" | ||
- | $DB[" | ||
- | $DB[" | ||
- | $DB[" | ||
- | $ZBX_SERVER | ||
- | </ | ||
- | |||
- | 4. Deberiamos poder acceder (usuario ' | ||
- | |||
- | http:// | ||
- | |||
- | ==== Paquete ==== | ||
- | |||
- | |||
- | 1. Repetir los pasos 1. y 2. del Servidor Zabbix | ||
- | |||
- | 2. Actualizar e instalar el paquete (probablemente dara un warning): | ||
- | |||
- | sudo aptitude update; sudo aptitude install zabbix-frontend-php | ||
- | |||
- | 3. Editar el archivo de configuracion para indicar servidor Zabbix y de bases de datos: | ||
- | |||
- | sudo cp / | ||
- | sudo vim / | ||
- | |||
- | Anyadir/ | ||
- | |||
- | < | ||
- | $DB[" | ||
- | $DB[" | ||
- | $DB[" | ||
- | $DB[" | ||
- | $ZBX_SERVER | ||
- | </ | ||
- | |||
- | 4. Deberiamos poder acceder (usuario ' | ||
- | |||
- | http:// | ||
- | |||
- | |||
- | ===== Cliente ===== | ||
- | |||
- | Es similar a un agente SNMP. Para instalar | ||
- | |||
- | 1. Repetir los pasos 1. y 2. del Servidor Zabbix | ||
- | |||
- | 2. Actualizar e instalar el paquete (probablemente dara un warning): | ||
- | |||
- | sudo aptitude update; sudo aptitude install zabbix-agent | ||
- | |||
- | 3. Para arrancar/ | ||
- | |||
- | / | ||
- | |||
- | |||
- | ===== Proxy ===== | ||
- | |||
- | Esta receta es para Ubuntu server. | ||
- | |||
- | Resumen de maquinas: | ||
- | |||
- | | zabbix.dominio.com | Servidor donde esta instalado Zabbix | | ||
- | | proxy.dominio.com | Servidor donde esta instalado Zabbix proxy | | ||
- | | maquina.dominio.com | Maquina que server.dominio.com monitoriza a traves de proxy.dominio.com | | ||
- | |||
- | 1. Instalar | ||
- | |||
- | sudo aptitude install zabbix-proxy-mysql | ||
- | |||
- | Te pregunta usuario y contrasenya de MySQL etc... | ||
- | |||
- | 2. Editar config: | ||
- | |||
- | sudo vim / | ||
- | |||
- | Yo ajuste los siguientes valores: | ||
- | |||
- | | Server | zabbix.dominio.com | | ||
- | | Hostname | proxy.dominio.com | | ||
- | |||
- | **IMPORTANTE** Por defecto esta configurado en **modo activo**, es decir, proxy.dominio.com se conecta de vez en cuando a zabbix.dominio.com y le pregunta si hay alguna peticion que hacer. | ||
- | En caso de que la haya, proxy.dominio.com las hara y devolvera el resultado, a traves del puerto TCP 10051, a zabbix.dominio.com | ||
- | |||
- | 3. Arrancar (si no lo estuviera ya): | ||
- | |||
- | sudo / | ||
- | sudo tail -F / | ||
- | |||
- | ===== Monitorizar una maquina a traves de zabbix proxy ===== | ||
- | |||
- | Resumen de maquinas: | ||
- | |||
- | | zabbix.dominio.com | Servidor donde esta instalado Zabbix | | ||
- | | proxy.dominio.com | Servidor donde esta instalado Zabbix proxy | | ||
- | | maquina.dominio.com | Maquina que server.dominio.com monitoriza a traves de proxy.dominio.com | | ||
- | |||
- | 1. (Opcional) Permitir conexiones entre zabbix.dominio.com y proxy.dominio.com a traves del puerto TCP 10051. Ejemplo: | ||
- | |||
- | $IPTABLES -A INPUT -d $KVM_LAN_IP -s proxy.dominio.com -i $EXT_IF -p tcp --dport 10051 -j ACCEPT | ||
- | |||
- | |||
- | |||
- | |||
- | ====== Base de datos en profundidad ====== | ||
- | |||
- | ===== Copia de seguridad ===== | ||
- | |||
- | http:// | ||
- | |||
- | < | ||
- | #!/bin/bash | ||
- | # | ||
- | # lh_zabbix_backup.sh | ||
- | # v1.0 – 20130710 | ||
- | # | ||
- | # Configuration Backup for Zabbix 2 w/MySQL | ||
- | # | ||
- | # Original Author: Ricardo Santos (rsantos at gmail.com) http:// | ||
- | # | ||
- | #Modified by Suyash Jain ( me at suyashjain.com) http:// | ||
- | |||
- | #The purpose of this script is to take the backup of zabbix server database. | ||
- | #The concept behind writing this script is that #zabbix database grows up on day to day bases | ||
- | #and it become very tedious to take the backup with mysqldump or other #available tools , | ||
- | #< | ||
- | # | ||
- | |||
- | #Zabbix History/ | ||
- | #So we will not backup their data , only the #zabbix configrations. | ||
- | #The script is based on zabbix 2.x database schema , or older schema you must check the table | ||
- | #names and change them accordingly. | ||
- | |||
- | # mysql config | ||
- | DBHOST=" | ||
- | DBNAME=" | ||
- | DBUSER=" | ||
- | DBPASS=" | ||
- | |||
- | # some tools | ||
- | MYSQLDUMP=" | ||
- | GZIP=" | ||
- | DATEBIN=" | ||
- | MKDIRBIN=" | ||
- | |||
- | # target path | ||
- | MAINDIR="/ | ||
- | DUMPFILE=" | ||
- | ${MKDIRBIN} -p ${MAINDIR} | ||
- | |||
- | # configuration tables | ||
- | CONFTABLES=( actions applications autoreg_host conditions config dchecks dhosts drules dservices escalations expressions \ | ||
- | functions globalmacro globalvars graph_discovery graph_theme graphs graphs_items groups help_items \ | ||
- | host_inventory hostmacro hosts hosts_groups hosts_templates housekeeper httpstep httpstepitem \ | ||
- | httptest httptestitem icon_map icon_mapping ids images interface item_discovery items items_applications \ | ||
- | maintenances maintenances_groups maintenances_hosts maintenances_windows mappings media media_type \ | ||
- | node_cksum nodes opcommand opcommand_grp opcommand_hst opconditions operations opgroup opmessage \ | ||
- | opmessage_grp opmessage_usr optemplate profiles proxy_autoreg_host proxy_dhistory proxy_history \ | ||
- | regexps rights screens screens_items scripts service_alarms services services_links services_times \ | ||
- | sessions slides slideshows sysmap_element_url sysmap_url sysmaps sysmaps_elements sysmaps_link_triggers \ | ||
- | sysmaps_links timeperiods trigger_depends trigger_discovery triggers user_history users users_groups usrgrp valuemaps ) | ||
- | |||
- | # tables with large data | ||
- | DATATABLES=( acknowledges alerts auditlog_details auditlog events \ | ||
- | history history_log history_str history_str_sync history_sync history_text \ | ||
- | history_uint history_uint_sync trends trends_uint ) | ||
- | |||
- | # CONFTABLES | ||
- | for table in ${CONFTABLES[*]}; | ||
- | echo " | ||
- | ${MYSQLDUMP} -R –opt –extended-insert=FALSE \ | ||
- | -h ${DBHOST} -u ${DBUSER} -p${DBPASS} ${DBNAME} –tables ${table} >> | ||
- | done | ||
- | |||
- | # DATATABLES | ||
- | for table in ${DATATABLES[*]}; | ||
- | echo " | ||
- | ${MYSQLDUMP} -R –opt –no-data \ | ||
- | -h ${DBHOST} -u ${DBUSER} -p${DBPASS} ${DBNAME} –tables ${table} >> | ||
- | done | ||
- | |||
- | echo | ||
- | echo " | ||
- | </ | ||
- | |||
- | ===== Housekeeper y particionado ===== | ||
- | |||
- | http:// | ||
- | |||
- | Es MUY recomendable: | ||
- | |||
- | 1. [[http:// | ||
- | |||
- | 2. [[https:// | ||
- | ====== Comandos varios ====== | ||
- | |||
- | Recargar la cache (util para recargar la configuracion sin reiniciar el demonio): | ||
- | |||
- | sudo zabbix_server -R config_cache_reload | ||
- | |||
- | Obtener un valor de una maquina con el cliente zabbix instalado: | ||
- | |||
- | zabbix_get -s www-1.dev -k system.cpu.load | ||
- | |||
- | ====== Monitorizacion ====== | ||
- | |||
- | |||
- | |||
- | ===== MySQL ===== | ||
- | |||
- | http:// | ||
- | |||
- | http:// | ||
- | |||
- | |||
- | ===== Logs ===== | ||
- | |||
- | http:// | ||
- | http:// | ||
- | |||
- | Requisitos: | ||
- | |||
- | ^ Maquina ^ Elemento ^ Comentario ^ | ||
- | | Cliente | Zabbix client | Requiere configuracion, | ||
- | | Servidor | Item | - | | ||
- | | Servidor | Trigger | - | | ||
- | | Servidor | Action (Trigger) | Doy por hecho que ya existe una accion que envia un correo cuando se produce un trigger, pero se puede crear una para este caso | | ||
- | |||
- | En este ejemplo: | ||
- | |||
- | | test-5.dev.jj.com | Maquina que contiene el archivo de log que vamos a monitorizar | | ||
- | | monitor.dev.jj.com | Maquina con el servidor Zabbix instalado | | ||
- | |||
- | **Cliente** | ||
- | |||
- | 1. Editar: | ||
- | |||
- | / | ||
- | |||
- | Y anyadir/ | ||
- | |||
- | < | ||
- | EnableRemoteCommands=1 | ||
- | Hostname=test-5.dev.jj.com.dev.jj.com | ||
- | ListenPort=10050 | ||
- | ServerActive=monitor.dev.jj.com | ||
- | </ | ||
- | |||
- | 2. Reiniciar el servicio: | ||
- | |||
- | sudo / | ||
- | |||
- | **Item** | ||
- | |||
- | En este caso lo he creado a pelo sobre el ' | ||
- | |||
- | {{informatica: | ||
- | |||
- | **Trigger** | ||
- | |||
- | Buscamos la cadena ' | ||
- | |||
- | {{informatica: | ||
- | |||
- | **Action** | ||
- | |||
- | En este caso generica, pero se puede personalizar: | ||
- | |||
- | {{informatica: | ||
- | {{informatica: | ||
- | {{informatica: | ||
- | |||
- | |||
- | |||
- | ====== Triggers ====== | ||
- | |||
- | * Trigger que se ejecuta solo en un determinado lapso de tiempo (solo de 05:00:00 a 05:01:10): | ||
- | |||
- | | Expression | {scheduler-1.dev.jj.com: | ||
- | |||
- | ====== Notificaciones ====== | ||
- | |||
- | ===== Correo (ssmtp) ===== | ||
- | |||
- | https:// | ||
- | |||
- | 1. Crear un script: | ||
- | |||
- | sudo vim / | ||
- | | ||
- | Con el siguiente contenido: | ||
- | |||
- | < | ||
- | #!/bin/bash | ||
- | |||
- | to=$1 | ||
- | subject=$2 | ||
- | body=$3 | ||
- | |||
- | cat <<EOF | mail -s " | ||
- | $body | ||
- | EOF | ||
- | </ | ||
- | |||
- | 2. Dar permisos: | ||
- | |||
- | sudo chgrp zabbix / | ||
- | sudo chmod 0775 / | ||
- | |||
- | 3. Editar el archivo de configuracion: | ||
- | |||
- | sudo cp / | ||
- | sudo vim / | ||
- | |||
- | Y escribir la siguiente linea: | ||
- | |||
- | AlertScriptsPath=/ | ||
- | | ||
- | 4. Recargar la cache de configuracion: | ||
- | |||
- | sudo service zabbix-server force-reload | ||
- | |||
- | 5. (Interfaz web) Iniciar sesion con un usuario con permisos de administracion | ||
- | |||
- | 6. Ir a " | ||
- | |||
- | 7. Pulsar sobre el boton " | ||
- | |||
- | 8. Dejar los valores asi: | ||
- | |||
- | | Description | Email ssmtp | | ||
- | | Type | Script | | ||
- | | Script name | zabbix_mail.sh | | ||
- | | Enabled | (marcado) | | ||
- | |||
- | Pulsar el boton " | ||
- | |||
- | 9. Comprobar que todo ha ido bien: | ||
- | |||
- | 9.1. Ir a " | ||
- | |||
- | 9.2. Seleccionar un usuario cualquiera | ||
- | |||
- | 9.3. Pulsar en la solapa " | ||
- | |||
- | 9.4. Pulsar en el enlace " | ||
- | |||
- | 9.5.Dejar los valores asi: | ||
- | |||
- | | Type | Email ssmtp | | ||
- | | Send to | destination@example.com | | ||
- | |||
- | Pulsar el boton " | ||
- | |||
- | |||
- | ====== Parches ====== | ||
- | |||
- | ^ Version ^ Funcionalidad ^ Recurso ^ | ||
- | | 2.2 | Mostrar todas las graficas de un host a la vez | https:// | ||
- | | 2.0.2 (2.0.9+ creo no necesario) | Soporte a OID dinamicos para SNMP LLD | https:// | ||
- | |||
- | |||
- | ====== Bugs ====== | ||
- | |||
- | 1. Cuando activo/ | ||
- | |||
- | ssh monitor.dev.jj.com | ||
- | sudo zabbix_server -R config_cache_reload | ||
- | |||
- | |||
- | ====== Script de arranque para agente ====== | ||
- | |||
- | Usar este en lugar del que provee zabbix: | ||
- | |||
- | / | ||
- | |||
- | < | ||
- | #!/bin/sh | ||
- | |||
- | # | ||
- | # Zabbix agent start/stop script. | ||
- | # | ||
- | # Copyright (C) 2000-2012 Zabbix SIA | ||
- | # Added status) parameter by Jamgo S.C.C.L. | ||
- | |||
- | NAME=zabbix_agentd | ||
- | DAEMON=/ | ||
- | DESC=" | ||
- | PID=/ | ||
- | LOG=/ | ||
- | |||
- | # Include LSB funcions | ||
- | . / | ||
- | |||
- | test -f $DAEMON || exit 0 | ||
- | |||
- | case " | ||
- | start) | ||
- | echo " | ||
- | start-stop-daemon --start --oknodo --pidfile $PID --exec $DAEMON | ||
- | ;; | ||
- | stop) | ||
- | echo " | ||
- | start-stop-daemon --stop --quiet --pidfile $PID --retry=TERM/ | ||
- | start-stop-daemon --stop --oknodo --exec $DAEMON --name $NAME --retry=TERM/ | ||
- | ;; | ||
- | restart|force-reload) | ||
- | $0 stop | ||
- | $0 start | ||
- | ;; | ||
- | status) | ||
- | status_of_proc -p $PID " | ||
- | ;; | ||
- | *) | ||
- | N=/ | ||
- | echo " | ||
- | exit 1 | ||
- | ;; | ||
- | esac | ||
- | |||
- | exit 0 | ||
- | </ | ||
- | ====== Autenticacion LDAP ====== | ||
- | |||
- | **IMPORTANTE** Hay que crear cuentas primero con el mismo ' | ||
- | |||
- | Ver: | ||
- | |||
- | [[https:// | ||
- | |||
- | [[https:// | ||
- | |||
- | [[https:// | ||
- | |||
- | 1. Hacer login con el superusuario ' | ||
- | |||
- | 2. Crear otro superusuario con el **mismo usuario y contrasenya que un usuario LDAP ya existente** | ||
- | |||
- | 2.1. Ir a ' | ||
- | |||
- | 2.2. En el desplegable seleccionar ' | ||
- | |||
- | 2.3. Rellenar los campos " | ||
- | |||
- | 2.4. En la pestanya " | ||
- | |||
- | 2.5. Pulsamos el boton " | ||
- | |||
- | 3. Hacemos un logout | ||
- | |||
- | 4. Hacemos un login con las nuevas credenciales recien creadas en el paso 2. | ||
- | |||
- | 5. Vamos a " | ||
- | |||
- | 6. Ejemplo de config con LDAPS: | ||
- | |||
- | | LDAP host | STRING (see below, it breaks the table) | | ||
- | | Port | 636 | | ||
- | | Base DN | ou=people, | ||
- | | Search attribute | uid | | ||
- | | Bind DN | cn=readonly, | ||
- | | Bind password | El password del usuario LDAP " | ||
- | |||
- | STRING: | ||
- | ldaps:// | ||
- | |||
- | El campo " | ||
- | |||
- | 7. Pulsar sobre el boton " |
informatica/linux/zabbix.1426257730.txt.gz · Last modified: 2015/04/13 20:19 (external edit)