Bug #40530 Agent cannot connect to DB with hostname=localhost
Submitted: 5 Nov 2008 14:01 Modified: 21 Nov 2008 16:31
Reporter: Andrii Nikitin Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Enterprise Monitor: Agent Severity:S3 (Non-critical)
Version:1.x, 2.0.0.7092 OS:Any (UNIX)
Assigned to: Kay Roepke CPU Architecture:Any
Tags: kay_merlin_immediate

[5 Nov 2008 14:01] Andrii Nikitin
Description:
I believe that agent uses same connection rules which described here:
http://dev.mysql.com/doc/refman/5.0/en/connecting.html

"
On Unix, MySQL programs treat the hostname localhost specially, in a way that is likely different from what you expect compared to other network-based programs. For connections to localhost, MySQL programs attempt to connect to the local server by using a Unix socket file
"

So, if 'localhost' is specified in configuration agent fails with error:

(critical) the MySQL server could not be reached at socket '(null)', we will check in 10 seconds

That is probably useful feature but it should be mentioned in documentation also.

How to repeat:
Configure in agent ini file hostname=localhost (maybe it is necessary to not have socket file in default location).

It gets fixed with either changing localhost to 127.0.0.1 or adding socket='path_to_socket' parameter

Suggested fix:
Document this feature in agent installation guide and troubleshooting.
[6 Nov 2008 19:35] Sloan Childers
Due to the overwhelming number of support cases related to this behavior we should really consider fixing it or making it easy for a customer to work around.
[12 Nov 2008 14:12] Kay Roepke
The agent will now regard 'localhost' as '127.0.0.1', differing to mysqld's usage of localhost.

A log message will be printed if this is detected:
2008-11-12 15:06:22: (message) agent-inst-config.c:153: [mysqld].hostname was 'localhost', setting to '127.0.0.1' to prevent connection over UNIX socket. If you want to connect via the socket, specify [mysqld].socket directly.
[18 Nov 2008 14:47] Carsten Segieth
tested OK in 2.0.0.7100
[21 Nov 2008 16:31] Tony Bedford
An entry was added to the 2.0 changelog:

The Agent could not connect to a database with the hostname set to localhost. Doing so resulted in the error:

(critical) the MySQL server could not be reached at socket '(null)', we will check in 10 seconds