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

MySQL agent does not work if using non-standard socket #17

Open
tmcallaghan opened this issue Aug 8, 2014 · 7 comments
Open

MySQL agent does not work if using non-standard socket #17

tmcallaghan opened this issue Aug 8, 2014 · 7 comments
Assignees

Comments

@tmcallaghan
Copy link

My server's socket is /tmp/mysql.sock, Perl DBI:MySQL is hard coded to '/var/lib/mysql/mysql.sock'.

Rather than create a symlink, I modified line 69 in DataGetter/Applications/MySQL.pm, adding my specific socket.

my $dbh = DBI->connect_cached( "DBI:mysql:host=localhost;mysql_socket=/tmp/mysql.sock;", $creds->{username}, $creds->{password} ) or do {

It would be better if I could provide a non-default socket in the Longview MySQL configuration file.

@jowy
Copy link

jowy commented Aug 13, 2014

Just a thought on this from a sysadmin perspective... MySQL servers usually contain the MySQL client for management and have their root unix users configured with the root MySQL credentials and connection information under /root/.my.cnf. Could this root MySQL client be used to dynamically determine the socket location if no defaults exist e.g. /tmp/mysql.sock, /var/lib/mysql/mysql.sock?

@tmcallaghan
Copy link
Author

From what I've read, DBD:Perl uses /var/lib/mysql/mysql.sock if you don't specify otherwise. It does not look for /etc/my.cnf to figure out the socket. For now, patching the MySQL.pm file in Longview works for me.

@dwfreed
Copy link
Contributor

dwfreed commented Aug 13, 2014

The best solution would be to just use 'mysql_read_default_group' to tell libmysqlclient to read the my.cnf file for settings, which can be done with the following DBI connection string:

DBI:mysql:mysql_read_default_group=client

@tmcallaghan
Copy link
Author

I agree that anything is better than me having to patch the Longview code myself. It seems appropriate to me that the app should figure out the socket from the usual my.cnf locations and/or allow me to specify the socket in the Longview mysql config file.

@buley
Copy link

buley commented Jan 21, 2015

Ideally host config var could be supported in /etc/linode/longview.d/MySQL.conf

I run my infra on docker and needed to make the following change to get Longview to pick up data:

sed -i -e '/s/DBI:mysql:host=localhost/DBI:mysql:host=0.0.0.0/g' /opt/linode/longview/Linode/Longview/DataGetter/Applications/MySQL.pm

There is no shared socket for docker, so localhost (a special alias for the socket) doesn't work

@akh1
Copy link

akh1 commented Apr 13, 2016

Same problem,
should i correct like this ?

sed -i -e '/s/DBI:mysql:host=localhost/DBI:mysql:mysql_read_default_group=client:host=localhost/g' /opt/linode/longview/Linode/Longview/DataGetter/Applications/MySQL.pm

@tarqd
Copy link

tarqd commented Jul 27, 2017

I think it'd be neat if it used the my.cnf config for this. Would be nice if it checked a longview group first before checking client so you can give longview it's own thing. Or at the very least have it so you can specify a config file to use (ala defaults-extra-file)

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

7 participants