From a15b5b93a4fafb4a49b8b649e77efeaf3782f32e Mon Sep 17 00:00:00 2001 From: Matt Farmer Date: Sun, 16 Feb 2020 16:45:36 -0500 Subject: [PATCH] Permit specifying custom host --- Linode/Longview/DataGetter/Applications/MySQL.pm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Linode/Longview/DataGetter/Applications/MySQL.pm b/Linode/Longview/DataGetter/Applications/MySQL.pm index d75c24c..19d56de 100644 --- a/Linode/Longview/DataGetter/Applications/MySQL.pm +++ b/Linode/Longview/DataGetter/Applications/MySQL.pm @@ -65,8 +65,13 @@ sub get { 1 ); } } + + my $hostname = "localhost"; + if ( exists( $creds->{host} ) ) { + $hostname = $creds->{host}; + } - my $dbh = DBI->connect_cached( "DBI:mysql:host=localhost;", $creds->{username}, $creds->{password} ) or do { + my $dbh = DBI->connect_cached( "DBI:mysql:host=${hostname};", $creds->{username}, $creds->{password} ) or do { return application_error( $dataref, $namespace, 'Unable to connect to the database: ' . $DBI::errstr, 2 );