Commit bcedb420 authored by Anel Husakovic's avatar Anel Husakovic

MDEV-25878: mytop bugs: check for mysql driver and sockets

- Adding socket check for MariaDB/Mysql driver

Reviewed by: serg@mariadb.com
parent 59e3ac2e
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
=head1 NAME =head1 NAME
mytop - display MariaDB server performance info like `top' mytop - display MariaDB/MySQL server performance info like `top'
=cut =cut
...@@ -241,16 +241,17 @@ my $BOLD = BOLD() || ''; ...@@ -241,16 +241,17 @@ my $BOLD = BOLD() || '';
my $dsn; my $dsn;
## Socket takes precedence. ## Socket takes precedence.
my $prefix= 'mysql';
if (eval {DBI->install_driver("MariaDB")}) { if (eval {DBI->install_driver("MariaDB")}) {
$dsn = "DBI:MariaDB:database=$config{db};mariadb_read_default_group=mytop;"; $dsn = "DBI:MariaDB:database=$config{db};mariadb_read_default_group=mytop;";
$prefix= 'mariadb'
} else { } else {
$dsn = "DBI:mysql:database=$config{db};mysql_read_default_group=mytop;"; $dsn = "DBI:mysql:database=$config{db};mysql_read_default_group=mytop;";
} }
if ($config{socket} and -S $config{socket}) if ($config{socket} and -S $config{socket})
{ {
$dsn .= "mariadb_socket=$config{socket}"; $dsn .= "${prefix}_socket=$config{socket}";
} }
else else
{ {
...@@ -272,7 +273,7 @@ my $dbh = DBI->connect($dsn, $config{user}, $config{pass}, ...@@ -272,7 +273,7 @@ my $dbh = DBI->connect($dsn, $config{user}, $config{pass},
if (not ref $dbh) if (not ref $dbh)
{ {
my $Error = <<EODIE my $Error = <<EODIE
Cannot connect to MariaDB server. Please check the: Cannot connect to MariaDB/MySQL server. Please check the:
* database you specified "$config{db}" (default is "") * database you specified "$config{db}" (default is "")
* username you specified "$config{user}" (default is "root") * username you specified "$config{user}" (default is "root")
...@@ -2284,8 +2285,8 @@ Default: unset. ...@@ -2284,8 +2285,8 @@ Default: unset.
=item B<-S> or B<--socket> I</path/to/socket> =item B<-S> or B<--socket> I</path/to/socket>
If you're running B<mytop> on the same host as MariaDB, you may wish to If you're running B<mytop> on the same host as MariaDB/MySQL, you may wish to
have it use the MariaDB socket directly rather than a standard TCP/IP have it use the MariaDB/MySQL socket directly rather than a standard TCP/IP
connection. If you do,just specify one. connection. If you do,just specify one.
Note that specifying a socket will make B<mytop> ignore any host Note that specifying a socket will make B<mytop> ignore any host
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment