Ad Widget

Collapse

Como configurar este template >> Template DB MySQL

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gairhald
    Junior Member
    • Jan 2019
    • 8

    #1

    Como configurar este template >> Template DB MySQL

    Buenas,

    estoy intentado configurar este template que viene por defecto con Zabbix >> Template DB MySQL pero no recoge datos, unicamente la versión...creo que lo tengo bien configurado, lo pongo a continuación la información:

    Entorno del servidor:
    Code:
    Ubuntu 18.04 LTS
    Zabbix Server Source Code 4.03 and Agent install
    MySQL Binaries 8.0.15
    Lo estoy probando directamente sobre mi ZABBIX SERVER

    Si miro el fichero de configuración del AGENTE zabbix_agentd.conf, esta incluida las dos rutas de ficheros de configuración:

    Code:
    ### Option: Include
    #       You may include individual files or all files in a directory in the configuration file.
    #       Installing Zabbix will create include directory in /usr/local/etc, unless modified during the compile time.
    #
    # Mandatory: no
    # Default:
    # Include=
    
    # Include=/usr/local/etc/zabbix_agentd.userparams.conf
    Include=/usr/local/etc/zabbix_agentd.conf.d/
    Include=/usr/local/etc/zabbix_agentd.conf.d/*.conf
    Si miro el fichero userparameter_mysql.conf necesario para esta plantilla:

    Code:
    root@csavzabbix:~# cat /usr/local/etc/zabbix_agentd.conf.d/userparameter_mysql.conf
    # For all the following commands HOME should be set to the directory that has .my.cnf file with password information.
    
    # Flexible parameter to grab global variables. On the frontend side, use keys like mysql.status[Com_insert].
    # Key syntax is mysql.status[variable].
    UserParameter=mysql.status[*],echo "show global status where Variable_name='$1';" | HOME=/var/lib/zabbix mysql -N | awk '{print $$2}'
    
    # Flexible parameter to determine database or table size. On the frontend side, use keys like mysql.size[zabbix,history,data].
    # Key syntax is mysql.size[<database>,<table>,<type>].
    # Database may be a database name or "all". Default is "all".
    # Table may be a table name or "all". Default is "all".
    # Type may be "data", "index", "free" or "both". Both is a sum of data and index. Default is "both".
    # Database is mandatory if a table is specified. Type may be specified always.
    # Returns value in bytes.
    # 'sum' on data_length or index_length alone needed when we are getting this information for whole database instead of a single table
    UserParameter=mysql.size[*],bash -c 'echo "select sum($(case "$3" in both|"") echo "data_length+index_length";; data|index) echo "$3_length";; free) echo "data_free";; esac)) from information_schema.tables$([[ "$1" = "all" || ! "$1" ]] || echo " where table_schema=\"$1\"")$([[ "$2" = "all" || ! "$2" ]] || echo "and table_name=\"$2\"");" | HOME=/var/lib/zabbix mysql -N'
    
    UserParameter=mysql.ping,HOME=/var/lib/zabbix mysqladmin ping | grep -c alive
    UserParameter=mysql.version,mysql -V
    donde la ruta de configuración de acceso del MYSQL esta en

    Code:
    root@csavzabbix:~# cat /var/lib/zabbix/.my.cnf
    [client]
    user=zabbix_agent
    password=*******
    En el MySQL he creado este usuario con acceso a todo el mysql

    Code:
    mysql> show grants for 'zabbix_agent'@'localhost'\G
    *************************** 1. row ***************************
    Grants for zabbix_agent@localhost: GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE, CREATE ROLE, DROP ROLE ON *.* TO `zabbix_agent`@`localhost`
    *************************** 2. row ***************************
    Grants for zabbix_agent@localhost: GRANT APPLICATION_PASSWORD_ADMIN,BACKUP_ADMIN,BINLOG_ADMIN,BINLOG_ENCRYPTION_ADMIN,CONNECTION_ADMIN,ENCRYPTION_KEY_ADMIN,GROUP_REPLICATION_ADMIN,PERSIST_RO_VARIABLES_ADMIN,REPLICATION_SLAVE_ADMIN,RESOURCE_GROUP_ADMIN,RESOURCE_GROUP_USER,ROLE_ADMIN,SERVICE_CONNECTION_ADMIN,SESSION_VARIABLES_ADMIN,SET_USER_ID,SYSTEM_VARIABLES_ADMIN,XA_RECOVER_ADMIN ON *.* TO `zabbix_agent`@`localhost`
    2 rows in set (0.00 sec)
    Sin embargo en la consola de Zabbix me aparecen como not supported aunque algunos se queja de qe no puede convertir el tipo de dato para verlo... he de modificar algo más en la plantilla o configuración??

    Click image for larger version

Name:	zabbix_01.jpg
Views:	1644
Size:	180.0 KB
ID:	375095

    Pero otros, se queja de que no existe el mysqladmin

    Click image for larger version

Name:	zabbix_02.jpg
Views:	1348
Size:	179.6 KB
ID:	375096


    sin embargo el mysqladmin si existe y esta en el path por lo que no se que más he de hacer para poder usar esta pantilla, alguna sugerencia? muchas gracias

    Code:
    root@csavzabbix:~# mysqladmin
    mysqladmin  Ver 8.0.15 for linux-glibc2.12 on x86_64 (MySQL Community Server - GPL)
    Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
    
    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.
    
    Administration program for the mysqld daemon.
    Usage: mysqladmin [OPTIONS] command command....
      --bind-address=name IP address to bind to.
      -c, --count=#       Number of iterations to make. This works with -i
                          (--sleep) only.
      -#, --debug[=#]     This is a non-debug version. Catch this and exit.
      --debug-check       This is a non-debug version. Catch this and exit.
      --debug-info        This is a non-debug version. Catch this and exit.
      -f, --force         Don't ask for confirmation on drop database; with
                          multiple commands, continue even if an error occurs.
      -C, --compress      Use compression in server/client protocol.
      --character-sets-dir=name
                          Directory for character set files.
      --default-character-set=name

    gracias!!



    Attached Files
  • gairhald
    Junior Member
    • Jan 2019
    • 8

    #2
    No se que mas he tocado pero ahora si me funciona.... todos los campos excepto el de MySQL STATUS

    Click image for larger version

Name:	zabbix_04.jpg
Views:	1343
Size:	186.1 KB
ID:	375105

    Pero igualmente, si quiero recoger datos de otros servidores... he de añadir este fichero, el userparameter_mysql.conf en cada agente?? o desde el servidor lanzará esa configuración? porque si añado esa plantialla a otrs host no me funciona, aunque configure el usuario en em mysql ni nada...

    Comment

    • deprakid
      Junior Member
      • Mar 2019
      • 1

      #3
      Hola, a mi me paso algo similar, y lo resolvi modificando el user parameter para ping como sigue:

      UserParameter=mysql.ping,HOME=/var/lib/zabbix mysqladmin --socket=/mi/instanciaDB/instanciaDB.sock ping | grep -c alive

      donde /mi/instanciaDB/instanciaDB.sock seria el path completo del archivo .sock de tu instancia MySQL

      Comment

      • alejodurin
        Junior Member
        • Feb 2019
        • 4

        #4
        Hola, tendrias que ver a donde apunta la variable de entorno HOME.
        A mi me paso que apuntaba a otro directorio, asi que la tuve que cambiar y recien ahi arranco.

        Comment

        • garycuello
          Junior Member
          • Jul 2022
          • 2

          #5
          Hola! Que tal? soy nuevo, me sucede que me arroja error de MySQL: Service is down. El template que se encuentra en /etc/zabbix/zabbix_agentd.d/template_db_mysql.conf se debe importar en zabbix? saludos.

          Comment

          Working...