Ad Widget

Collapse

Help with partitioning; perl script not working?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • surfrock66
    Member
    • Jul 2018
    • 30

    #1

    Help with partitioning; perl script not working?

    I have a Zabbix 7.2.1 install (from the repo, not a container) on Ubuntu 24.04 which has been upgraded over the years, and I'm now finding my partitioning routine is not working. I'm using the partitioning perl script from here (an official Zabbix publication):

    https://blog.zabbix.com/partitioning...cedures/13531/

    Specifically a newly downloaded copy of the perl script here (which is NOT an official Zabbix publication, but was directly referred to in one):



    However the script is producing the following error:

    Code:
    root@sr66-zbx-01:/usr/share/zabbix# perl /usr/share/zabbix/mysql_zbx_part.pl
    DBI connect('zabbix:mysql_socket=/var/lib/mysql/mysql.sock','zabbix',...) failed: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) at /usr/share/zabbix/mysql_zbx_part.pl line 83.
    Can't call method "prepare" on an undefined value at /usr/share/zabbix/mysql_zbx_part.pl line 127.
    The issue is, I updated the script per the instructions to point to Ubuntu's version of the DSI:

    Code:
    my $db_schema;
    my $db_host;
    my $db_port;
    my $dsn = 'DBI:mysql:'.$db_schema.':mysql_socket=/var/run/mysqld/mysqld.sock';
    However the error indicates it's using the wrong DSN, and instead pointing to the original version of the .sock from the raw script. For confirmation, the sock as I put it in the script exists:

    Code:
    root@sr66-zbx-01:/usr/share/zabbix# ls /var/run/mysqld/mysqld.sock
    0 srwxrwxrwx 1 mysql mysql 0 Dec 26 15:11 /var/run/mysqld/mysqld.sock
    ​I don't know enough perl to debug this, but any help is appreciated. I believe this has been failing for a bit and I didn't notice, and I'm starting to have performance issues.
  • tim.mooney
    Senior Member
    • Dec 2012
    • 1427

    #2
    Originally posted by surfrock66
    Code:
    my $db_schema;
    my $db_host;
    my $db_port;
    my $dsn = 'DBI:mysql:'.$db_schema.':mysql_socket=/var/run/mysqld/mysqld.sock';
    I'm looking at the version of the script that is part of the 6.0 tag from github.

    It looks like you updated the place where $dsn is declared (approximately line 12 of the script), but later on inside the "else" conditional it's defined to a default value (approximately line 37). That default value is replacing the value you set during the declaration.

    You can leave line 12 (or wherever $dsn is "my'ed" without a value being assigned) alone, you only need to change the socket path to the correct value where it's first assigned. Again, for the version I'm looking at, it looks like approximately line 37.

    Comment

    • surfrock66
      Member
      • Jul 2018
      • 30

      #3
      Ugh you put me on the right path; it's not line 37 (which is when it's in a container) but instead 48. I will submit this as feedback to them, thank you for helping me to see it.

      Comment

      • tim.mooney
        Senior Member
        • Dec 2012
        • 1427

        #4
        Originally posted by surfrock66
        Ugh you put me on the right path; it's not line 37 (which is when it's in a container) but instead 48. I will submit this as feedback to them, thank you for helping me to see it.
        As I said, I was going off the version that's included with the 6.0 tag. For that tagged version, it's line 37.

        You appear to be using the version from head: https://github.com/OpensourceICTSolu...bx_part.pl#L48

        Either way, I'm glad you got it figured out.

        Comment

        • jhboricua
          Senior Member
          • Dec 2021
          • 113

          #5
          I made a python version of this if you want to check it out.

          https://gitlab.com/jhboricua/zabbix-mysql-partitioning

          Comment

          Working...