Nagios Check Calculated on Mysql Server Variables

Posted in: Technical Track

Nagios Check For Calculating Based on Mysql Server Variables

Recently we needed to make a change for a client to one of our mysql monitoring tools so I thought it would be a good opportunity to highlight the tool and discuss some of the changes that I made.

You can access the tool on Github from our public repository here.

Before this change if you were using either the “varcomp” or “lastrun-varcomp” modes, it would only return a WARNING if your criteria for comparison were exceeded. In the new version, both WARNING and CRITICAL states can return to nagios. Here is an example: Let’s say you want to alert on maximum connections, but the number of maximum connections is different for different hosts. Instead of writing distinct per/host checks, you can use this check to do a simple calculation and alert on the result of that calculation. In this case you want to send a warning when your connections exceeds 75% of max connections and alert when it reaches 80%. The entry in your nagios config file might look something like this: -H $HOSTADDRESS$ -u $ARG1$ -p $ARG2$ –mode varcomp –expression “Threads_connected / max_connections * 100″ –comparison_warning=”> ‘$ARG3$'” –comparison_critical “> ‘$ARG4$’ –shortname percent_max_connections

Where the expression flag uses the names that are returned from any of “FULL PROCESSLIST”, “ENGINE INNODB STATUS”, “GLOBAL VARIABLES”, “GLOBAL STATUS”, or “SLAVE STATUS”. The comparison_warning and comparison_critical flags are going to be evaluated in perl, so ensure that it is a valid perl expression (in this case you could use either > or -gt. You’ll definitely need to test out your commands with a few different use cases to ensure you have good syntax. When a varcomp or lastrun-varcomp check is run, the results are kept in a local cache file against which you can make comparisons. So, to give a ridiculous example, if you want to ensure that the number of open table definitions didn’t increase too much between samples, you could do something like this -H $HOSTADDRESS$ -u $ARG1$ -p $ARG2$ –mode lastrun-varcomp –expression “current{Open_table_definitions} – lastrun{Open_table_definitions}” –comparison_warning=”> 10″ –comparison_critical “> 20” –shortname increase_in_open_table_defs

Where the notation current{} and lastrun{} refer to which sample time you want. You can see more details on all the features of the script in the README on the plugin page. We welcome any comments and suggestions.



Want to talk with an expert? Schedule a call with our team to get the conversation started.

No comments

Leave a Reply

Your email address will not be published. Required fields are marked *