Using check_mk mysql plugin with a password


Bastian Kuhn has started an awesome series of check_mk related posts on his blog, including a few where he leads through creating a plugin for mysql.
The plugin can monitor all variables visible in the mysql status output.

It’s great to see some more plugins being added to the check_mk exchange and this will surely be a very high profile one πŸ™‚

I definitely had to give it a try and it’s working:

The only issue was I have systems that are quite publicly accessible, so most ways of passing a password to mysql would not just work for me[tm]. I didn’t wanna use anything visible a command line option or envvar. (Moreso, I found that $MY_PWD does not even work??)

I got a working result using the following changes to the agent plugin:
if pgrep mysql > /dev/null ; then
echo "<<<mysql_status>>>"
mysql --defaults-extra-file=/root/.my.cnf -e "show status;" -s 2>&1
fi

and creating a file called /root/.my.cnf (mode 400) that contains
[client]
password=mypassword

Once these changes were in use, I could see the agent output using netcat etc.

I created a etc/check_mk/conf.d/mysql.mk with the following options – but note I’m not a DBA so these are just things that looked reasonable to monitor.

mysql_status_vars = [
( "Innodb_os_log_pending_fsyncs", 5, 10),
( "Innodb_buffer_pool_pages_dirty", 20, 40),
( "Innodb_row_lock_current_waits", 5, 10),
( "Innodb_row_lock_time_avg", None, None),
( "Innodb_row_lock_time_max", None, None),
( "Created_tmp_files", None, None),
]

One downside of the current (tutorial!) implementation is that you can’t just specify values that need to be calculated. (% of free buffers or such). but you can just add specific sections for those in the check and let him know πŸ™‚

Worst thing is that my Perf-o-Meters are still broken!

Advertisements

4 thoughts on “Using check_mk mysql plugin with a password

  1. Hey Florian

    du solltest den Quelltext des Agent Plugins in pre Tags setzen.
    So stimmt die Ausgabe nicht, z.B. wird die Sektion Ausgabe nicht angezeigt
    weil vom Browser als HTML Tag interpretiert πŸ™‚

    Grüße Basti

  2. Hi & guten morgen πŸ™‚

    mit pre hat – zumindest immer wenn ich es probiere – wordpress wieder ganz eigene Probleme. Ich hatte das code tag verwendet, aber auch das will wie bemerkt, nicht mitspielen.

    ich miste das dann demnaechst aus πŸ™‚

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s