
Monitoring MySQL database queries using Centreon
Another marvel of monitoring with Centreon, is that it allows us to make queries to any type of database, in this post we will see how to query a MySQL database, We can launch any type of query that helps us to know the state or value that interests us, then we will be able to know that there are no blockages or that 'something’ He has not stopped writing on his table…
As usual, The first thing we will need is the plugin to use, In this document we will base ourselves on 'check_mysql_query’ that we can find in its official website, We download it and leave it in our plugins folder & We make it executable. It will be based on creating the Command to be used, here, in your website We have all the options if you want to see them, but go to the command we'll pass it as Argument 1 query to run on the MySQL server that we indicate (your IP or FQDN), in addition to validating us with the credentials and the indicated database:
$CENTREONPLUGINS$/check_mysql_query -q $ARG 1$ -H SERVIDOR_MYSQL -d BASE_DE_DATOS -u USERNAME -p PASSWORD -w 1: -c 1:
Eye! my Warning and Critical values I mark them to 1: indicating that if the query returns a value less than 1 (that is 0) as it will sing CRITICAL message. This, as is normal, can be established as additional arguments! As well as the user/pwd theme.
After creating the, as usual, we will now be able to create as many Services as we need, In this example I'll create a Service that will check if the vacuum cleaner is writing data to a table that has, where data such as your consumption is stored, use… in the argument we see that we have to put the Query that interests us, in this particular case, I look at how many records are written in the last few 15 minutes (since the vacuum cleaner is supposed to store this info in this MySQL database every 15min).
And nothing! As usual, We save the configuration & we export it and return to the Monitoring view, We can search for the service and force it to run to see the final result! If everything has gone well, we will already have this particular Table of a MySQL database monitored! Phenomenal! Go for more!