======= zabbix ======= monitor snmp graphs ====== Instalacion ====== ===== Por repositorio ===== Fuente: https://www.zabbix.com/documentation/2.0/manual/installation/install_from_packages#debian_ubuntu \\ Nos descargamos el paquete de configuración: http://repo.zabbix.com/zabbix/2.0/debian/pool/main/z/zabbix-release/zabbix-release_2.0-1squeeze_all.deb Y lo instalamos: dpkg -i zabbix-release_2.0-1squeeze_all.deb Esto crea la siguiente entrada en los repositorios: /etc/apt/sources.list.d/zabbix.list deb http://repo.zabbix.com/zabbix/2.0/debian squeeze main deb-src http://repo.zabbix.com/zabbix/2.0/debian squeeze main ===== 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 'zabbix-server-mysql' de los repositorios oficials de Debian se queda colgado ===== Servidor Zabbix ===== ==== Version 2.0.2 repositorio no oficial ==== 1. (monitor-1.dev.jj.com) Anyadir al sources list el repositorio de http://guruhub.com.uy: sudo su echo "deb http://repo.guruhub.com.uy/debian/ squeeze main" >/etc/apt/sources.list.d/guruhub-squeeze.list 2. Anyadir sus claves. A mi no me funciono, me sigue dando un warning: wget -q -O - http://repo.guruhub.com.uy/guruhub.apt.gpg | sudo apt-key add - 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 'mysql-1.dev.jj.com'. Quiza haya que reconfigurar el paquete: sudo dpkg-reconfigure zabbix-server-mysql 4. Para el servidor zabbix: sudo /etc/init.d/zabbix-server stop 5. Hacer un volcado de la base de datos (el nombre se especifica en el paso 3, asumo que es 'zabbix'): sudo mysqldump --add-drop-table -e zabbix > /tmp/zabbix_dump.sql -u mi_usuario -p Le anyadimos que use la base de datos zabbix: sudo vim /tmp/zabbix_dump.sql Teclear al inicio: use zabbix; 6. Copiar el volcado a la base de datos (mysql-1.dev.jj.com en el ejemplo): scp /tmp/zabbix_dump.sql mysql-1.dev.jj.com:/tmp/ 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://www.zabbix.com/documentation/2.0/manual/installation/install 1. Descargar http://www.zabbix.com/download.php 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 /ruta/zabbix-2.0.2 ./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 /ruta/zabbix-2.0.2/misc/init.d/debian/zabbix-server /etc/init.d/ 8. Editar el archivo de configuracion (importante ajustar entre otros los valores de la conexion a la BD): sudo vim /usr/local/etc/zabbix_server.conf 9. Arrancar sudo /etc/init.d/zabbix-server restart ===== Servidor de Bases de Datos ===== https://www.zabbix.com/documentation/2.0/manual/appendix/install/db_scripts 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 'zabbix' que se conectara tanto desde el servidor Zabbix como desde el frontend web. En este caso le permito que se conecte desde maquinas cuyo nombre coincida con el patron '%.dev.jj.com': grant usage on *.* to 'zabbix'@'%.dev.jj.com' identified by 'contrasenya'; grant all on zabbix.* to 'zabbix'@'%.dev.jj.com'; flush privileges; 4. Permito conectividad desde todas las maquinas (se puede hacer mas restrictivo si se quiere): sudo cp /etc/mysql/my.cnf /etc/mysql/my.cnf.old sudo vim /etc/mysql/my.cnf Y anyado/edito la siguiente linea: bind-address = 0.0.0.0 5. Ingesta inicial del volcado de la base de datos del servidor Zabbix: mysql -u root -p < /tmp/zabbix_dump.sql 5.1 Si lo hemos instalado de la versión oficial, ejecutamos el volcado de los ficheros de: /usr/local/bin/zabbix-2.0.6/database/mysql 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 /etc/init.d/mysql restart 7. (monitor-1.dev.jj.com) Ajusto la configuracion del servidor Zabbix para que apunte a la basae de datos: sudo cp /etc/zabbix/zabbix_server.conf /etc/zabbix/zabbix_server.conf.old sudo vim /etc/zabbix/zabbix_server.conf Y anyado/edito las siguientes lineas: 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 /etc/init.d/zabbix-agent restart sudo tail -F /var/log/zabbix-server/zabbix_server.log ===== 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 '/var/www') al directorio 'frontends/php': cd /srv/www; sudo ln -s cd /ruta/zabbix-2.0.5/frontends/php zabbix sudo chown -R www-data:www-data * 3. Ajustar la configuración de la Base de Datos: cd /srv/www/zabbix/conf; sudo cp zabbix.conf.php.example zabbix.conf.php sudo vim zabbix.conf.php Con el siguiente contenido: $DB["SERVER"] = "mysql-1.dev.jj.com"; $DB["DATABASE"] = "zabbix"; $DB["USER"] = "zabbix"; $DB["PASSWORD"] = "contrasenya"; $ZBX_SERVER = "monitor.dev.jj.com"; 4. Deberiamos poder acceder (usuario 'Admin', contrasenya 'zabbix') al frontend web: http://www-1.dev.jj.com/zabbix ==== 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 /etc/zabbix/dbconfig.php /etc/zabbix/dbconfig.php.old sudo vim /etc/zabbix/dbconfig.php Anyadir/editar las siguientes lineas: $DB["SERVER"] = "mysql-1.dev.jj.com"; $DB["DATABASE"] = "zabbix"; $DB["USER"] = "zabbix"; $DB["PASSWORD"] = "contrasenya"; $ZBX_SERVER = "monitor.dev.jj.com"; 4. Deberiamos poder acceder (usuario 'Admin', contrasenya 'zabbix') al frontend web: http://www-1.dev.jj.com/zabbix ===== 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/para... el servicio: /etc/init.d/zabbix_agentd {start|stop|restart|force-reload} ===== 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 /etc/zabbix/zabbix_proxy.conf 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 /etc/init.d/zabbix-proxy restart sudo tail -F /var/log/zabbix-proxy/zabbix_proxy.log ===== 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://linuxhacks.in/2013/08/zabbix-database-backup.html#.U1-ynt1yvg4 #!/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://zabbixzone.com # #Modified by Suyash Jain ( me at suyashjain.com) http://linuxhacks.in #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 , #so we required an custom script which will take the backup of entire schema/structure and the #important/configuration data only. #Zabbix History/alerts and their are many other tables which grows rapidly. #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="localhost" DBNAME="database" DBUSER="username" DBPASS="password" # some tools MYSQLDUMP="`which mysqldump`" GZIP="`which gzip`" DATEBIN="`which date`" MKDIRBIN="`which mkdir`" # target path MAINDIR="/opt/zabbix-backup/" DUMPFILE="${MAINDIR}/`${DATEBIN} +%Y%m%d%H%M`" ${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[*]}; do echo "Backuping table ${table}" ${MYSQLDUMP} -R –opt –extended-insert=FALSE \ -h ${DBHOST} -u ${DBUSER} -p${DBPASS} ${DBNAME} –tables ${table} >>${DUMPFILE} done # DATATABLES for table in ${DATATABLES[*]}; do echo "Backuping schema table ${table}" ${MYSQLDUMP} -R –opt –no-data \ -h ${DBHOST} -u ${DBUSER} -p${DBPASS} ${DBNAME} –tables ${table} >>${DUMPFILE} done echo echo "Backup Completed – ${DUMPFILE}" ===== Housekeeper y particionado ===== http://zabbixzone.com/zabbix/mysql-performance-tips-for-zabbix/ http://dev.mysql.com/doc/refman/5.5/en/innodb-multiple-tablespaces.html https://www.zabbix.org/wiki/Docs/howto/mysql_partition 1. Habilitar file per table http://dev.mysql.com/doc/refman/5.5/en/innodb-multiple-tablespaces.html 2. Cambiar indices (puede ser lento y bloquear inserts): mysql -u zabbix2014 -p use zabbix2014; Alter table history_text drop primary key, add index (id), drop index history_text_2, add index history_text_2 itemid, id); Alter table history_log drop primary key, add index (id), drop index history_log_2, add index history_log_2 (itemid, id); 3. Crear procedures: DELIMITER $$ CREATE PROCEDURE `partition_create`(SCHEMANAME VARCHAR(64), TABLENAME VARCHAR(64), PARTITIONNAME VARCHAR(64), CLOCK INT) BEGIN /* SCHEMANAME = The DB schema in which to make changes TABLENAME = The table with partitions to potentially delete PARTITIONNAME = The name of the partition to create */ /* Verify that the partition does not already exist */ DECLARE RETROWS INT; SELECT COUNT(1) INTO RETROWS FROM information_schema.partitions WHERE table_schema = SCHEMANAME AND TABLE_NAME = TABLENAME AND partition_description >= CLOCK; IF RETROWS = 0 THEN /* 1. Print a message indicating that a partition was created. 2. Create the SQL to create the partition. 3. Execute the SQL from #2. */ SELECT CONCAT( "partition_create(", SCHEMANAME, ",", TABLENAME, ",", PARTITIONNAME, ",", CLOCK, ")" ) AS msg; SET @SQL = CONCAT( 'ALTER TABLE ', SCHEMANAME, '.', TABLENAME, ' ADD PARTITION (PARTITION ', PARTITIONNAME, ' VALUES LESS THAN (', CLOCK, '));' ); PREPARE STMT FROM @SQL; EXECUTE STMT; DEALLOCATE PREPARE STMT; END IF; END$$ DELIMITER ; DELIMITER $$ CREATE PROCEDURE `partition_drop`(SCHEMANAME VARCHAR(64), TABLENAME VARCHAR(64), DELETE_BELOW_PARTITION_DATE BIGINT) BEGIN /* SCHEMANAME = The DB schema in which to make changes TABLENAME = The table with partitions to potentially delete DELETE_BELOW_PARTITION_DATE = Delete any partitions with names that are dates older than this one (yyyy-mm-dd) */ DECLARE done INT DEFAULT FALSE; DECLARE drop_part_name VARCHAR(16); /* Get a list of all the partitions that are older than the date in DELETE_BELOW_PARTITION_DATE. All partitions are prefixed with a "p", so use SUBSTRING TO get rid of that character. */ DECLARE myCursor CURSOR FOR SELECT partition_name FROM information_schema.partitions WHERE table_schema = SCHEMANAME AND TABLE_NAME = TABLENAME AND CAST(SUBSTRING(partition_name FROM 2) AS UNSIGNED) < DELETE_BELOW_PARTITION_DATE; DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; /* Create the basics for when we need to drop the partition. Also, create @drop_partitions to hold a comma-delimited list of all partitions that should be deleted. */ SET @alter_header = CONCAT("ALTER TABLE ", SCHEMANAME, ".", TABLENAME, " DROP PARTITION "); SET @drop_partitions = ""; /* Start looping through all the partitions that are too old. */ OPEN myCursor; read_loop: LOOP FETCH myCursor INTO drop_part_name; IF done THEN LEAVE read_loop; END IF; SET @drop_partitions = IF(@drop_partitions = "", drop_part_name, CONCAT(@drop_partitions, ",", drop_part_name)); END LOOP; IF @drop_partitions != "" THEN /* 1. Build the SQL to drop all the necessary partitions. 2. Run the SQL to drop the partitions. 3. Print out the table partitions that were deleted. */ SET @full_sql = CONCAT(@alter_header, @drop_partitions, ";"); PREPARE STMT FROM @full_sql; EXECUTE STMT; DEALLOCATE PREPARE STMT; SELECT CONCAT(SCHEMANAME, ".", TABLENAME) AS `table`, @drop_partitions AS `partitions_deleted`; ELSE /* No partitions are being deleted, so print out "N/A" (Not applicable) to indicate that no changes were made. */ SELECT CONCAT(SCHEMANAME, ".", TABLENAME) AS `table`, "N/A" AS `partitions_deleted`; END IF; END$$ DELIMITER ; DELIMITER $$ CREATE PROCEDURE `partition_maintenance`(SCHEMA_NAME VARCHAR(32), TABLE_NAME VARCHAR(32), KEEP_DATA_DAYS INT, HOURLY_INTERVAL INT, CREATE_NEXT_INTERVALS INT) BEGIN DECLARE OLDER_THAN_PARTITION_DATE VARCHAR(16); DECLARE PARTITION_NAME VARCHAR(16); DECLARE LESS_THAN_TIMESTAMP INT; DECLARE CUR_TIME INT; CALL partition_verify(SCHEMA_NAME, TABLE_NAME, HOURLY_INTERVAL); SET CUR_TIME = UNIX_TIMESTAMP(DATE_FORMAT(NOW(), '%Y-%m-%d 00:00:00')); SET @__interval = 1; create_loop: LOOP IF @__interval > CREATE_NEXT_INTERVALS THEN LEAVE create_loop; END IF; SET LESS_THAN_TIMESTAMP = CUR_TIME + (HOURLY_INTERVAL * @__interval * 3600); SET PARTITION_NAME = FROM_UNIXTIME(CUR_TIME + HOURLY_INTERVAL * (@__interval - 1) * 3600, 'p%Y%m%d%H00'); CALL partition_create(SCHEMA_NAME, TABLE_NAME, PARTITION_NAME, LESS_THAN_TIMESTAMP); SET @__interval=@__interval+1; END LOOP; SET OLDER_THAN_PARTITION_DATE=DATE_FORMAT(DATE_SUB(NOW(), INTERVAL KEEP_DATA_DAYS DAY), '%Y%m%d0000'); CALL partition_drop(SCHEMA_NAME, TABLE_NAME, OLDER_THAN_PARTITION_DATE); END$$ DELIMITER ; DELIMITER $$ CREATE PROCEDURE `partition_verify`(SCHEMANAME VARCHAR(64), TABLENAME VARCHAR(64), HOURLYINTERVAL INT(11)) BEGIN DECLARE PARTITION_NAME VARCHAR(16); DECLARE RETROWS INT(11); DECLARE FUTURE_TIMESTAMP TIMESTAMP; /* * Check if any partitions exist for the given SCHEMANAME.TABLENAME. */ SELECT COUNT(1) INTO RETROWS FROM information_schema.partitions WHERE table_schema = SCHEMANAME AND TABLE_NAME = TABLENAME AND partition_name IS NULL; /* * If partitions do not exist, go ahead and partition the table */ IF RETROWS = 1 THEN /* * Take the current date at 00:00:00 and add HOURLYINTERVAL to it. This is the timestamp below which we will store values. * We begin partitioning based on the beginning of a day. This is because we don't want to generate a random partition * that won't necessarily fall in line with the desired partition naming (ie: if the hour interval is 24 hours, we could * end up creating a partition now named "p201403270600" when all other partitions will be like "p201403280000"). */ SET FUTURE_TIMESTAMP = TIMESTAMPADD(HOUR, HOURLYINTERVAL, CONCAT(CURDATE(), " ", '00:00:00')); SET PARTITION_NAME = DATE_FORMAT(CURDATE(), 'p%Y%m%d%H00'); -- Create the partitioning query SET @__PARTITION_SQL = CONCAT("ALTER TABLE ", SCHEMANAME, ".", TABLENAME, " PARTITION BY RANGE(`clock`)"); SET @__PARTITION_SQL = CONCAT(@__PARTITION_SQL, "(PARTITION ", PARTITION_NAME, " VALUES LESS THAN (", UNIX_TIMESTAMP(FUTURE_TIMESTAMP), "));"); -- Run the partitioning query PREPARE STMT FROM @__PARTITION_SQL; EXECUTE STMT; DEALLOCATE PREPARE STMT; END IF; END$$ DELIMITER ; Este ultimo los gobierna todos, por tanto hay que seleccionar los valores que se adapte a nuestras necesidades: DELIMITER $$ CREATE PROCEDURE `partition_maintenance_all`(SCHEMA_NAME VARCHAR(32)) BEGIN CALL partition_maintenance(SCHEMA_NAME, 'history', 28, 24, 14); CALL partition_maintenance(SCHEMA_NAME, 'history_log', 28, 24, 14); CALL partition_maintenance(SCHEMA_NAME, 'history_str', 28, 24, 14); CALL partition_maintenance(SCHEMA_NAME, 'history_text', 28, 24, 14); CALL partition_maintenance(SCHEMA_NAME, 'history_uint', 28, 24, 14); CALL partition_maintenance(SCHEMA_NAME, 'trends', 730, 24, 14); CALL partition_maintenance(SCHEMA_NAME, 'trends_uint', 730, 24, 14); END$$ DELIMITER ; 4. Dar permisos de ejecucion al ultimo procedimiento. Vamos a dar al mismo usuario que puede leer la base de datos de zabbix: GRANT EXECUTE ON PROCEDURE zabbix2014.partition_maintenance_all TO 'zabbix2014'@'localhost'; flush privileges; exit; 5. Creamos archivo para poder iniciar sesion mysql sin contrasenya: vim ~/.my.cnf Con el siguiente contenido: [client] user=zabbix2014 password=zabbix2014 Ajustamos permisos: chmod 0600 ~/.my.cnf 6. Creamos un script para ser llamado desde cron: sudo vim /opt/partition_maintenance_all.sh Con el siguiente contenido (ajustar variables): #!/bin/bash LOG="/var/log/"`basename $0`".log" STRING_START="START of the script:" STRING_END="END of the script:" MYSQL_USER="zabbix2014" MYSQL_DB=$MYSQL_USER MYSQL_PROCEDURE="partition_maintenance_all" [[ ! $LOG ]]; touch $LOG DATE="$(date +%d/%m/%Y) $(date +%H:%M:%S)" echo -e "\n################### $STRING_START $DATE ##################" >> $LOG #mysql -u $MYSQL_USER -e "CALL partition_maintenance_all('zabbix2014')\G" zabbix2014 >> $LOG 2>&1 #mysql -u $MYSQL_USER -e "CALL partition_maintenance_all('"$MYSQL_DB"')\G" $MYSQL_DB >> $LOG 2>&1 mysql -u $MYSQL_USER -e "CALL "$MYSQL_PROCEDURE"('"$MYSQL_DB"')\G" $MYSQL_DB >> $LOG 2>&1 DATE="$(date +%d/%m/%Y) $(date +%H:%M:%S)" echo -e "\n################### $STRING_END $DATE ##################" >> $LOG Ajustamos permisos y logs: sudo chown usuario:usuario /opt/partition_maintenance_all.sh chmod +x /opt/partition_maintenance_all.sh sudo touch /var/log/partition_maintenance_all.sh.log sudo chown root:usuario /var/log/partition_maintenance_all.sh.log chmod 660 /var/log/partition_maintenance_all.sh.log Y anyadimos la entrada a cron, para ser ejecutada, por ejemplo, cada dia: 13 4 * * * /opt/partition_maintenance_all.sh >> /var/log/partition_maintenance_all.sh.log 2>&1 ====== 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://www.zabbix.com/forum/showthread.php?t=26503 http://code.google.com/p/mysql-cacti-templates/source/browse/trunk/scripts/ss_get_mysql_stats.php?r=543 1. Instalar agente paquetes sudo aptitude update; sudo aptitude install zabbix-agent 2. Crear script para obtener info de mysql: sudo mkdir -p /usr/local/share/zabbix/plugins/ sudo touch /usr/local/share/zabbix/plugins/ss_get_mysql_stats.php sudo chmod +x /usr/local/share/zabbix/plugins/ss_get_mysql_stats.php sudo vim /usr/local/share/zabbix/plugins/ss_get_mysql_stats.php **OJO**: ajustar las credenciales del usuario mysql que crearemos posteriormente: $mysql_user = 'zabbix'; $mysql_pass = 'some_password'; Con el siguiente contenido: true, # Do you want to check InnoDB statistics? 'master' => true, # Do you want to check binary logging? 'slave' => true, # Do you want to check slave status? 'procs' => true, # Do you want to check SHOW PROCESSLIST? 'get_qrt' => true, # Get query response times from Percona Server? ); $use_ss = FALSE; # Whether to use the script server or not $debug = FALSE; # Define whether you want debugging behavior. $debug_log = FALSE; # If $debug_log is a filename, it'll be used. # ============================================================================ # You should not need to change anything below this line. # ============================================================================ $version = '$VERSION$'; # ============================================================================ # Include settings from an external config file (issue 39). # ============================================================================ if ( file_exists(__FILE__ . '.cnf' ) ) { debug("Found configuration file " . __FILE__ . ".cnf"); require(__FILE__ . '.cnf'); } # Make this a happy little script even when there are errors. $no_http_headers = true; ini_set('implicit_flush', false); # No output, ever. if ( $debug ) { ini_set('display_errors', true); ini_set('display_startup_errors', true); ini_set('error_reporting', 2147483647); } else { ini_set('error_reporting', E_ERROR); } ob_start(); # Catch all output such as notices of undefined array indexes. function error_handler($errno, $errstr, $errfile, $errline) { print("$errstr at $errfile line $errline\n"); debug("$errstr at $errfile line $errline"); } # ============================================================================ # Set up the stuff we need to be called by the script server. # ============================================================================ if ( $use_ss ) { if ( file_exists( dirname(__FILE__) . "/../include/global.php") ) { # See issue 5 for the reasoning behind this. debug("including " . dirname(__FILE__) . "/../include/global.php"); include_once(dirname(__FILE__) . "/../include/global.php"); } elseif ( file_exists( dirname(__FILE__) . "/../include/config.php" ) ) { # Some Cacti installations don't have global.php. debug("including " . dirname(__FILE__) . "/../include/config.php"); include_once(dirname(__FILE__) . "/../include/config.php"); } } # ============================================================================ # Set the default timezone either to the configured, system timezone, or the # default set above in the script. # ============================================================================ if ( function_exists("date_default_timezone_set") && function_exists("date_default_timezone_get") ) { $tz = ($timezone ? $timezone : @date_default_timezone_get()); if ( $tz ) { @date_default_timezone_set($tz); } } # ============================================================================ # Make sure we can also be called as a script. # ============================================================================ if (!isset($called_by_script_server)) { debug($_SERVER["argv"]); array_shift($_SERVER["argv"]); # Strip off this script's filename $options = parse_cmdline($_SERVER["argv"]); validate_options($options); $result = ss_get_mysql_stats($options); debug($result); if ( !$debug ) { # Throw away the buffer, which ought to contain only errors. ob_end_clean(); } else { ob_end_flush(); # In debugging mode, print out the errors. } # Split the result up and extract only the desired parts of it. $wanted = explode(',', $options['items']); $output = array(); foreach ( explode(' ', $result) as $item ) { if ( in_array(substr($item, 0, 2), $wanted) ) { $output[] = $item; } } debug(array("Final result", $output)); print(implode(' ', $output)); } # ============================================================================ # End "if file was not included" section. # ============================================================================ } # ============================================================================ # Work around the lack of array_change_key_case in older PHP. # ============================================================================ if ( !function_exists('array_change_key_case') ) { function array_change_key_case($arr) { $res = array(); foreach ( $arr as $key => $val ) { $res[strtolower($key)] = $val; } return $res; } } # ============================================================================ # Validate that the command-line options are here and correct # ============================================================================ function validate_options($options) { debug($options); $opts = array('host', 'items', 'user', 'pass', 'heartbeat', 'nocache', 'port'); # Required command-line options foreach ( array('host', 'items') as $option ) { if ( !isset($options[$option]) || !$options[$option] ) { usage("Required option --$option is missing"); } } foreach ( $options as $key => $val ) { if ( !in_array($key, $opts) ) { usage("Unknown option --$key"); } } } # ============================================================================ # Print out a brief usage summary # ============================================================================ function usage($message) { global $mysql_user, $mysql_pass, $mysql_port, $heartbeat; $usage = << --items [OPTION] --host MySQL host --port MySQL port; defaults to $mysql_port if not given --items Comma-separated list of the items whose data you want --user MySQL username; defaults to $mysql_user if not given --pass MySQL password; defaults to $mysql_pass if not given --heartbeat MySQL heartbeat table; defaults to '$heartbeat' (see pt-heartbeat) --nocache Do not cache results in a file --mysql_ssl Enable SSL support for MySQL connection EOF; die($usage); } # ============================================================================ # Parse command-line arguments, in the format --arg value --arg value, and # return them as an array ( arg => value ) # ============================================================================ function parse_cmdline( $args ) { $result = array(); $cur_arg = ''; foreach ($args as $val) { if ( strpos($val, '--') === 0 ) { if ( strpos($val, '--no') === 0 ) { # It's an option without an argument, but it's a --nosomething so # it's OK. $result[substr($val, 2)] = 1; $cur_arg = ''; } elseif ( $cur_arg ) { # Maybe the last --arg was an option with no arg if ( $cur_arg == '--user' || $cur_arg == '--pass' || $cur_arg == '--port' ) { # Special case because Cacti will pass these without an arg $cur_arg = ''; } else { die("No arg: $cur_arg\n"); } } else { $cur_arg = $val; } } else { $result[substr($cur_arg, 2)] = $val; $cur_arg = ''; } } if ( $cur_arg && ($cur_arg != '--user' && $cur_arg != '--pass' && $cur_arg != '--port') ) { die("No arg: $cur_arg\n"); } debug($result); return $result; } # ============================================================================ # This is the main function. Some parameters are filled in from defaults at the # top of this file. # ============================================================================ function ss_get_mysql_stats( $options ) { # Process connection options and connect to MySQL. global $debug, $mysql_user, $mysql_pass, $heartbeat, $cache_dir, $poll_time, $chk_options, $mysql_port, $mysql_ssl, $mysql_ssl_key, $mysql_ssl_cert, $mysql_ssl_ca; # Connect to MySQL. $user = isset($options['user']) ? $options['user'] : $mysql_user; $pass = isset($options['pass']) ? $options['pass'] : $mysql_pass; $host = $options['host']; $port = isset($options['port']) ? $options['port'] : $mysql_port; $heartbeat = isset($options['heartbeat']) ? $options['heartbeat'] : $heartbeat; debug(array('connecting to', $host, $port, $user, $pass)); if ( !extension_loaded('mysqli') ) { debug("The MySQLi extension is not loaded"); die("The MySQLi extension is not loaded"); } if ( $mysql_ssl || (isset($options['mysql_ssl']) && $options['mysql_ssl']) ) { $conn = mysqli_init(); mysqli_ssl_set($conn, $mysql_ssl_key, $mysql_ssl_cert, $mysql_ssl_ca, NULL, NULL); mysqli_real_connect($conn, $host, $user, $pass, NULL, $port); } else { $conn = mysqli_connect($host, $user, $pass, NULL, $port); } if ( !$conn ) { debug("MySQL connection failed: " . mysqli_error()); die("MySQL: " . mysqli_error()); } $sanitized_host = str_replace(array(":", "/"), array("", "_"), $options['host']); $cache_file = "$cache_dir/$sanitized_host-mysql_cacti_stats.txt" . (isset($options['port']) || $port != 3306 ? ":$port" : ''); debug("Cache file is $cache_file"); # First, check the cache. $fp = null; if ( !isset($options['nocache']) ) { if ( $fp = fopen($cache_file, 'a+') ) { $locked = flock($fp, 1); # LOCK_SH if ( $locked ) { if ( filesize($cache_file) > 0 && filectime($cache_file) + ($poll_time/2) > time() && ($arr = file($cache_file)) ) {# The cache file is good to use. debug("Using the cache file"); fclose($fp); return $arr[0]; } else { debug("The cache file seems too small or stale"); # Escalate the lock to exclusive, so we can write to it. if ( flock($fp, 2) ) { # LOCK_EX # We might have blocked while waiting for that LOCK_EX, and # another process ran and updated it. Let's see if we can just # return the data now: if ( filesize($cache_file) > 0 && filectime($cache_file) + ($poll_time/2) > time() && ($arr = file($cache_file)) ) {# The cache file is good to use. debug("Using the cache file"); fclose($fp); return $arr[0]; } ftruncate($fp, 0); # Now it's ready for writing later. } } } else { debug("Couldn't lock the cache file, ignoring it."); $fp = null; } } } else { $fp = null; debug("Couldn't open the cache file"); } # Set up variables. $status = array( # Holds the result of SHOW STATUS, SHOW INNODB STATUS, etc # Define some indexes so they don't cause errors with += operations. 'relay_log_space' => null, 'binary_log_space' => null, 'current_transactions' => 0, 'locked_transactions' => 0, 'active_transactions' => 0, 'innodb_locked_tables' => 0, 'innodb_tables_in_use' => 0, 'innodb_lock_structs' => 0, 'innodb_lock_wait_secs' => 0, 'innodb_sem_waits' => 0, 'innodb_sem_wait_time_ms' => 0, # Values for the 'state' column from SHOW PROCESSLIST (converted to # lowercase, with spaces replaced by underscores) 'State_closing_tables' => 0, 'State_copying_to_tmp_table' => 0, 'State_end' => 0, 'State_freeing_items' => 0, 'State_init' => 0, 'State_locked' => 0, 'State_login' => 0, 'State_preparing' => 0, 'State_reading_from_net' => 0, 'State_sending_data' => 0, 'State_sorting_result' => 0, 'State_statistics' => 0, 'State_updating' => 0, 'State_writing_to_net' => 0, 'State_none' => 0, 'State_other' => 0, # Everything not listed above ); # Get SHOW STATUS and convert the name-value array into a simple # associative array. $result = run_query("SHOW /*!50002 GLOBAL */ STATUS", $conn); foreach ( $result as $row ) { $status[$row[0]] = $row[1]; } # Get SHOW VARIABLES and do the same thing, adding it to the $status array. $result = run_query("SHOW VARIABLES", $conn); foreach ( $result as $row ) { $status[$row[0]] = $row[1]; } # Get SHOW SLAVE STATUS, and add it to the $status array. if ( $chk_options['slave'] ) { $result = run_query("SHOW SLAVE STATUS", $conn); $slave_status_rows_gotten = 0; foreach ( $result as $row ) { $slave_status_rows_gotten++; # Must lowercase keys because different MySQL versions have different # lettercase. $row = array_change_key_case($row, CASE_LOWER); $status['relay_log_space'] = $row['relay_log_space']; $status['slave_lag'] = $row['seconds_behind_master']; # Check replication heartbeat, if present. if ( $heartbeat ) { $result2 = run_query( "SELECT MAX(GREATEST(0, UNIX_TIMESTAMP() - UNIX_TIMESTAMP(ts) - 1))" . " AS delay FROM $heartbeat", $conn); $slave_delay_rows_gotten = 0; foreach ( $result2 as $row2 ) { $slave_delay_rows_gotten++; if ( $row2 && is_array($row2) && array_key_exists('delay', $row2) ) { $status['slave_lag'] = $row2['delay']; } else { debug("Couldn't get slave lag from $heartbeat"); } } if ( $slave_delay_rows_gotten == 0 ) { debug("Got nothing from heartbeat query"); } } # Scale slave_running and slave_stopped relative to the slave lag. $status['slave_running'] = ($row['slave_sql_running'] == 'Yes') ? $status['slave_lag'] : 0; $status['slave_stopped'] = ($row['slave_sql_running'] == 'Yes') ? 0 : $status['slave_lag']; } if ( $slave_status_rows_gotten == 0 ) { debug("Got nothing from SHOW SLAVE STATUS"); } } # Get SHOW MASTER STATUS, and add it to the $status array. if ( $chk_options['master'] && array_key_exists('log_bin', $status) && $status['log_bin'] == 'ON' ) { # See issue #8 $binlogs = array(0); $result = run_query("SHOW MASTER LOGS", $conn); foreach ( $result as $row ) { $row = array_change_key_case($row, CASE_LOWER); # Older versions of MySQL may not have the File_size column in the # results of the command. Zero-size files indicate the user is # deleting binlogs manually from disk (bad user! bad!). if ( array_key_exists('file_size', $row) && $row['file_size'] > 0 ) { $binlogs[] = $row['file_size']; } } if (count($binlogs)) { $status['binary_log_space'] = to_int(array_sum($binlogs)); } } # Get SHOW PROCESSLIST and aggregate it by state, then add it to the array # too. if ( $chk_options['procs'] ) { $result = run_query('SHOW PROCESSLIST', $conn); foreach ( $result as $row ) { $state = $row['State']; if ( is_null($state) ) { $state = 'NULL'; } if ( $state == '' ) { $state = 'none'; } # MySQL 5.5 replaces the 'Locked' state with a variety of "Waiting for # X lock" types of statuses. Wrap these all back into "Locked" because # we don't really care about the type of locking it is. $state = preg_replace('/^(Table lock|Waiting for .*lock)$/', 'Locked', $state); $state = str_replace(' ', '_', strtolower($state)); if ( array_key_exists("State_$state", $status) ) { increment($status, "State_$state", 1); } else { increment($status, "State_other", 1); } } } # Get SHOW ENGINES to be able to determine whether InnoDB is present. $engines = array(); $result = run_query("SHOW ENGINES", $conn); foreach ( $result as $row ) { $engines[$row[0]] = $row[1]; } # Get SHOW INNODB STATUS and extract the desired metrics from it, then add # those to the array too. if ( $chk_options['innodb'] && array_key_exists('InnoDB', $engines) && $engines['InnoDB'] == 'YES' || $engines['InnoDB'] == 'DEFAULT' ) { $result = run_query("SHOW /*!50000 ENGINE*/ INNODB STATUS", $conn); $istatus_text = $result[0]['Status']; $istatus_vals = get_innodb_array($istatus_text); # Get response time histogram from Percona Server if enabled. if ( $chk_options['get_qrt'] && isset($status['have_response_time_distribution']) && ($status['have_response_time_distribution'] == 'YES')) { debug('Getting query time histogram'); $i = 0; $result = run_query( "SELECT `count`, total * 1000000 AS total " . "FROM INFORMATION_SCHEMA.QUERY_RESPONSE_TIME " . "WHERE `time` <> 'TOO LONG'", $conn); foreach ( $result as $row ) { if ( $i > 13 ) { # It's possible that the number of rows returned isn't 14. # Don't add extra status counters. break; } $count_key = sprintf("Query_time_count_%02d", $i); $total_key = sprintf("Query_time_total_%02d", $i); $status[$count_key] = $row['count']; $status[$total_key] = $row['total']; $i++; } # It's also possible that the number of rows returned is too few. # Don't leave any status counters unassigned; it will break graphs. while ( $i <= 13 ) { $count_key = sprintf("Query_time_count_%02d", $i); $total_key = sprintf("Query_time_total_%02d", $i); $status[$count_key] = 0; $status[$total_key] = 0; $i++; } } else { debug('Not getting time histogram because it is not enabled'); } # Override values from InnoDB parsing with values from SHOW STATUS, # because InnoDB status might not have everything and the SHOW STATUS is # to be preferred where possible. $overrides = array( 'Innodb_buffer_pool_pages_data' => 'database_pages', 'Innodb_buffer_pool_pages_dirty' => 'modified_pages', 'Innodb_buffer_pool_pages_free' => 'free_pages', 'Innodb_buffer_pool_pages_total' => 'pool_size', 'Innodb_data_fsyncs' => 'file_fsyncs', 'Innodb_data_pending_reads' => 'pending_normal_aio_reads', 'Innodb_data_pending_writes' => 'pending_normal_aio_writes', 'Innodb_os_log_pending_fsyncs' => 'pending_log_flushes', 'Innodb_pages_created' => 'pages_created', 'Innodb_pages_read' => 'pages_read', 'Innodb_pages_written' => 'pages_written', 'Innodb_rows_deleted' => 'rows_deleted', 'Innodb_rows_inserted' => 'rows_inserted', 'Innodb_rows_read' => 'rows_read', 'Innodb_rows_updated' => 'rows_updated', 'Innodb_buffer_pool_reads' => 'pool_reads', 'Innodb_buffer_pool_read_requests' => 'pool_read_requests', ); # If the SHOW STATUS value exists, override... foreach ( $overrides as $key => $val ) { if ( array_key_exists($key, $status) ) { debug("Override $key"); $istatus_vals[$val] = $status[$key]; } } # Now copy the values into $status. foreach ( $istatus_vals as $key => $val ) { $status[$key] = $istatus_vals[$key]; } } # Make table_open_cache backwards-compatible (issue 63). if ( array_key_exists('table_open_cache', $status) ) { $status['table_cache'] = $status['table_open_cache']; } # Compute how much of the key buffer is used and unflushed (issue 127). $status['Key_buf_bytes_used'] = big_sub($status['key_buffer_size'], big_multiply($status['Key_blocks_unused'], $status['key_cache_block_size'])); $status['Key_buf_bytes_unflushed'] = big_multiply($status['Key_blocks_not_flushed'], $status['key_cache_block_size']); if ( array_key_exists('unflushed_log', $status) && $status['unflushed_log'] ) { # TODO: I'm not sure what the deal is here; need to debug this. But the # unflushed log bytes spikes a lot sometimes and it's impossible for it to # be more than the log buffer. debug("Unflushed log: $status[unflushed_log]"); $status['unflushed_log'] = max($status['unflushed_log'], $status['innodb_log_buffer_size']); } # Define the variables to output. I use shortened variable names so maybe # it'll all fit in 1024 bytes for Cactid and Spine's benefit. Strings must # have some non-hex characters (non a-f0-9) to avoid a Cacti bug. This list # must come right after the word MAGIC_VARS_DEFINITIONS. The Perl script # parses it and uses it as a Perl variable. $keys = array( 'Key_read_requests' => 'gg', 'Key_reads' => 'gh', 'Key_write_requests' => 'gi', 'Key_writes' => 'gj', 'history_list' => 'gk', 'innodb_transactions' => 'gl', 'read_views' => 'gm', 'current_transactions' => 'gn', 'locked_transactions' => 'go', 'active_transactions' => 'gp', 'pool_size' => 'gq', 'free_pages' => 'gr', 'database_pages' => 'gs', 'modified_pages' => 'gt', 'pages_read' => 'gu', 'pages_created' => 'gv', 'pages_written' => 'gw', 'file_fsyncs' => 'gx', 'file_reads' => 'gy', 'file_writes' => 'gz', 'log_writes' => 'hg', 'pending_aio_log_ios' => 'hh', 'pending_aio_sync_ios' => 'hi', 'pending_buf_pool_flushes' => 'hj', 'pending_chkp_writes' => 'hk', 'pending_ibuf_aio_reads' => 'hl', 'pending_log_flushes' => 'hm', 'pending_log_writes' => 'hn', 'pending_normal_aio_reads' => 'ho', 'pending_normal_aio_writes' => 'hp', 'ibuf_inserts' => 'hq', 'ibuf_merged' => 'hr', 'ibuf_merges' => 'hs', 'spin_waits' => 'ht', 'spin_rounds' => 'hu', 'os_waits' => 'hv', 'rows_inserted' => 'hw', 'rows_updated' => 'hx', 'rows_deleted' => 'hy', 'rows_read' => 'hz', 'Table_locks_waited' => 'ig', 'Table_locks_immediate' => 'ih', 'Slow_queries' => 'ii', 'Open_files' => 'ij', 'Open_tables' => 'ik', 'Opened_tables' => 'il', 'innodb_open_files' => 'im', 'open_files_limit' => 'in', 'table_cache' => 'io', 'Aborted_clients' => 'ip', 'Aborted_connects' => 'iq', 'Max_used_connections' => 'ir', 'Slow_launch_threads' => 'is', 'Threads_cached' => 'it', 'Threads_connected' => 'iu', 'Threads_created' => 'iv', 'Threads_running' => 'iw', 'max_connections' => 'ix', 'thread_cache_size' => 'iy', 'Connections' => 'iz', 'slave_running' => 'jg', 'slave_stopped' => 'jh', 'Slave_retried_transactions' => 'ji', 'slave_lag' => 'jj', 'Slave_open_temp_tables' => 'jk', 'Qcache_free_blocks' => 'jl', 'Qcache_free_memory' => 'jm', 'Qcache_hits' => 'jn', 'Qcache_inserts' => 'jo', 'Qcache_lowmem_prunes' => 'jp', 'Qcache_not_cached' => 'jq', 'Qcache_queries_in_cache' => 'jr', 'Qcache_total_blocks' => 'js', 'query_cache_size' => 'jt', 'Questions' => 'ju', 'Com_update' => 'jv', 'Com_insert' => 'jw', 'Com_select' => 'jx', 'Com_delete' => 'jy', 'Com_replace' => 'jz', 'Com_load' => 'kg', 'Com_update_multi' => 'kh', 'Com_insert_select' => 'ki', 'Com_delete_multi' => 'kj', 'Com_replace_select' => 'kk', 'Select_full_join' => 'kl', 'Select_full_range_join' => 'km', 'Select_range' => 'kn', 'Select_range_check' => 'ko', 'Select_scan' => 'kp', 'Sort_merge_passes' => 'kq', 'Sort_range' => 'kr', 'Sort_rows' => 'ks', 'Sort_scan' => 'kt', 'Created_tmp_tables' => 'ku', 'Created_tmp_disk_tables' => 'kv', 'Created_tmp_files' => 'kw', 'Bytes_sent' => 'kx', 'Bytes_received' => 'ky', 'innodb_log_buffer_size' => 'kz', 'unflushed_log' => 'lg', 'log_bytes_flushed' => 'lh', 'log_bytes_written' => 'li', 'relay_log_space' => 'lj', 'binlog_cache_size' => 'lk', 'Binlog_cache_disk_use' => 'll', 'Binlog_cache_use' => 'lm', 'binary_log_space' => 'ln', 'innodb_locked_tables' => 'lo', 'innodb_lock_structs' => 'lp', 'State_closing_tables' => 'lq', 'State_copying_to_tmp_table' => 'lr', 'State_end' => 'ls', 'State_freeing_items' => 'lt', 'State_init' => 'lu', 'State_locked' => 'lv', 'State_login' => 'lw', 'State_preparing' => 'lx', 'State_reading_from_net' => 'ly', 'State_sending_data' => 'lz', 'State_sorting_result' => 'mg', 'State_statistics' => 'mh', 'State_updating' => 'mi', 'State_writing_to_net' => 'mj', 'State_none' => 'mk', 'State_other' => 'ml', 'Handler_commit' => 'mm', 'Handler_delete' => 'mn', 'Handler_discover' => 'mo', 'Handler_prepare' => 'mp', 'Handler_read_first' => 'mq', 'Handler_read_key' => 'mr', 'Handler_read_next' => 'ms', 'Handler_read_prev' => 'mt', 'Handler_read_rnd' => 'mu', 'Handler_read_rnd_next' => 'mv', 'Handler_rollback' => 'mw', 'Handler_savepoint' => 'mx', 'Handler_savepoint_rollback' => 'my', 'Handler_update' => 'mz', 'Handler_write' => 'ng', 'innodb_tables_in_use' => 'nh', 'innodb_lock_wait_secs' => 'ni', 'hash_index_cells_total' => 'nj', 'hash_index_cells_used' => 'nk', 'total_mem_alloc' => 'nl', 'additional_pool_alloc' => 'nm', 'uncheckpointed_bytes' => 'nn', 'ibuf_used_cells' => 'no', 'ibuf_free_cells' => 'np', 'ibuf_cell_count' => 'nq', 'adaptive_hash_memory' => 'nr', 'page_hash_memory' => 'ns', 'dictionary_cache_memory' => 'nt', 'file_system_memory' => 'nu', 'lock_system_memory' => 'nv', 'recovery_system_memory' => 'nw', 'thread_hash_memory' => 'nx', 'innodb_sem_waits' => 'ny', 'innodb_sem_wait_time_ms' => 'nz', 'Key_buf_bytes_unflushed' => 'og', 'Key_buf_bytes_used' => 'oh', 'key_buffer_size' => 'oi', 'Innodb_row_lock_time' => 'oj', 'Innodb_row_lock_waits' => 'ok', 'Query_time_count_00' => 'ol', 'Query_time_count_01' => 'om', 'Query_time_count_02' => 'on', 'Query_time_count_03' => 'oo', 'Query_time_count_04' => 'op', 'Query_time_count_05' => 'oq', 'Query_time_count_06' => 'or', 'Query_time_count_07' => 'os', 'Query_time_count_08' => 'ot', 'Query_time_count_09' => 'ou', 'Query_time_count_10' => 'ov', 'Query_time_count_11' => 'ow', 'Query_time_count_12' => 'ox', 'Query_time_count_13' => 'oy', 'Query_time_total_00' => 'oz', 'Query_time_total_01' => 'pg', 'Query_time_total_02' => 'ph', 'Query_time_total_03' => 'pi', 'Query_time_total_04' => 'pj', 'Query_time_total_05' => 'pk', 'Query_time_total_06' => 'pl', 'Query_time_total_07' => 'pm', 'Query_time_total_08' => 'pn', 'Query_time_total_09' => 'po', 'Query_time_total_10' => 'pp', 'Query_time_total_11' => 'pq', 'Query_time_total_12' => 'pr', 'Query_time_total_13' => 'ps', 'wsrep_replicated_bytes' => 'pt', 'wsrep_received_bytes' => 'pu', 'wsrep_replicated' => 'pv', 'wsrep_received' => 'pw', 'wsrep_local_cert_failures' => 'px', 'wsrep_local_bf_aborts' => 'py', 'wsrep_local_send_queue' => 'pz', 'wsrep_local_recv_queue' => 'qg', 'wsrep_cluster_size' => 'qh', 'wsrep_cert_deps_distance' => 'qi', 'wsrep_apply_window' => 'qj', 'wsrep_commit_window' => 'qk', 'wsrep_flow_control_paused' => 'ql', 'wsrep_flow_control_sent' => 'qm', 'wsrep_flow_control_recv' => 'qn', 'pool_reads' => 'qo', 'pool_read_requests' => 'qp', ); # Return the output. $output = array(); foreach ($keys as $key => $short ) { # If the value isn't defined, return -1 which is lower than (most graphs') # minimum value of 0, so it'll be regarded as a missing value. $val = isset($status[$key]) ? $status[$key] : -1; $output[] = "$short:$val"; } $result = implode(' ', $output); if ( $fp ) { if ( fwrite($fp, $result) === FALSE ) { die("Can't write '$cache_file'"); } fclose($fp); } return $result; } # ============================================================================ # Given INNODB STATUS text, returns a key-value array of the parsed text. Each # line shows a sample of the input for both standard InnoDB as you would find in # MySQL 5.0, and XtraDB or enhanced InnoDB from Percona if applicable. Note # that extra leading spaces are ignored due to trim(). # ============================================================================ function get_innodb_array($text) { $results = array( 'spin_waits' => array(), 'spin_rounds' => array(), 'os_waits' => array(), 'pending_normal_aio_reads' => null, 'pending_normal_aio_writes' => null, 'pending_ibuf_aio_reads' => null, 'pending_aio_log_ios' => null, 'pending_aio_sync_ios' => null, 'pending_log_flushes' => null, 'pending_buf_pool_flushes' => null, 'file_reads' => null, 'file_writes' => null, 'file_fsyncs' => null, 'ibuf_inserts' => null, 'ibuf_merged' => null, 'ibuf_merges' => null, 'log_bytes_written' => null, 'unflushed_log' => null, 'log_bytes_flushed' => null, 'pending_log_writes' => null, 'pending_chkp_writes' => null, 'log_writes' => null, 'pool_size' => null, 'free_pages' => null, 'database_pages' => null, 'modified_pages' => null, 'pages_read' => null, 'pages_created' => null, 'pages_written' => null, 'queries_inside' => null, 'queries_queued' => null, 'read_views' => null, 'rows_inserted' => null, 'rows_updated' => null, 'rows_deleted' => null, 'rows_read' => null, 'innodb_transactions' => null, 'unpurged_txns' => null, 'history_list' => null, 'current_transactions' => null, 'hash_index_cells_total' => null, 'hash_index_cells_used' => null, 'total_mem_alloc' => null, 'additional_pool_alloc' => null, 'last_checkpoint' => null, 'uncheckpointed_bytes' => null, 'ibuf_used_cells' => null, 'ibuf_free_cells' => null, 'ibuf_cell_count' => null, 'adaptive_hash_memory' => null, 'page_hash_memory' => null, 'dictionary_cache_memory' => null, 'file_system_memory' => null, 'lock_system_memory' => null, 'recovery_system_memory' => null, 'thread_hash_memory' => null, 'innodb_sem_waits' => null, 'innodb_sem_wait_time_ms' => null, ); $txn_seen = FALSE; foreach ( explode("\n", $text) as $line ) { $line = trim($line); $row = preg_split('/ +/', $line); # SEMAPHORES if (strpos($line, 'Mutex spin waits') === 0 ) { # Mutex spin waits 79626940, rounds 157459864, OS waits 698719 # Mutex spin waits 0, rounds 247280272495, OS waits 316513438 $results['spin_waits'][] = to_int($row[3]); $results['spin_rounds'][] = to_int($row[5]); $results['os_waits'][] = to_int($row[8]); } elseif (strpos($line, 'RW-shared spins') === 0 && strpos($line, ';') > 0 ) { # RW-shared spins 3859028, OS waits 2100750; RW-excl spins 4641946, OS waits 1530310 $results['spin_waits'][] = to_int($row[2]); $results['spin_waits'][] = to_int($row[8]); $results['os_waits'][] = to_int($row[5]); $results['os_waits'][] = to_int($row[11]); } elseif (strpos($line, 'RW-shared spins') === 0 && strpos($line, '; RW-excl spins') === FALSE) { # Post 5.5.17 SHOW ENGINE INNODB STATUS syntax # RW-shared spins 604733, rounds 8107431, OS waits 241268 $results['spin_waits'][] = to_int($row[2]); $results['os_waits'][] = to_int($row[7]); } elseif (strpos($line, 'RW-excl spins') === 0) { # Post 5.5.17 SHOW ENGINE INNODB STATUS syntax # RW-excl spins 604733, rounds 8107431, OS waits 241268 $results['spin_waits'][] = to_int($row[2]); $results['os_waits'][] = to_int($row[7]); } elseif (strpos($line, 'seconds the semaphore:') > 0) { # --Thread 907205 has waited at handler/ha_innodb.cc line 7156 for 1.00 seconds the semaphore: increment($results, 'innodb_sem_waits', 1); increment($results, 'innodb_sem_wait_time_ms', to_int($row[9]) * 1000); } # TRANSACTIONS elseif ( strpos($line, 'Trx id counter') === 0 ) { # The beginning of the TRANSACTIONS section: start counting # transactions # Trx id counter 0 1170664159 # Trx id counter 861B144C $results['innodb_transactions'] = make_bigint( $row[3], (isset($row[4]) ? $row[4] : null)); $txn_seen = TRUE; } elseif ( strpos($line, 'Purge done for trx') === 0 ) { # Purge done for trx's n:o < 0 1170663853 undo n:o < 0 0 # Purge done for trx's n:o < 861B135D undo n:o < 0 $purged_to = make_bigint($row[6], $row[7] == 'undo' ? null : $row[7]); $results['unpurged_txns'] = big_sub($results['innodb_transactions'], $purged_to); } elseif (strpos($line, 'History list length') === 0 ) { # History list length 132 $results['history_list'] = to_int($row[3]); } elseif ( $txn_seen && strpos($line, '---TRANSACTION') === 0 ) { # ---TRANSACTION 0, not started, process no 13510, OS thread id 1170446656 increment($results, 'current_transactions', 1); if ( strpos($line, 'ACTIVE') > 0 ) { increment($results, 'active_transactions', 1); } } elseif ( $txn_seen && strpos($line, '------- TRX HAS BEEN') === 0 ) { # ------- TRX HAS BEEN WAITING 32 SEC FOR THIS LOCK TO BE GRANTED: increment($results, 'innodb_lock_wait_secs', to_int($row[5])); } elseif ( strpos($line, 'read views open inside InnoDB') > 0 ) { # 1 read views open inside InnoDB $results['read_views'] = to_int($row[0]); } elseif ( strpos($line, 'mysql tables in use') === 0 ) { # mysql tables in use 2, locked 2 increment($results, 'innodb_tables_in_use', to_int($row[4])); increment($results, 'innodb_locked_tables', to_int($row[6])); } elseif ( $txn_seen && strpos($line, 'lock struct(s)') > 0 ) { # 23 lock struct(s), heap size 3024, undo log entries 27 # LOCK WAIT 12 lock struct(s), heap size 3024, undo log entries 5 # LOCK WAIT 2 lock struct(s), heap size 368 if ( strpos($line, 'LOCK WAIT') === 0 ) { increment($results, 'innodb_lock_structs', to_int($row[2])); increment($results, 'locked_transactions', 1); } else { increment($results, 'innodb_lock_structs', to_int($row[0])); } } # FILE I/O elseif (strpos($line, ' OS file reads, ') > 0 ) { # 8782182 OS file reads, 15635445 OS file writes, 947800 OS fsyncs $results['file_reads'] = to_int($row[0]); $results['file_writes'] = to_int($row[4]); $results['file_fsyncs'] = to_int($row[8]); } elseif (strpos($line, 'Pending normal aio reads:') === 0 ) { # Pending normal aio reads: 0, aio writes: 0, $results['pending_normal_aio_reads'] = to_int($row[4]); $results['pending_normal_aio_writes'] = to_int($row[7]); } elseif (strpos($line, 'ibuf aio reads') === 0 ) { # ibuf aio reads: 0, log i/o's: 0, sync i/o's: 0 $results['pending_ibuf_aio_reads'] = to_int($row[3]); $results['pending_aio_log_ios'] = to_int($row[6]); $results['pending_aio_sync_ios'] = to_int($row[9]); } elseif ( strpos($line, 'Pending flushes (fsync)') === 0 ) { # Pending flushes (fsync) log: 0; buffer pool: 0 $results['pending_log_flushes'] = to_int($row[4]); $results['pending_buf_pool_flushes'] = to_int($row[7]); } # INSERT BUFFER AND ADAPTIVE HASH INDEX elseif (strpos($line, 'Ibuf for space 0: size ') === 0 ) { # Older InnoDB code seemed to be ready for an ibuf per tablespace. It # had two lines in the output. Newer has just one line, see below. # Ibuf for space 0: size 1, free list len 887, seg size 889, is not empty # Ibuf for space 0: size 1, free list len 887, seg size 889, $results['ibuf_used_cells'] = to_int($row[5]); $results['ibuf_free_cells'] = to_int($row[9]); $results['ibuf_cell_count'] = to_int($row[12]); } elseif (strpos($line, 'Ibuf: size ') === 0 ) { # Ibuf: size 1, free list len 4634, seg size 4636, $results['ibuf_used_cells'] = to_int($row[2]); $results['ibuf_free_cells'] = to_int($row[6]); $results['ibuf_cell_count'] = to_int($row[9]); if (strpos($line, 'merges')) { $results['ibuf_merges'] = to_int($row[10]); } } elseif (strpos($line, ', delete mark ') > 0 && strpos($prev_line, 'merged operations:') === 0 ) { # Output of show engine innodb status has changed in 5.5 # merged operations: # insert 593983, delete mark 387006, delete 73092 $results['ibuf_inserts'] = to_int($row[1]); $results['ibuf_merged'] = to_int($row[1]) + to_int($row[4]) + to_int($row[6]); } elseif (strpos($line, ' merged recs, ') > 0 ) { # 19817685 inserts, 19817684 merged recs, 3552620 merges $results['ibuf_inserts'] = to_int($row[0]); $results['ibuf_merged'] = to_int($row[2]); $results['ibuf_merges'] = to_int($row[5]); } elseif (strpos($line, 'Hash table size ') === 0 ) { # In some versions of InnoDB, the used cells is omitted. # Hash table size 4425293, used cells 4229064, .... # Hash table size 57374437, node heap has 72964 buffer(s) <-- no used cells $results['hash_index_cells_total'] = to_int($row[3]); $results['hash_index_cells_used'] = strpos($line, 'used cells') > 0 ? to_int($row[6]) : '0'; } # LOG elseif (strpos($line, " log i/o's done, ") > 0 ) { # 3430041 log i/o's done, 17.44 log i/o's/second # 520835887 log i/o's done, 17.28 log i/o's/second, 518724686 syncs, 2980893 checkpoints # TODO: graph syncs and checkpoints $results['log_writes'] = to_int($row[0]); } elseif (strpos($line, " pending log writes, ") > 0 ) { # 0 pending log writes, 0 pending chkp writes $results['pending_log_writes'] = to_int($row[0]); $results['pending_chkp_writes'] = to_int($row[4]); } elseif (strpos($line, "Log sequence number") === 0 ) { # This number is NOT printed in hex in InnoDB plugin. # Log sequence number 13093949495856 //plugin # Log sequence number 125 3934414864 //normal $results['log_bytes_written'] = isset($row[4]) ? make_bigint($row[3], $row[4]) : to_int($row[3]); } elseif (strpos($line, "Log flushed up to") === 0 ) { # This number is NOT printed in hex in InnoDB plugin. # Log flushed up to 13093948219327 # Log flushed up to 125 3934414864 $results['log_bytes_flushed'] = isset($row[5]) ? make_bigint($row[4], $row[5]) : to_int($row[4]); } elseif (strpos($line, "Last checkpoint at") === 0 ) { # Last checkpoint at 125 3934293461 $results['last_checkpoint'] = isset($row[4]) ? make_bigint($row[3], $row[4]) : to_int($row[3]); } # BUFFER POOL AND MEMORY elseif (strpos($line, "Total memory allocated") === 0 && strpos($line, "in additional pool allocated") > 0 ) { # Total memory allocated 29642194944; in additional pool allocated 0 # Total memory allocated by read views 96 $results['total_mem_alloc'] = to_int($row[3]); $results['additional_pool_alloc'] = to_int($row[8]); } elseif(strpos($line, 'Adaptive hash index ') === 0 ) { # Adaptive hash index 1538240664 (186998824 + 1351241840) $results['adaptive_hash_memory'] = to_int($row[3]); } elseif(strpos($line, 'Page hash ') === 0 ) { # Page hash 11688584 $results['page_hash_memory'] = to_int($row[2]); } elseif(strpos($line, 'Dictionary cache ') === 0 ) { # Dictionary cache 145525560 (140250984 + 5274576) $results['dictionary_cache_memory'] = to_int($row[2]); } elseif(strpos($line, 'File system ') === 0 ) { # File system 313848 (82672 + 231176) $results['file_system_memory'] = to_int($row[2]); } elseif(strpos($line, 'Lock system ') === 0 ) { # Lock system 29232616 (29219368 + 13248) $results['lock_system_memory'] = to_int($row[2]); } elseif(strpos($line, 'Recovery system ') === 0 ) { # Recovery system 0 (0 + 0) $results['recovery_system_memory'] = to_int($row[2]); } elseif(strpos($line, 'Threads ') === 0 ) { # Threads 409336 (406936 + 2400) $results['thread_hash_memory'] = to_int($row[1]); } elseif(strpos($line, 'innodb_io_pattern ') === 0 ) { # innodb_io_pattern 0 (0 + 0) $results['innodb_io_pattern_memory'] = to_int($row[1]); } elseif (strpos($line, "Buffer pool size ") === 0 ) { # The " " after size is necessary to avoid matching the wrong line: # Buffer pool size 1769471 # Buffer pool size, bytes 28991012864 $results['pool_size'] = to_int($row[3]); } elseif (strpos($line, "Free buffers") === 0 ) { # Free buffers 0 $results['free_pages'] = to_int($row[2]); } elseif (strpos($line, "Database pages") === 0 ) { # Database pages 1696503 $results['database_pages'] = to_int($row[2]); } elseif (strpos($line, "Modified db pages") === 0 ) { # Modified db pages 160602 $results['modified_pages'] = to_int($row[3]); } elseif (strpos($line, "Pages read ahead") === 0 ) { # Must do this BEFORE the next test, otherwise it'll get fooled by this # line from the new plugin (see samples/innodb-015.txt): # Pages read ahead 0.00/s, evicted without access 0.06/s # TODO: No-op for now, see issue 134. } elseif (strpos($line, "Pages read") === 0 ) { # Pages read 15240822, created 1770238, written 21705836 $results['pages_read'] = to_int($row[2]); $results['pages_created'] = to_int($row[4]); $results['pages_written'] = to_int($row[6]); } # ROW OPERATIONS elseif (strpos($line, 'Number of rows inserted') === 0 ) { # Number of rows inserted 50678311, updated 66425915, deleted 20605903, read 454561562 $results['rows_inserted'] = to_int($row[4]); $results['rows_updated'] = to_int($row[6]); $results['rows_deleted'] = to_int($row[8]); $results['rows_read'] = to_int($row[10]); } elseif (strpos($line, " queries inside InnoDB, ") > 0 ) { # 0 queries inside InnoDB, 0 queries in queue $results['queries_inside'] = to_int($row[0]); $results['queries_queued'] = to_int($row[4]); } $prev_line = $line; } foreach ( array('spin_waits', 'spin_rounds', 'os_waits') as $key ) { $results[$key] = to_int(array_sum($results[$key])); } $results['unflushed_log'] = big_sub($results['log_bytes_written'], $results['log_bytes_flushed']); $results['uncheckpointed_bytes'] = big_sub($results['log_bytes_written'], $results['last_checkpoint']); return $results; } # ============================================================================ # Returns a bigint from two ulint or a single hex number. This is tested in # t/mysql_stats.php and copied, without tests, to ss_get_by_ssh.php. # ============================================================================ function make_bigint ($hi, $lo = null) { debug(array($hi, $lo)); if ( is_null($lo) ) { # Assume it is a hex string representation. return base_convert($hi, 16, 10); } else { $hi = $hi ? $hi : '0'; # Handle empty-string or whatnot $lo = $lo ? $lo : '0'; return big_add(big_multiply($hi, 4294967296), $lo); } } # ============================================================================ # Extracts the numbers from a string. You can't reliably do this by casting to # an int, because numbers that are bigger than PHP's int (varies by platform) # will be truncated. And you can't use sprintf(%u) either, because the maximum # value that will return on some platforms is 4022289582. So this just handles # them as a string instead. It extracts digits until it finds a non-digit and # quits. This is tested in t/mysql_stats.php and copied, without tests, to # ss_get_by_ssh.php. # ============================================================================ function to_int ( $str ) { debug($str); global $debug; preg_match('{(\d+)}', $str, $m); if ( isset($m[1]) ) { return $m[1]; } elseif ( $debug ) { print_r(debug_backtrace()); } else { return 0; } } # ============================================================================ # Wrap mysqli_query in error-handling, and instead of returning the result, # return an array of arrays in the result. # ============================================================================ function run_query($sql, $conn) { global $debug; debug($sql); $result = @mysqli_query($conn, $sql); if ( $debug ) { $error = @mysqli_error($conn); if ( $error ) { debug(array($sql, $error)); die("SQLERR $error in $sql"); } } $array = array(); $count = @mysqli_num_rows($result); if ( $count > 10000 ) { debug('Abnormal number of rows returned: ' . $count); } else { while ( $row = @mysqli_fetch_array($result) ) { $array[] = $row; } } debug(array($sql, $array)); return $array; } # ============================================================================ # Safely increments a value that might be null. # ============================================================================ function increment(&$arr, $key, $howmuch) { debug(array($key, $howmuch)); if ( array_key_exists($key, $arr) && isset($arr[$key]) ) { $arr[$key] = big_add($arr[$key], $howmuch); } else { $arr[$key] = $howmuch; } } # ============================================================================ # Multiply two big integers together as accurately as possible with reasonable # effort. This is tested in t/mysql_stats.php and copied, without tests, to # ss_get_by_ssh.php. $force is for testability. # ============================================================================ function big_multiply ($left, $right, $force = null) { if ( function_exists("gmp_mul") && (is_null($force) || $force == 'gmp') ) { debug(array('gmp_mul', $left, $right)); return gmp_strval( gmp_mul( $left, $right )); } elseif ( function_exists("bcmul") && (is_null($force) || $force == 'bc') ) { debug(array('bcmul', $left, $right)); return bcmul( $left, $right ); } else { # Or $force == 'something else' debug(array('sprintf', $left, $right)); return sprintf("%.0f", $left * $right); } } # ============================================================================ # Subtract two big integers as accurately as possible with reasonable effort. # This is tested in t/mysql_stats.php and copied, without tests, to # ss_get_by_ssh.php. $force is for testability. # ============================================================================ function big_sub ($left, $right, $force = null) { debug(array($left, $right)); if ( is_null($left) ) { $left = 0; } if ( is_null($right) ) { $right = 0; } if ( function_exists("gmp_sub") && (is_null($force) || $force == 'gmp')) { debug(array('gmp_sub', $left, $right)); return gmp_strval( gmp_sub( $left, $right )); } elseif ( function_exists("bcsub") && (is_null($force) || $force == 'bc')) { debug(array('bcsub', $left, $right)); return bcsub( $left, $right ); } else { # Or $force == 'something else' debug(array('to_int', $left, $right)); return to_int($left - $right); } } # ============================================================================ # Add two big integers together as accurately as possible with reasonable # effort. This is tested in t/mysql_stats.php and copied, without tests, to # ss_get_by_ssh.php. $force is for testability. # ============================================================================ function big_add ($left, $right, $force = null) { if ( is_null($left) ) { $left = 0; } if ( is_null($right) ) { $right = 0; } if ( function_exists("gmp_add") && (is_null($force) || $force == 'gmp')) { debug(array('gmp_add', $left, $right)); return gmp_strval( gmp_add( $left, $right )); } elseif ( function_exists("bcadd") && (is_null($force) || $force == 'bc')) { debug(array('bcadd', $left, $right)); return bcadd( $left, $right ); } else { # Or $force == 'something else' debug(array('to_int', $left, $right)); return to_int($left + $right); } } # ============================================================================ # Writes to a debugging log. # ============================================================================ function debug($val) { global $debug_log; if ( !$debug_log ) { return; } if ( $fp = fopen($debug_log, 'a+') ) { $trace = debug_backtrace(); $calls = array(); $i = 0; $line = 0; $file = ''; foreach ( debug_backtrace() as $arr ) { if ( $i++ ) { $calls[] = "$arr[function]() at $file:$line"; } $line = array_key_exists('line', $arr) ? $arr['line'] : '?'; $file = array_key_exists('file', $arr) ? $arr['file'] : '?'; } if ( !count($calls) ) { $calls[] = "at $file:$line"; } fwrite($fp, date('Y-m-d H:i:s') . ' ' . implode(' <- ', $calls)); fwrite($fp, "\n" . var_export($val, TRUE) . "\n"); fclose($fp); } else { # Disable logging print("Warning: disabling debug logging to $debug_log\n"); $debug_log = FALSE; } } ?> 3. Crear archivo de config del agente Zabbix: sudo vim /etc/zabbix/zabbix_agentd.conf.d/zabbix_mysql.conf Con el siguiente contenido: # Copyright 2010 (c) Brian Smith and PalominoDB. # Feedback and improvements are welcome. # # THIS PROGRAM IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED # WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF # MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. # # This program is free software; you can redistribute it and/or modify it under # the terms of the GNU General Public License as published by the Free Software # Foundation, version 2. # # You should have received a copy of the GNU General Public License along with # this program; if not, write to the Free Software Foundation, Inc., 59 Temple # Place, Suite 330, Boston, MA02111-1307USA. UserParameter=mysql.Key_read_requests,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items gg | awk -F: '{ print $2 }' UserParameter=mysql.Key_reads,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items gh | awk -F: '{ print $2 }' UserParameter=mysql.Key_write_requests,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items gi | awk -F: '{ print $2 }' UserParameter=mysql.Key_writes,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items gj | awk -F: '{ print $2 }' UserParameter=mysql.history_list,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items gk | awk -F: '{ print $2 }' UserParameter=mysql.innodb_transactions,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items gl | awk -F: '{ print $2 }' UserParameter=mysql.read_views,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items gm | awk -F: '{ print $2 }' UserParameter=mysql.current_transactions,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items gn | awk -F: '{ print $2 }' UserParameter=mysql.locked_transactions,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items go | awk -F: '{ print $2 }' UserParameter=mysql.active_transactions,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items gp | awk -F: '{ print $2 }' UserParameter=mysql.pool_size,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items gq | awk -F: '{ print $2 }' UserParameter=mysql.free_pages,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items gr | awk -F: '{ print $2 }' UserParameter=mysql.database_pages,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items gs | awk -F: '{ print $2 }' UserParameter=mysql.modified_pages,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items gt | awk -F: '{ print $2 }' UserParameter=mysql.pages_read,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items gu | awk -F: '{ print $2 }' UserParameter=mysql.pages_created,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items gv | awk -F: '{ print $2 }' UserParameter=mysql.pages_written,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items gw | awk -F: '{ print $2 }' UserParameter=mysql.file_fsyncs,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items gx | awk -F: '{ print $2 }' UserParameter=mysql.file_reads,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items gy | awk -F: '{ print $2 }' UserParameter=mysql.file_writes,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items gz | awk -F: '{ print $2 }' UserParameter=mysql.log_writes,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items hg | awk -F: '{ print $2 }' UserParameter=mysql.pending_aio_log_ios,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items hh | awk -F: '{ print $2 }' UserParameter=mysql.pending_aio_sync_ios,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items hi | awk -F: '{ print $2 }' UserParameter=mysql.pending_buf_pool_flushes,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items hj | awk -F: '{ print $2 }' UserParameter=mysql.pending_chkp_writes,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items hk | awk -F: '{ print $2 }' UserParameter=mysql.pending_ibuf_aio_reads,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items hl | awk -F: '{ print $2 }' UserParameter=mysql.pending_log_flushes,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items hm | awk -F: '{ print $2 }' UserParameter=mysql.pending_log_writes,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items hn | awk -F: '{ print $2 }' UserParameter=mysql.pending_normal_aio_reads,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items ho | awk -F: '{ print $2 }' UserParameter=mysql.pending_normal_aio_writes,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items hp | awk -F: '{ print $2 }' UserParameter=mysql.ibuf_inserts,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items hq | awk -F: '{ print $2 }' UserParameter=mysql.ibuf_merged,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items hr | awk -F: '{ print $2 }' UserParameter=mysql.ibuf_merges,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items hs | awk -F: '{ print $2 }' UserParameter=mysql.spin_waits,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items ht | awk -F: '{ print $2 }' UserParameter=mysql.spin_rounds,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items hu | awk -F: '{ print $2 }' UserParameter=mysql.os_waits,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items hv | awk -F: '{ print $2 }' UserParameter=mysql.rows_inserted,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items hw | awk -F: '{ print $2 }' UserParameter=mysql.rows_updated,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items hx | awk -F: '{ print $2 }' UserParameter=mysql.rows_deleted,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items hy | awk -F: '{ print $2 }' UserParameter=mysql.rows_read,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items hz | awk -F: '{ print $2 }' UserParameter=mysql.Table_locks_waited,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items ig | awk -F: '{ print $2 }' UserParameter=mysql.Table_locks_immediate,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items ih | awk -F: '{ print $2 }' UserParameter=mysql.Slow_queries,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items ii | awk -F: '{ print $2 }' UserParameter=mysql.Open_files,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items ij | awk -F: '{ print $2 }' UserParameter=mysql.Open_tables,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items ik | awk -F: '{ print $2 }' UserParameter=mysql.Opened_tables,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items il | awk -F: '{ print $2 }' UserParameter=mysql.innodb_open_files,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items im | awk -F: '{ print $2 }' UserParameter=mysql.open_files_limit,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items in | awk -F: '{ print $2 }' UserParameter=mysql.table_cache,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items io | awk -F: '{ print $2 }' UserParameter=mysql.Aborted_clients,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items ip | awk -F: '{ print $2 }' UserParameter=mysql.Aborted_connects,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items iq | awk -F: '{ print $2 }' UserParameter=mysql.Max_used_connections,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items ir | awk -F: '{ print $2 }' UserParameter=mysql.Slow_launch_threads,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items is | awk -F: '{ print $2 }' UserParameter=mysql.Threads_cached,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items it | awk -F: '{ print $2 }' UserParameter=mysql.Threads_connected,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items iu | awk -F: '{ print $2 }' UserParameter=mysql.Threads_created,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items iv | awk -F: '{ print $2 }' UserParameter=mysql.Threads_running,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items iw | awk -F: '{ print $2 }' UserParameter=mysql.max_connections,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items ix | awk -F: '{ print $2 }' UserParameter=mysql.thread_cache_size,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items iy | awk -F: '{ print $2 }' UserParameter=mysql.Connections,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items iz | awk -F: '{ print $2 }' UserParameter=mysql.slave_running,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items jg | awk -F: '{ print $2 }' UserParameter=mysql.slave_stopped,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items jh | awk -F: '{ print $2 }' UserParameter=mysql.Slave_retried_transactions,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items ji | awk -F: '{ print $2 }' UserParameter=mysql.slave_lag,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items jj | awk -F: '{ print $2 }' UserParameter=mysql.Slave_open_temp_tables,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items jk | awk -F: '{ print $2 }' UserParameter=mysql.Qcache_free_blocks,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items jl | awk -F: '{ print $2 }' UserParameter=mysql.Qcache_free_memory,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items jm | awk -F: '{ print $2 }' UserParameter=mysql.Qcache_hits,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items jn | awk -F: '{ print $2 }' UserParameter=mysql.Qcache_inserts,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items jo | awk -F: '{ print $2 }' UserParameter=mysql.Qcache_lowmem_prunes,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items jp | awk -F: '{ print $2 }' UserParameter=mysql.Qcache_not_cached,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items jq | awk -F: '{ print $2 }' UserParameter=mysql.Qcache_queries_in_cache,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items jr | awk -F: '{ print $2 }' UserParameter=mysql.Qcache_total_blocks,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items js | awk -F: '{ print $2 }' UserParameter=mysql.query_cache_size,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items jt | awk -F: '{ print $2 }' UserParameter=mysql.Questions,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items ju | awk -F: '{ print $2 }' UserParameter=mysql.Com_update,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items jv | awk -F: '{ print $2 }' UserParameter=mysql.Com_insert,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items jw | awk -F: '{ print $2 }' UserParameter=mysql.Com_select,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items jx | awk -F: '{ print $2 }' UserParameter=mysql.Com_delete,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items jy | awk -F: '{ print $2 }' UserParameter=mysql.Com_replace,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items jz | awk -F: '{ print $2 }' UserParameter=mysql.Com_load,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items kg | awk -F: '{ print $2 }' UserParameter=mysql.Com_update_multi,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items kh | awk -F: '{ print $2 }' UserParameter=mysql.Com_insert_select,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items ki | awk -F: '{ print $2 }' UserParameter=mysql.Com_delete_multi,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items kj | awk -F: '{ print $2 }' UserParameter=mysql.Com_replace_select,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items kk | awk -F: '{ print $2 }' UserParameter=mysql.Select_full_join,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items kl | awk -F: '{ print $2 }' UserParameter=mysql.Select_full_range_join,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items km | awk -F: '{ print $2 }' UserParameter=mysql.Select_range,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items kn | awk -F: '{ print $2 }' UserParameter=mysql.Select_range_check,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items ko | awk -F: '{ print $2 }' UserParameter=mysql.Select_scan,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items kp | awk -F: '{ print $2 }' UserParameter=mysql.Sort_merge_passes,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items kq | awk -F: '{ print $2 }' UserParameter=mysql.Sort_range,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items kr | awk -F: '{ print $2 }' UserParameter=mysql.Sort_rows,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items ks | awk -F: '{ print $2 }' UserParameter=mysql.Sort_scan,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items kt | awk -F: '{ print $2 }' UserParameter=mysql.Created_tmp_tables,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items ku | awk -F: '{ print $2 }' UserParameter=mysql.Created_tmp_disk_tables,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items kv | awk -F: '{ print $2 }' UserParameter=mysql.Created_tmp_files,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items kw | awk -F: '{ print $2 }' UserParameter=mysql.Bytes_sent,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items kx | awk -F: '{ print $2 }' UserParameter=mysql.Bytes_received,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items ky | awk -F: '{ print $2 }' UserParameter=mysql.innodb_log_buffer_size,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items kz | awk -F: '{ print $2 }' UserParameter=mysql.unflushed_log,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items lg | awk -F: '{ print $2 }' UserParameter=mysql.log_bytes_flushed,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items lh | awk -F: '{ print $2 }' UserParameter=mysql.log_bytes_written,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items li | awk -F: '{ print $2 }' UserParameter=mysql.relay_log_space,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items lj | awk -F: '{ print $2 }' UserParameter=mysql.binlog_cache_size,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items lk | awk -F: '{ print $2 }' UserParameter=mysql.Binlog_cache_disk_use,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items ll | awk -F: '{ print $2 }' UserParameter=mysql.Binlog_cache_use,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items lm | awk -F: '{ print $2 }' UserParameter=mysql.binary_log_space,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items ln | awk -F: '{ print $2 }' UserParameter=mysql.innodb_locked_tables,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items lo | awk -F: '{ print $2 }' UserParameter=mysql.innodb_lock_structs,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items lp | awk -F: '{ print $2 }' UserParameter=mysql.State_closing_tables,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items lq | awk -F: '{ print $2 }' UserParameter=mysql.State_copying_to_tmp_table,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items lr | awk -F: '{ print $2 }' UserParameter=mysql.State_end,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items ls | awk -F: '{ print $2 }' UserParameter=mysql.State_freeing_items,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items lt | awk -F: '{ print $2 }' UserParameter=mysql.State_init,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items lu | awk -F: '{ print $2 }' UserParameter=mysql.State_locked,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items lv | awk -F: '{ print $2 }' UserParameter=mysql.State_login,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items lw | awk -F: '{ print $2 }' UserParameter=mysql.State_preparing,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items lx | awk -F: '{ print $2 }' UserParameter=mysql.State_reading_from_net,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items ly | awk -F: '{ print $2 }' UserParameter=mysql.State_sending_data,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items lz | awk -F: '{ print $2 }' UserParameter=mysql.State_sorting_result,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items mg | awk -F: '{ print $2 }' UserParameter=mysql.State_statistics,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items mh | awk -F: '{ print $2 }' UserParameter=mysql.State_updating,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items mi | awk -F: '{ print $2 }' UserParameter=mysql.State_writing_to_net,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items mj | awk -F: '{ print $2 }' UserParameter=mysql.State_none,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items mk | awk -F: '{ print $2 }' UserParameter=mysql.State_other,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items ml | awk -F: '{ print $2 }' UserParameter=mysql.Handler_commit,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items mm | awk -F: '{ print $2 }' UserParameter=mysql.Handler_delete,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items mn | awk -F: '{ print $2 }' UserParameter=mysql.Handler_discover,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items mo | awk -F: '{ print $2 }' UserParameter=mysql.Handler_prepare,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items mp | awk -F: '{ print $2 }' UserParameter=mysql.Handler_read_first,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items mq | awk -F: '{ print $2 }' UserParameter=mysql.Handler_read_key,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items mr | awk -F: '{ print $2 }' UserParameter=mysql.Handler_read_next,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items ms | awk -F: '{ print $2 }' UserParameter=mysql.Handler_read_prev,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items mt | awk -F: '{ print $2 }' UserParameter=mysql.Handler_read_rnd,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items mu | awk -F: '{ print $2 }' UserParameter=mysql.Handler_read_rnd_next,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items mv | awk -F: '{ print $2 }' UserParameter=mysql.Handler_rollback,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items mw | awk -F: '{ print $2 }' UserParameter=mysql.Handler_savepoint,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items mx | awk -F: '{ print $2 }' UserParameter=mysql.Handler_savepoint_rollback,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items my | awk -F: '{ print $2 }' UserParameter=mysql.Handler_update,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items mz | awk -F: '{ print $2 }' UserParameter=mysql.Handler_write,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items ng | awk -F: '{ print $2 }' UserParameter=mysql.innodb_tables_in_use,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items nh | awk -F: '{ print $2 }' UserParameter=mysql.innodb_lock_wait_secs,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items ni | awk -F: '{ print $2 }' UserParameter=mysql.hash_index_cells_total,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items nj | awk -F: '{ print $2 }' UserParameter=mysql.hash_index_cells_used,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items nk | awk -F: '{ print $2 }' UserParameter=mysql.total_mem_alloc,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items nl | awk -F: '{ print $2 }' UserParameter=mysql.additional_pool_alloc,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items nm | awk -F: '{ print $2 }' UserParameter=mysql.uncheckpointed_bytes,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items nn | awk -F: '{ print $2 }' UserParameter=mysql.ibuf_used_cells,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items no | awk -F: '{ print $2 }' UserParameter=mysql.ibuf_free_cells,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items np | awk -F: '{ print $2 }' UserParameter=mysql.ibuf_cell_count,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items nq | awk -F: '{ print $2 }' UserParameter=mysql.adaptive_hash_memory,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items nr | awk -F: '{ print $2 }' UserParameter=mysql.page_hash_memory,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items ns | awk -F: '{ print $2 }' UserParameter=mysql.dictionary_cache_memory,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items nt | awk -F: '{ print $2 }' UserParameter=mysql.file_system_memory,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items nu | awk -F: '{ print $2 }' UserParameter=mysql.lock_system_memory,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items nv | awk -F: '{ print $2 }' UserParameter=mysql.recovery_system_memory,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items nw | awk -F: '{ print $2 }' UserParameter=mysql.thread_hash_memory,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items nx | awk -F: '{ print $2 }' UserParameter=mysql.innodb_sem_waits,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items ny | awk -F: '{ print $2 }' UserParameter=mysql.innodb_sem_wait_time_ms,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items nz | awk -F: '{ print $2 }' UserParameter=mysql.Key_buf_bytes_unflushed,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items og | awk -F: '{ print $2 }' UserParameter=mysql.Key_buf_bytes_used,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items oh | awk -F: '{ print $2 }' UserParameter=mysql.key_buffer_size,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items oi | awk -F: '{ print $2 }' UserParameter=mysql.Innodb_row_lock_time,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items oj | awk -F: '{ print $2 }' UserParameter=mysql.Innodb_row_lock_waits,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items ok | awk -F: '{ print $2 }' UserParameter=mysql.Query_time_count_00,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items ol | awk -F: '{ print $2 }' UserParameter=mysql.Query_time_count_01,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items om | awk -F: '{ print $2 }' UserParameter=mysql.Query_time_count_02,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items on | awk -F: '{ print $2 }' UserParameter=mysql.Query_time_count_03,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items oo | awk -F: '{ print $2 }' UserParameter=mysql.Query_time_count_04,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items op | awk -F: '{ print $2 }' UserParameter=mysql.Query_time_count_05,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items oq | awk -F: '{ print $2 }' UserParameter=mysql.Query_time_count_06,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items or | awk -F: '{ print $2 }' UserParameter=mysql.Query_time_count_07,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items os | awk -F: '{ print $2 }' UserParameter=mysql.Query_time_count_08,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items ot | awk -F: '{ print $2 }' UserParameter=mysql.Query_time_count_09,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items ou | awk -F: '{ print $2 }' UserParameter=mysql.Query_time_count_10,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items ov | awk -F: '{ print $2 }' UserParameter=mysql.Query_time_count_11,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items ow | awk -F: '{ print $2 }' UserParameter=mysql.Query_time_count_12,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items ox | awk -F: '{ print $2 }' UserParameter=mysql.Query_time_count_13,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items oy | awk -F: '{ print $2 }' UserParameter=mysql.Query_time_total_00,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items oz | awk -F: '{ print $2 }' UserParameter=mysql.Query_time_total_01,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items pg | awk -F: '{ print $2 }' UserParameter=mysql.Query_time_total_02,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items ph | awk -F: '{ print $2 }' UserParameter=mysql.Query_time_total_03,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items pi | awk -F: '{ print $2 }' UserParameter=mysql.Query_time_total_04,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items pj | awk -F: '{ print $2 }' UserParameter=mysql.Query_time_total_05,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items pk | awk -F: '{ print $2 }' UserParameter=mysql.Query_time_total_06,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items pl | awk -F: '{ print $2 }' UserParameter=mysql.Query_time_total_07,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items pm | awk -F: '{ print $2 }' UserParameter=mysql.Query_time_total_08,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items pn | awk -F: '{ print $2 }' UserParameter=mysql.Query_time_total_09,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items po | awk -F: '{ print $2 }' UserParameter=mysql.Query_time_total_10,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items pp | awk -F: '{ print $2 }' UserParameter=mysql.Query_time_total_11,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items pq | awk -F: '{ print $2 }' UserParameter=mysql.Query_time_total_12,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items pr | awk -F: '{ print $2 }' UserParameter=mysql.Query_time_total_13,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items ps | awk -F: '{ print $2 }' UserParameter=mysql.wsrep_replicated_bytes,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items pt | awk -F: '{ print $2 }' UserParameter=mysql.wsrep_received_bytes,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items pu | awk -F: '{ print $2 }' UserParameter=mysql.wsrep_replicated,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items pv | awk -F: '{ print $2 }' UserParameter=mysql.wsrep_received,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items pw | awk -F: '{ print $2 }' UserParameter=mysql.wsrep_local_cert_failures,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items px | awk -F: '{ print $2 }' UserParameter=mysql.wsrep_local_bf_aborts,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items py | awk -F: '{ print $2 }' UserParameter=mysql.wsrep_local_send_queue,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items pz | awk -F: '{ print $2 }' UserParameter=mysql.wsrep_local_recv_queue,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items qg | awk -F: '{ print $2 }' UserParameter=mysql.wsrep_cluster_size,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items qh | awk -F: '{ print $2 }' UserParameter=mysql.wsrep_cert_deps_distance,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items qi | awk -F: '{ print $2 }' UserParameter=mysql.wsrep_apply_window,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items qj | awk -F: '{ print $2 }' UserParameter=mysql.wsrep_commit_window,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items qk | awk -F: '{ print $2 }' UserParameter=mysql.wsrep_flow_control_paused,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items ql | awk -F: '{ print $2 }' UserParameter=mysql.wsrep_flow_control_sent,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items qm | awk -F: '{ print $2 }' UserParameter=mysql.wsrep_flow_control_recv,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items qn | awk -F: '{ print $2 }' UserParameter=mysql.pool_reads,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items qo | awk -F: '{ print $2 }' UserParameter=mysql.pool_read_requests,/usr/bin/php /usr/local/zabbix/plugins/ss_get_mysql_stats.php --host localhost --items qp', 3. Ajustar valores del archivo de configuracion del agente zabbix: sudo vim /etc/zabbix/zabbix_agentd.conf Server=zabbix.example.com Hostname=mysql.example.com 4. Crear un usuario mysql con permisos para mostrar procesos con las mismas credenciales que en el paso 2: mysql -u root -p GRANT PROCESS ON *.* TO 'zabbix'@'localhost' identified BY 'some_password'; 5. Probar: zabbix_agentd -t mysql.Sort_scan Valor esperado similar a: mysql.Sort_scan [t|13] 6. Subir al servidor zabbix el template Mysql: 2.0 2015-03-18T11:03:34Z Templates {Template_MySQL:mysql.innodb_lock_structs.delta(300)}>30 InnoDB lock structures more than 30 in 5m on {HOSTNAME} 0 3 0 Process mysqld not running on {HOSTNAME} {Template_MySQL:proc.num[mysqld].last(0)}=0 {Template_MySQL:mysql.uncheckpointed_bytes.delta(600)}>25M InnoDB uncheckpointed bytes in the last 10m > 25MB on {HOSTNAME} 0 3 0 Process mysqld not running on {HOSTNAME} {Template_MySQL:proc.num[mysqld].last(0)}=0 {Template_MySQL:mysql.Threads_connected.last(0)}>500 More than 500 threads on {HOSTNAME} 0 3 0 Process mysqld not running on {HOSTNAME} {Template_MySQL:proc.num[mysqld].last(0)}=0 {Template_MySQL:proc.num[mysqld].last(0)}=0 Process mysqld not running on {HOSTNAME} 0 5 0 {Template_MySQL:mysql.Table_locks_waited.delta(300)}>10 Server {HOSTNAME} is waiting on table locks 0 3 0 Process mysqld not running on {HOSTNAME} {Template_MySQL:proc.num[mysqld].last(0)}=0 {Template_MySQL:mysql.slave_stopped.last(0)}<>0 Slave is stopped on {HOSTNAME} 0 4 0 Process mysqld not running on {HOSTNAME} {Template_MySQL:proc.num[mysqld].last(0)}=0 {Template_MySQL:mysql.slave_lag.avg(600)}>300 Slave lag more than 5m over 10m on {HOSTNAME} 0 3 0 Process mysqld not running on {HOSTNAME} {Template_MySQL:proc.num[mysqld].last(0)}=0 Slave lag more than 10m over 10m on {HOSTNAME} {Template_MySQL:mysql.slave_lag.avg(600)}>600 {Template_MySQL:mysql.slave_lag.avg(600)}>600 Slave lag more than 10m over 10m on {HOSTNAME} 0 4 0 Process mysqld not running on {HOSTNAME} {Template_MySQL:proc.num[mysqld].last(0)}=0 ({TRIGGER.VALUE}=0 and {Template_MySQL:mysql.State_copying_to_tmp_table.count(360,1,"ge")}>2) or ({TRIGGER.VALUE}=1 and {Template_MySQL:mysql.State_copying_to_tmp_table.count(360,1,"ge")}>0) Thread in state Copying_to_tmp_table for more than 6min on {HOSTNAME} 0 3 0 InnoDB Active/Locked Transactions 800 150 0.0000 100.0000 1 1 0 1 0 0.0000 0.0000 0 0 0 0 0 1 C0C0C0 1 2 0 Template_MySQL mysql.active_transactions 0 0 FF0000 1 2 0 Template_MySQL mysql.locked_transactions InnoDB Adaptive Hash Index 800 150 0.0000 100.0000 1 1 0 1 0 0.0000 0.0000 0 0 0 0 0 1 0C4E5D 1 2 0 Template_MySQL mysql.hash_index_cells_total 0 1 D9C7A3 1 2 0 Template_MySQL mysql.hash_index_cells_used InnoDB Buffer Pool 800 150 0.0000 100.0000 1 1 0 1 0 0.0000 0.0000 0 0 0 0 0 1 3D1500 1 2 0 Template_MySQL mysql.setting.pool_size 0 1 EDAA41 1 2 0 Template_MySQL mysql.database_pages 0 5 AA3B27 1 2 0 Template_MySQL mysql.free_pages 0 0 13343B 1 2 0 Template_MySQL mysql.modified_pages InnoDB Buffer Pool Activity 800 150 0.0000 100.0000 1 1 0 1 0 0.0000 0.0000 0 0 0 0 0 1 D6883A 1 2 0 Template_MySQL mysql.pages_created 0 5 E6D883 1 2 0 Template_MySQL mysql.pages_read 0 1 55AD84 1 2 0 Template_MySQL mysql.pages_written InnoDB Checkpoint Age 800 150 0.0000 100.0000 1 1 0 1 0 0.0000 0.0000 0 0 0 0 0 0 661100 1 2 0 Template_MySQL mysql.uncheckpointed_bytes InnoDB Current Lock Waits 800 150 0.0000 100.0000 1 1 0 1 0 0.0000 0.0000 0 0 0 0 0 0 201A33 1 2 0 Template_MySQL mysql.innodb_lock_wait_secs InnoDB I/O 800 150 0.0000 100.0000 1 1 0 1 0 0.0000 0.0000 0 0 0 0 0 0 402204 1 2 0 Template_MySQL mysql.file_reads 0 0 B3092B 1 2 0 Template_MySQL mysql.file_writes 0 0 FFBF00 1 2 0 Template_MySQL mysql.log_writes 0 0 0ABFCC 1 2 0 Template_MySQL mysql.file_fsyncs InnoDB I/O Pending 800 150 0.0000 100.0000 1 1 0 1 0 0.0000 0.0000 0 0 0 0 0 0 FF0000 1 2 0 Template_MySQL mysql.pending_aio_log_ios 0 0 FF7D00 1 2 0 Template_MySQL mysql.pending_aio_sync_ios 0 0 FFF200 1 2 0 Template_MySQL mysql.pending_buf_pool_flushes 0 0 00A348 1 2 0 Template_MySQL mysql.pending_chkp_writes 0 0 6DC8FE 1 2 0 Template_MySQL mysql.pending_ibuf_aio_reads 0 0 4444FF 1 2 0 Template_MySQL mysql.pending_log_flushes 0 0 55009D 1 2 0 Template_MySQL mysql.pending_log_writes 0 0 B90054 1 2 0 Template_MySQL mysql.pending_normal_aio_reads 0 0 8F9286 1 2 0 Template_MySQL mysql.pending_normal_aio_writes InnoDB Insert Buffer 800 150 0.0000 100.0000 1 1 0 1 0 0.0000 0.0000 0 0 0 0 0 0 157419 1 2 0 Template_MySQL mysql.ibuf_inserts 0 0 0000FF 1 2 0 Template_MySQL mysql.ibuf_merged 0 0 862F2F 1 2 0 Template_MySQL mysql.ibuf_merges InnoDB Insert Buffer Usage 800 150 0.0000 100.0000 1 1 0 1 0 0.0000 0.0000 0 0 0 0 0 1 793A57 1 2 0 Template_MySQL mysql.ibuf_cell_count 0 1 8C873E 1 2 0 Template_MySQL mysql.ibuf_used_cells 0 5 A38A5F 1 2 0 Template_MySQL mysql.ibuf_free_cells InnoDB Internal Hash Memory Usage 800 150 0.0000 100.0000 1 1 0 1 0 0.0000 0.0000 0 0 0 0 0 1 793A57 1 2 0 Template_MySQL mysql.adaptive_hash_memory 0 5 8C873E 1 2 0 Template_MySQL mysql.page_hash_memory 0 5 D1C5A5 1 2 0 Template_MySQL mysql.dictionary_cache_memory 0 5 4D3339 1 2 0 Template_MySQL mysql.file_system_memory 0 5 A38A5F 1 2 0 Template_MySQL mysql.lock_system_memory 0 5 E97F02 1 2 0 Template_MySQL mysql.recovery_system_memory 0 5 23B0BA 1 2 0 Template_MySQL mysql.thread_hash_memory InnoDB Lock Structures 800 150 0.0000 100.0000 1 1 0 1 0 0.0000 0.0000 0 0 0 0 0 0 0C4E5D 1 2 0 Template_MySQL mysql.innodb_lock_structs InnoDB Log 800 150 0.0000 100.0000 1 1 0 1 0 0.0000 0.0000 0 0 0 0 0 1 6E3803 1 2 0 Template_MySQL mysql.innodb_log_buffer_size 0 1 5B8257 1 2 0 Template_MySQL mysql.log_bytes_written 0 0 AB4253 1 2 0 Template_MySQL mysql.log_bytes_flushed 0 1 AFECED 1 2 0 Template_MySQL mysql.unflushed_log InnoDB Memory Allocation 800 150 0.0000 100.0000 1 1 0 1 0 0.0000 0.0000 0 0 0 0 0 1 53777A 1 2 0 Template_MySQL mysql.total_mem_alloc 0 0 C02942 1 2 0 Template_MySQL mysql.additional_pool_alloc InnoDB Row Lock Time 800 150 0.0000 100.0000 1 1 0 1 0 0.0000 0.0000 0 0 0 0 0 1 B11D03 1 2 0 Template_MySQL mysql.Innodb_row_lock_time InnoDB Row Lock Waits 800 150 0.0000 100.0000 1 1 0 1 0 0.0000 0.0000 0 0 0 0 0 1 E84A5F 1 2 0 Template_MySQL mysql.Innodb_row_lock_waits InnoDB Row Operations 800 150 0.0000 100.0000 1 1 0 1 0 0.0000 0.0000 0 0 0 0 0 1 AFECED 1 2 0 Template_MySQL mysql.rows_read 0 5 DA4725 1 2 0 Template_MySQL mysql.rows_deleted 0 5 EA8F00 1 2 0 Template_MySQL mysql.rows_updated 0 5 35962B 1 2 0 Template_MySQL mysql.rows_inserted InnoDB Semaphores 800 150 0.0000 100.0000 1 1 0 1 0 0.0000 0.0000 0 0 0 0 0 0 306078 1 2 0 Template_MySQL mysql.spin_rounds 0 0 4444FF 1 2 0 Template_MySQL mysql.spin_waits 0 0 157419 1 2 0 Template_MySQL mysql.os_waits InnoDB Semaphore Waits 800 150 0.0000 100.0000 1 1 0 1 0 0.0000 0.0000 0 0 0 0 0 1 7020AF 1 2 0 Template_MySQL mysql.innodb_sem_waits InnoDB Semaphore Wait Time 800 150 0.0000 100.0000 1 1 0 1 0 0.0000 0.0000 0 0 0 0 0 1 708226 1 2 0 Template_MySQL mysql.innodb_sem_wait_time_ms InnoDB Tables In Use 800 150 0.0000 100.0000 1 1 0 1 0 0.0000 0.0000 0 0 0 0 0 1 D99362 1 2 0 Template_MySQL mysql.innodb_tables_in_use 0 0 663344 1 2 0 Template_MySQL mysql.innodb_locked_tables InnoDB Transactions 800 150 0.0000 100.0000 1 1 0 1 0 0.0000 0.0000 0 0 0 0 0 0 8F005C 1 2 0 Template_MySQL mysql.innodb_transactions 0 0 4444FF 1 2 0 Template_MySQL mysql.current_transactions 0 0 FF7D00 1 2 0 Template_MySQL mysql.history_list 0 0 74C366 1 2 0 Template_MySQL mysql.read_views MyISAM Indexes 800 150 0.0000 100.0000 1 1 0 1 0 0.0000 0.0000 0 0 0 0 0 1 157419 1 2 0 Template_MySQL mysql.Key_read_requests 0 0 AFECED 1 2 0 Template_MySQL mysql.Key_reads 0 1 862F2F 1 2 0 Template_MySQL mysql.Key_write_requests 0 0 F51D30 1 2 0 Template_MySQL mysql.Key_writes MyISAM Key Cache 800 150 0.0000 100.0000 1 1 0 1 0 0.0000 0.0000 0 0 0 0 0 1 99B898 1 2 0 Template_MySQL mysql.setting.key_buffer_size 0 1 2A363B 1 2 0 Template_MySQL mysql.Key_buf_bytes_used 0 1 FECEA8 1 2 0 Template_MySQL mysql.Key_buf_bytes_unflushed MySQL Binary/Relay Logs 800 150 0.0000 100.0000 1 1 0 1 0 0.0000 0.0000 0 0 0 0 0 0 35962B 1 2 0 Template_MySQL mysql.Binlog_cache_use 0 0 FF0000 1 2 0 Template_MySQL mysql.Binlog_cache_disk_use 0 0 8D00BA 1 2 0 Template_MySQL mysql.binary_log_space 0 0 8F005C 1 2 0 Template_MySQL mysql.relay_log_space MySQL Command Counters 800 150 0.0000 100.0000 1 1 0 1 0 0.0000 0.0000 0 0 0 0 0 1 FFC3C0 1 2 0 Template_MySQL mysql.Questions 0 1 FF0000 1 2 0 Template_MySQL mysql.Com_select 0 5 FF7D00 1 2 0 Template_MySQL mysql.Com_delete 0 5 FFF200 1 2 0 Template_MySQL mysql.Com_insert 0 5 00CF00 1 2 0 Template_MySQL mysql.Com_update 0 5 2175D9 1 2 0 Template_MySQL mysql.Com_replace 0 5 55009D 1 2 0 Template_MySQL mysql.Com_load 0 5 942D0C 1 2 0 Template_MySQL mysql.Com_delete_multi 0 5 AAABA1 1 2 0 Template_MySQL mysql.Com_insert_select 0 5 D8ACE0 1 2 0 Template_MySQL mysql.Com_update_multi 0 5 00B99B 1 2 0 Template_MySQL mysql.Com_replace_select MySQL Connections 800 150 0.0000 100.0000 1 1 0 1 0 0.0000 0.0000 0 0 0 0 0 1 C0C0C0 1 2 0 Template_MySQL mysql.setting.max_connections 0 1 FFD660 1 2 0 Template_MySQL mysql.Max_used_connections 0 0 FF3932 1 2 0 Template_MySQL mysql.Aborted_clients 0 0 00FF00 1 2 0 Template_MySQL mysql.Aborted_connects 0 2 FF7D00 1 2 0 Template_MySQL mysql.Threads_connected 0 0 4444FF 1 2 0 Template_MySQL mysql.Connections MySQL Files and Tables 800 150 0.0000 100.0000 1 1 0 1 0 0.0000 0.0000 0 0 0 0 0 1 D09887 1 2 0 Template_MySQL mysql.setting.table_cache 0 0 4A6959 1 2 0 Template_MySQL mysql.Open_tables 0 0 1D1159 1 2 0 Template_MySQL mysql.Open_files 0 0 DE0056 1 2 0 Template_MySQL mysql.Opened_tables MySQL Handlers 800 150 0.0000 100.0000 1 1 0 1 0 0.0000 0.0000 0 0 0 0 0 1 4D4A47 1 2 0 Template_MySQL mysql.Handler_write 0 5 C79F71 1 2 0 Template_MySQL mysql.Handler_update 0 5 BDB8B3 1 2 0 Template_MySQL mysql.Handler_delete 0 5 8C286E 1 2 0 Template_MySQL mysql.Handler_read_first 0 5 BAB27F 1 2 0 Template_MySQL mysql.Handler_read_key 0 5 C02942 1 2 0 Template_MySQL mysql.Handler_read_next 0 5 FA6900 1 2 0 Template_MySQL mysql.Handler_read_prev 0 5 5A3D31 1 2 0 Template_MySQL mysql.Handler_read_rnd 0 5 69D2E7 1 2 0 Template_MySQL mysql.Handler_read_rnd_next MySQL Network Traffic 800 150 0.0000 100.0000 1 1 0 1 0 0.0000 0.0000 0 0 0 0 0 1 4B2744 1 2 0 Template_MySQL mysql.Bytes_sent 0 1 E4C576 1 2 0 Template_MySQL mysql.Bytes_received MySQL Processlist 800 150 0.0000 100.0000 1 1 0 1 0 0.0000 0.0000 0 0 0 0 0 1 DE0056 1 2 0 Template_MySQL mysql.State_closing_tables 0 5 784890 1 2 0 Template_MySQL mysql.State_copying_to_tmp_table 0 5 D1642E 1 2 0 Template_MySQL mysql.State_end 0 5 487860 1 2 0 Template_MySQL mysql.State_freeing_items 0 5 907890 1 2 0 Template_MySQL mysql.State_init 0 5 DE0056 1 2 0 Template_MySQL mysql.State_locked 0 5 1693A7 1 2 0 Template_MySQL mysql.State_login 0 5 783030 1 2 0 Template_MySQL mysql.State_preparing 0 5 FF7F00 1 2 0 Template_MySQL mysql.State_reading_from_net 0 5 54382A 1 2 0 Template_MySQL mysql.State_sending_data 0 5 B83A04 1 2 0 Template_MySQL mysql.State_sorting_result 0 5 6E3803 1 2 0 Template_MySQL mysql.State_statistics 0 5 B56414 1 2 0 Template_MySQL mysql.State_updating 0 5 6E645A 1 2 0 Template_MySQL mysql.State_writing_to_net 0 5 521808 1 2 0 Template_MySQL mysql.State_none 0 5 194240 1 2 0 Template_MySQL mysql.State_other MySQL Query Cache 800 150 0.0000 100.0000 1 1 0 1 0 0.0000 0.0000 0 0 0 0 0 2 4444FF 1 2 0 Template_MySQL mysql.Qcache_queries_in_cache 0 2 EAAF00 1 2 0 Template_MySQL mysql.Qcache_hits 0 0 157419 1 2 0 Template_MySQL mysql.Qcache_inserts 0 0 00A0C1 1 2 0 Template_MySQL mysql.Qcache_not_cached 0 0 FF0000 1 2 0 Template_MySQL mysql.Qcache_lowmem_prunes MySQL Query Cache Memory 800 150 0.0000 100.0000 1 1 0 1 0 0.0000 0.0000 0 0 0 0 0 1 74C366 1 2 0 Template_MySQL mysql.setting.query_cache_size 0 1 FFC3C0 1 2 0 Template_MySQL mysql.Qcache_free_memory 0 0 8D00BA 1 2 0 Template_MySQL mysql.Qcache_total_blocks 0 0 837C04 1 2 0 Template_MySQL mysql.Qcache_free_blocks MySQL Replication 800 150 0.0000 100.0000 1 1 0 1 0 0.0000 0.0000 0 0 0 0 0 1 96E78A 1 2 0 Template_MySQL mysql.slave_running 0 1 CDCFC4 1 2 0 Template_MySQL mysql.slave_stopped 0 0 4444FF 1 2 0 Template_MySQL mysql.slave_lag 0 0 8D00BA 1 2 0 Template_MySQL mysql.Slave_open_temp_tables 0 0 FF0000 1 2 0 Template_MySQL mysql.Slave_retried_transactions MySQL Select Types 800 150 0.0000 100.0000 1 1 0 1 0 0.0000 0.0000 0 0 0 0 0 1 3D1500 1 2 0 Template_MySQL mysql.Select_full_join 0 5 AA3B27 1 2 0 Template_MySQL mysql.Select_full_range_join 0 5 EDAA41 1 2 0 Template_MySQL mysql.Select_range 0 5 13343B 1 2 0 Template_MySQL mysql.Select_range_check 0 5 686240 1 2 0 Template_MySQL mysql.Select_scan MySQL Sorts 800 150 0.0000 100.0000 1 1 0 1 0 0.0000 0.0000 0 0 0 0 0 1 FFAB00 1 2 0 Template_MySQL mysql.Sort_rows 0 0 157419 1 2 0 Template_MySQL mysql.Sort_range 0 0 DA4725 1 2 0 Template_MySQL mysql.Sort_merge_passes 0 0 4444FF 1 2 0 Template_MySQL mysql.Sort_scan MySQL Table Locks 800 150 0.0000 100.0000 1 1 0 1 0 0.0000 0.0000 0 0 0 0 0 1 D2D8F9 1 2 0 Template_MySQL mysql.Table_locks_immediate 0 0 002A8F 1 2 0 Template_MySQL mysql.Table_locks_immediate 0 1 FF3932 1 2 0 Template_MySQL mysql.Table_locks_waited 0 0 35962B 1 2 0 Template_MySQL mysql.Slow_queries MySQL Temporary Objects 800 150 0.0000 100.0000 1 1 0 1 0 0.0000 0.0000 0 0 0 0 0 1 FFAB00 1 2 0 Template_MySQL mysql.Created_tmp_tables 0 0 837C04 1 2 0 Template_MySQL mysql.Created_tmp_tables 0 0 F51D30 1 2 0 Template_MySQL mysql.Created_tmp_disk_tables 0 2 157419 1 2 0 Template_MySQL mysql.Created_tmp_files MySQL Threads 800 150 0.0000 100.0000 1 1 0 1 0 0.0000 0.0000 0 0 0 0 0 1 D8ACE0 1 2 0 Template_MySQL mysql.setting.thread_cache_size 0 2 DE0056 1 2 0 Template_MySQL mysql.Threads_created MySQL Transaction Handler 800 150 0.0000 100.0000 1 1 0 1 0 0.0000 0.0000 0 0 0 0 0 0 DE0056 1 2 0 Template_MySQL mysql.Handler_commit 0 0 784890 1 2 0 Template_MySQL mysql.Handler_rollback 0 0 D1642E 1 2 0 Template_MySQL mysql.Handler_savepoint 0 0 487860 1 2 0 Template_MySQL mysql.Handler_savepoint_rollback ===== Logs ===== http://87.110.183.172/forum/showthread.php?t=20211 http://www.zabbix.com/forum/showthread.php?t=25551 Requisitos: ^ Maquina ^ Elemento ^ Comentario ^ | Cliente | Zabbix client | Requiere configuracion, NO hay que anyadir entradas extra | | 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: /etc/zabbix/zabbix_agentd.conf Y anyadir/editar las lineas: EnableRemoteCommands=1 Hostname=test-5.dev.jj.com.dev.jj.com ListenPort=10050 ServerActive=monitor.dev.jj.com 2. Reiniciar el servicio: sudo /etc/init.d/zabbix-agent restart **Item** En este caso lo he creado a pelo sobre el 'Host', pero lo suyo es crear un 'Template' {{informatica:linux:01.png|}} **Trigger** Buscamos la cadena 'ERROR': {{informatica:linux:02.png|}} **Action** En este caso generica, pero se puede personalizar: {{informatica:linux:03.png|}} {{informatica:linux:04.png|}} {{informatica:linux:05.png|}} ====== 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:logmatchNumFound[kvm_backup_finished].diff(0)}<1 & {scheduler-1.dev.jj.com:logmatchNumFound[kvm_backup_finished].time(0)}>050000 & {scheduler-1.dev.jj.com:logmatchNumFound[kvm_backup_finished].time(0)}<050110 | ====== Notificaciones ====== ===== Correo (usar esta) ===== 0. Requisitos El servidor zabbix tiene que estar compilado con soporte SMTP. Al arrancar ver en los logs: 1:20180719:063241.135 SMTP authentication: YES 1. Login como administrador 2. Administration / Media types 3. Click en "Email" 4. Dejar el formulario tal que así: | SMTP server | smtp01.example.com | | SMTP server port | 465 | | SMTP helo | example.com | | SMTP email | user@example.com | | Connection security | SSL\TLS | | Authentication | Username and Password | | Username | user@example.com | | Password | secret | 5. Click "Update" ===== Correo (ssmtp) ===== https://www.zabbix.com/documentation/2.0/manual/config/notifications/media/script 1. Crear un script: sudo vim /opt/zabbix_email.sh Con el siguiente contenido: #!/bin/bash to=$1 subject=$2 body=$3 cat < 2. Dar permisos: sudo chgrp zabbix /opt/zabbix_email.sh sudo chmod 0775 /opt/zabbix_email.sh 3. Editar el archivo de configuracion: sudo cp /etc/zabbix/zabbix_server.conf /etc/zabbix/zabbix_server.conf.bak sudo vim /etc/zabbix/zabbix_server.conf Y escribir la siguiente linea: AlertScriptsPath=/opt 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 "Administration / Media types" 7. Pulsar sobre el boton "Create media type" 8. Dejar los valores asi: | Description | Email ssmtp | | Type | Script | | Script name | zabbix_mail.sh | | Enabled | (marcado) | Pulsar el boton "Save". 9. Comprobar que todo ha ido bien: 9.1. Ir a "Administration / Users" 9.2. Seleccionar un usuario cualquiera 9.3. Pulsar en la solapa "Media" 9.4. Pulsar en el enlace "Add" 9.5.Dejar los valores asi: | Type | Email ssmtp | | Send to | destination@example.com | Pulsar el boton "Add" ====== Parches ====== ^ Version ^ Funcionalidad ^ Recurso ^ | 2.2 | Mostrar todas las graficas de un host a la vez | https://support.zabbix.com/browse/ZBXNEXT-75 | | 2.0.2 (2.0.9+ creo no necesario) | Soporte a OID dinamicos para SNMP LLD | https://support.zabbix.com/browse/ZBX-3449 | ====== Bugs ====== 1. Cuando activo/desactivo alguna 'Discovery rule' tengo que recargar la cache de la configuracion en el servidor 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: /etc/init.d/zabbix_agentd #!/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=/usr/sbin/${NAME} DESC="Zabbix agent daemon" PID=/var/run/zabbix/$NAME.pid LOG=/var/log/zabbix/$NAME.log # Include LSB funcions . /lib/lsb/init-functions test -f $DAEMON || exit 0 case "$1" in start) echo "Starting $DESC: $NAME" start-stop-daemon --start --oknodo --pidfile $PID --exec $DAEMON ;; stop) echo "Stopping $DESC: $NAME" start-stop-daemon --stop --quiet --pidfile $PID --retry=TERM/10/KILL/5 && return 0 start-stop-daemon --stop --oknodo --exec $DAEMON --name $NAME --retry=TERM/10/KILL/5 ;; restart|force-reload) $0 stop $0 start ;; status) status_of_proc -p $PID "$DAEMON" $NAME ;; *) N=/etc/init.d/$NAME echo "Usage: $N {start|stop|restart|force-reload}" >&2 exit 1 ;; esac exit 0 ====== Autenticacion LDAP ====== (Actualizado Zabbix Web 3.4.7.) ===== Cambiar autenticación de "Internal" a "LDAP" ===== 1. Hacer login con el superusuario 'admin' 2. Crear otro superusuario con el **mismo usuario y contrasenya que un usuario LDAP ya existente** 2.1. Ir a 'Administration/Users' 2.2. Pulsar sobre el boton "Create user" 2.3. Pulsar "Select" 2.4. En el combo seleccionar "Zabbix Super Admin" 2.5. Pulsar pestaña "User" 2.6. Rellenar formulario dejando los campos como están excepto: | **Alias** | Nombre del usuario que coincida con el uid del usuario de LDAP | | **Password** | Contraseña del usuario que coincida con la del usuario de LDAP | | **Password (once again)** | Contraseña del usuario que coincida con la del usuario de LDAP | 2.7. Pulsar "Select" 2.8. En la nueva ventana que se ha abierto seleccionar "Zabbix administrators" y pulsar "Save" 2.9. Pulsar "Add" 3. Hacemos un logout 4. Hacemos un login con las nuevas credenciales recien creadas en el paso 1.2. 5. Vamos a "Administration/Authentication", y pulsamos sobre el boton "LDAP" 6. Ejemplo de config con LDAPS: | LDAP host | ldap.example.com | | Port | 389 | | Base DN | ou=people,dc=example,dc=com | | Search attribute | uid | | Bind DN | cn=readonly,dc=example,dc=com | | Bind password | El password del usuario LDAP "cn=readonly,dc=example,dc=com" | | Login | El usuario que se ha usado para iniciar sesión en Zabbix | | User password | La contraseña del usuario que se ha usado para iniciar sesión en Zabbix | 7. Pulsar "Test" Resultado esperado: Franja verde en la parte superior con el mensaje "LDAP login successful" 8. Pulsar "Update" ===== Crear usuarios con autenticación LDAP ===== La implementación LDAP que tiene zabbix exige que en Zabbix se creen los usuarios, cuyo "Alias" debe coincidir con el "uid" de LDAP. NO hace falta ponerles contraseña. En este ejemplo les damos permiso de superadministradores para que puedan a su vez crear otros usuarios. 1. Login como superadmin 2. Ir a 'Administration/Users' 3. Pulsar sobre el boton "Create user" 4. Pulsar "Select" 5. En el combo seleccionar "Zabbix Super Admin" 6. Pulsar pestaña "User" 7. Rellenar formulario dejando los campos como están excepto: | **Alias** | Nombre del usuario que coincida con el uid del usuario de LDAP | 8. Pulsar "Select" 9. En la nueva ventana que se ha abierto seleccionar "Zabbix administrators" y pulsar "Save" 10. Pulsar "Add"