I'm attempting to test out the check_mysql plugin for Nagios using the command line. It works great when I'm just checking localhost but when I try to specify a different server (using the -H argument) I keep getting the following error message:
CRITICAL - Unable to connect to mysql://nagios_user@{remoteServerHostname}/ - Access denied for user 'nagios_user'@'{localServerHostName}' (using password: YES)
It looks like it's trying to connect to the database using the localhost server even though I've specified a different host name. I've already set up this user on the remote database and they have correct permissions. I'm just trying to figure out why the script keeps inserting the localhost server name instead of the remote one.
The default setting for a MySQL server is to deny access from clients with IP addresses other than the server address. To get around this, run the following command on your server:
Also check that your MySQL server's firewall allows access from your Nagios server on the MySQL server port (default is 3306).
I ended up using NRPE with a plugin which solved my connection issue.