zabbix-mysql-partitioning-perl icon indicating copy to clipboard operation
zabbix-mysql-partitioning-perl copied to clipboard

DSN not being referenced as a variable and is set literally later in the script.

Open surfrock66 opened this issue 11 months ago • 4 comments

In this version of the script:

https://raw.githubusercontent.com/OpensourceICTSolutions/zabbix-mysql-partitioning-perl/5f3e78ee90b1f18cc00099f3a3deda45eb9f76bd/mysql_zbx_part.pl

the $dsn can be declared on line 12, however on lines 37 and 48 they are manually re-declared, wiping out a config set at the front. This seems like it is in error.

surfrock66 avatar Dec 27 '24 19:12 surfrock66

@surfrock66 hello!

Modern perl style (can we even use such a word to describe a perl style?) assumes that you are using use strict;, declare variables with my, assigning a value somewhere else. There is no error here.

If you have problems connecting to the database, it is better to check all the settings.

pavlozt avatar Dec 28 '24 20:12 pavlozt

There is, however, a small inconvenience in the script. This script uses /var/lib/mysql/mysql.sock by default , but modern Oracle Mysql in Ubuntu uses /var/run/mysqld/mysqld.sock which different. Mariadb in Debian 12 uses /run/mysqld/mysqld.sock . The author faced a difficult choice .

If you have any problems running the script on modern systems, try editing the socket path.

pavlozt avatar Dec 28 '24 20:12 pavlozt

You don't need to specify the socket path in a special way. The localhost value has a special meaning in the library. TCP connection will not be used.

This code is quite sufficient: my $dsn = 'DBI:mysql:database=zabbix;host=localhost';

Perhaps on older systems there were problems with finding the socket, but modern libraries use the settings in config files like /etc/mysql/my.conf

pavlozt avatar Dec 28 '24 21:12 pavlozt

That's fair, and I'm not a perl expert; I just thought editing the entries at the top with the "my" definition would be enough, but I ended up just commenting out where they're set lower and that worked.

surfrock66 avatar Dec 29 '24 20:12 surfrock66