Ad Widget

Collapse

Agent2 MySQL Template

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • TheImmortal
    Junior Member
    • Nov 2020
    • 11

    #16
    Noone, anything? This is bonkers to me, and the lack of help is pushing towards other monitoring utilities. The MySQL template for agent2 is the most inane of it all - i can get it running REGARDLESS of what i have in zabbix_agent2.conf if i specify the DSN (unix:/path/to/socket) in the template's macro, alongside the user and password, however the moment i try to leave the macros 'up for grabs' and just use the DNS as a session name (...as the manual says!) and fill the zabbix_agent2.conf with the credentials and URI, the server logs "bad connections". That is even tho the item check ALWAYS succeeds!


    Even in the first scenario, the results are so crazy that it's unreliable to use (false positives of mysql being down together with alerts of it returning 'loaded data').

    Anyone, anything please?

    LE: more to this madness:

    [root@zabbix ~]# zabbix_get -s IP -k "mysql.ping[unix:/var/lib/mysql/mysql.sock,zbx_monitor,PASS]"
    0
    [root@zabbix ~]# zabbix_get -s IP -k "mysql.ping[unix:/var/lib/mysql/mysql.sock,zbx_monitor,PASS]"
    1
    [root@zabbix ~]# zabbix_get -s IP -k "mysql.version[unix:/var/lib/mysql/mysql.sock,zbx_monitor,PASS"]
    5.6.47
    [root@zabbix ~]# zabbix_get -s IP -k "mysql.db.discovery[unix:/var/lib/mysql/mysql.sock,zbx_monitor,PASS]"
    ZBX_NOTSUPPORTED: invalid connection
    Only AFTER i executed the first mysql.ping (that failed!) have graphs started being populated with the server in question and for this last one cmd, i did see a 'show databases' call on the server, but that ended prematurely. Second time i tried the command? ALL SUCCESS. Wtf?

    To me, something is looking way too odd, with the server apparently expecting a way different connection?

    Last edited by TheImmortal; 10-11-2020, 11:22. Reason: addtl details

    Comment

    • yeffo
      Junior Member
      • Nov 2020
      • 4

      #17

      After assigned "zabbix agent2 mysql template" to host with installed mysql database, you have two options:

      A. Edit only template macros assigned to host with mysql:
      • go to: Host -> Macros -> Iherited and host macros
      • fill three macros: mysql.dsn, mysql.password, mysql.user
      • after this steps, this three macros you can see not only in "Iherited and host macros" but in "host macros" too
      • value filled in without special "start and end" markers ("",<>, ...)
      • !!!dont change or edit any "Mysql" values in /etc/zabbix/zabbix-agent2.conf!!!

      B. Edit /etc/zabbix/zabbix-agent2.conf + "mysql.dsn" macros assigned to host (maybe more secure, if dont use TLS)
      • find and edit in /etc/zabbix/zabbix-agent2.conf:
      Plugins.Mysql.Sessions.XTESTX.Uri=
      Plugins.Mysql.Sessions.XTESTX.User=
      Plugins.Mysql.Sessions.XTESTX.Password=
      • go to: Host -> Macros -> Iherited and host macros
      • IMPORTANT STEP: fill the only one macro - mysql.dsn and copy value from /etc/zabbix/zabbix-agent2.conf (in my example: XTESTX)
      • after this steps, this macro you can see not only in "Iherited and host macros" but in "host macros" too
      • probably need to restart zabbix-agent2 on host with mysql database

      URI from example (you can find correct URI value with minimal this commands in cli):
      find / - name mysql.sock
      mysql_config --socket
      netstat -ln|grep mysql
      mysqladmin -p -u zbx_monitor variables

      User and pwd from example:
      CREATE USER 'zbx_monitor'@'%' IDENTIFIED BY 'dbpwd';
      GRANT USAGE,REPLICATION CLIENT,PROCESS,SHOW DATABASES,SHOW VIEW ON *.* TO 'zbx_monitor'@'%';

      Example of values, usable in A and B:
      Plugins.Mysql.Sessions.XTESTX.Uri=unix:/var/lib/mysql/mysql.sock
      Plugins.Mysql.Sessions.XTESTX.User=zbx_monitor
      Plugins.Mysql.Sessions.XTESTX.Password=dbpwd



      But I have 2 question..
      When values was defined on site of zabbix server (in macros), and agent <-> server communication dont use TLS, are this values sending to client unecrypted, yes?
      But when I defined all values only on agent site in conf and on site of server is defined only "URI name", are pwd and name sending from agent to server?

      Thx
      Jaro


      Comment

      • anonamoose
        Junior Member
        • May 2019
        • 16

        #18
        well I fell kind of dumb after wasting a few hours on this but perhaps it'll help someone else.

        For me I was setting the macros globally under the admin console. After I set them in configuration -> Templates -> Template DB MySQL by Zabbix 2 -> macros it worked fine.

        All I needed was:
        {$MYSQL.DSN} tcp://localhost:3306

        {$MYSQL.PASSWORD}

        {$MYSQL.USER}

        Worked perfect.

        Comment

        • HoracioDos
          Junior Member
          • Nov 2019
          • 13

          #19
          Originally posted by anonamoose
          well I fell kind of dumb after wasting a few hours on this but perhaps it'll help someone else.

          For me I was setting the macros globally under the admin console. After I set them in configuration -> Templates -> Template DB MySQL by Zabbix 2 -> macros it worked fine.

          All I needed was:
          {$MYSQL.DSN} tcp://localhost:3306

          {$MYSQL.PASSWORD}

          {$MYSQL.USER}

          Worked perfect.
          Hello.
          We used to set everything in the template, But now, we set MYSQL URI inside zabbix-agent2.conf and we define user and password macros for each machine.

          Comment

          • anonamoose
            Junior Member
            • May 2019
            • 16

            #20
            Originally posted by HoracioDos

            Hello.
            We used to set everything in the template, But now, we set MYSQL URI inside zabbix-agent2.conf and we define user and password macros for each machine.
            That would work fine too. We manage things with puppet and it's a bit more streamlined to have it set one time in the template and then I can create the user with password and grants with puppet.

            Comment

            • LenR
              Senior Member
              • Sep 2009
              • 1005

              #21
              Originally posted by TheImmortal
              Noone, anything? This is bonkers to me, and the lack of help is pushing towards other monitoring utilities. The MySQL template for agent2 is the most inane of it all - i can get it running REGARDLESS of what i have in zabbix_agent2.conf if i specify the DSN (unix:/path/to/socket) in the template's macro, alongside the user and password, however the moment i try to leave the macros 'up for grabs' and just use the DNS as a session name (...as the manual says!) and fill the zabbix_agent2.conf with the credentials and URI, the server logs "bad connections". That is even tho the item check ALWAYS succeeds!


              Even in the first scenario, the results are so crazy that it's unreliable to use (false positives of mysql being down together with alerts of it returning 'loaded data').

              Anyone, anything please?

              LE: more to this madness:



              Only AFTER i executed the first mysql.ping (that failed!) have graphs started being populated with the server in question and for this last one cmd, i did see a 'show databases' call on the server, but that ended prematurely. Second time i tried the command? ALL SUCCESS. Wtf?

              To me, something is looking way too odd, with the server apparently expecting a way different connection?
              I ran into the same issue on my first try using agent2 for mysql. I put the macros on the host, it won't work. If I use zabbix_get with the values, it returns data, It's like it's not resolving host macros properly.

              Did you ever get a resolution?

              I'm on 6.4.2.

              Comment

              • LenR
                Senior Member
                • Sep 2009
                • 1005

                #22
                I found my problem, I had blank values in the macros, but the desired values in the description fields. It looks right, but it isn't.

                Comment

                • TheImmortal
                  Junior Member
                  • Nov 2020
                  • 11

                  #23
                  Nah I gave up and used the OG agent initially. Issues like the one I quoted ultimately made us give up and look at different solutions.

                  Comment

                  Working...