1

I have modified the script mysql_ from Munin, so that the function do_connect looks like this:

sub db_connect {
    my $dsn =     "$config{dsn};mysql_socket=$config{mysqlsocket};mysql_connect_timeout=5;";

    return DBI->connect($dsn, $config{user}, $config{password}, {
        RaiseError       => 1,
        PrintError       => 0,
        FetchHashKeyName => 'NAME_lc',
    });
}

I have configured plugins-conf to set different values for the socket reflected in the environment variable mysqlsocket. So, each instance has its own value for env.mysqlsocket. When I run my instances with

$ for i in a b c; do munin-run mysql_${i}_innodb_rows; done

then the first one that connects (a in this order) opens a connection which is used by the subsequent ones, instead of their sockets. The connection strings are correct, they really change.

The DBI->connect is not executed. I can prove this by setting the socket filenames to non-existent files; it reuses the same connection again.

I wonder, since these are independent processes of a symlinked script.

How can I force my Perl script to open a new connection anyway?

ThisSuitIsBlackNot
  • 23,492
  • 9
  • 63
  • 110
rexkogitans
  • 279
  • 2
  • 17

1 Answers1

0

Use the manual:

$dsn->disconnect;
Ipor Sircer
  • 3,069
  • 3
  • 10
  • 15
  • Thank you for the hint; yes, the original plugin code misses this point, but I have already added it. No success. – rexkogitans Aug 18 '16 at 13:01
  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - [From Review](/review/low-quality-posts/566802) – Ctrl-alt-dlt Aug 18 '16 at 15:59