Unable to figure out how to properly monitor mysql

This forum was archived to /woltlab and is now in read-only mode.
  • Hello,


    I have /usr/lib/nagios/plugins/check_mysql in the right place and I have a services.conf definition as follows:


    Code
    1. apply Service "MySQL" {
    2. import "generic-service"
    3. check_command = "mysql"
    4. assign where host.address == "local.host.local"
    5. assign where host.name == NodeName
    6. }


    On the two hosts I have this assigned for I get two very logical errors:


    the icinga2 server reports:


    Code
    1. Access denied for user 'nagios'@'localhost' (using password: NO)


    and the remote host reports:


    Code
    1. Can't connect to MySQL server on 'local.host.local' (111)


    For this remote host in the hosts.conf file I have tried a variety of options such as with no success in checking on the localhost interface.


    Code
    1. vars.mysql_host = "$address$"




    What I'm terribly sorry to ask help for is that


    1) I cannot find how to define the mysql user nagios and password in the icinga2 docs. If this is somewhere really obvious I am sorry but I would like to know where to find it! I have the same issue for Postgres as well. I understand that these options need to be passed onto the check_mysql script but I don't know how to do that in the new icinga2 syntax.

    2) My remote host check is being checked by the public interface and not the localhost interface where mysql is running. How can I force the check to run on the remote host and check the localhost if mysql is running? I would be happy to use a systemd check if there is an option for that, I am running these services on Ubuntu 16.04.


    Thank you! :thumbsup:


  • Do you know what the correct level of minimal permissions for the nagios should be? I see from prior install guides people recommend:


    Code
    1. GRANT ALL PRIVILEGES ON *.* TO 'nagios'@'%';


    but I wonder if that is really the best approach for production?

  • Okay it looks like


    Code
    1. GRANT SELECT ON mysql.* TO 'nagios'@'localhost';

    is good enough! Issue 1 is resolved.


    dnsmichi can you point me to the docs for running a service check on a remote host and checking if a service is running using either a localhost variable or a systemd service check?