Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
surfrock66 opened this issue Dec 27, 2024 · 4 comments

Comments

@surfrock66
Copy link

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.

@pavlozt
Copy link

pavlozt commented Dec 28, 2024

@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
Copy link

pavlozt commented Dec 28, 2024

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
Copy link

pavlozt commented Dec 28, 2024

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

@surfrock66
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants