Monitoring MySQL clusers with Nagios

nagios

I'm trying to figure out how to monitor MySQL clusters with Nagios.

I have found the following information at http://blog.unixmaniacs.com/2008/12/mysql-cluster-ndbd-monitoring-with.html, however I have got nowhere.

How exactly do I install plugins?

Best Answer

Alright, Nagios 101

Your Nagios installation is most likely in /usr/local/nagios/

Underneath that, you've got a lot of directories, but the one that the plugins go into is libexec. If you 'cd' into there, do an 'ls' and check it out. Those are all the plugins that you can use right now. Most, if you run them by themselves, will give you example usage.

Incidentally, if you know how to program, you can write your own scripts to check whatever you want. The language of the script doesn't matter, as long as the machine can run it. I write mine in bash, lots of people use perl, and the ones that come by default are (mostly?) written in C.

Anyway, once you've got the plugin into the directory, you've got to tell Nagios about it. Go to '/usr/local/nagios/etc/'. If you've got a recent installation (ie 3.0 or above) you should have an 'objects' directory. Inside there, by default, you'll have a "commands.cfg". Edit that, and check out the existing entries. They're all of the format

define command{
    command_name    command_name
    command_line    command_line

}

Put your new plugin in at the bottom.

define command{ 
    command_name      my_mysql_check
    command_line      $USER1$/whatever
} 

The "$USER1$" is a Nagios macro that points to the /usr/local/nagios/libexec directory. You can edit the "resources.cfg" to see what else is available, and even add macros.

Anyway, now that we've got the command in there, we've got to set up a service to take advantage of it.

Save the commands.cfg and edit "services.cfg". Notice that everything is in the format:

define service{
     host_name server
     service_description whatever
     etc 
     etc
} 

These set up the actual service description and the "host_name" assigns it to a server. Look at the documentation here when creating your service. The stuff in red is necessary, the others are used to refine how your service check behaves.

I hope this helped in some way. If not, please reply and let me know. You should also know that the default layout for Nagios configs is simple but unproductive. I wrote some documentation on how I lay mine out, and it's saved me a lot of time trying to find exactly the definition I was looking for. Depending on your installation, it may be overkill.

http://www.standalone-sysadmin.com/blog/2009/07/nagios-config/

Good luck!