mysqlclient detection in Nagios Plugins

It’s a real pain writing configure scripts. Autoconf makes things easier, but it is really hard to autodetect software correctly.

The plugins are particularly onerous because usually a single executable, say check_ldap, has requirements that no other plugin has.

Lately, I’ve been trying to work out what’s the best way of detecting mysqlclient. For pre-1.4.7, we used mysql_config to gives us the list of necessary libraries at compile time. On my Debian server, mysql_config --libs says: -L/usr/lib -lmysqlclient -lz -lcrypt -lnsl -lm. This was a much better way than trying to manually work out all the various libraries required. So configure said: “if mysql_config exists, compile check_mysql”.

Good, eh? Nope.

On some Redhat derived systems, it appears that mysql_config exists, but the headers do not. Sounds like a packaging problem to me, but we started to get lots of emails because a ./configure; make was giving errors when compiling the Nagios Plugins.

So an extra test was added: AC_CHECK_LIB. If you can call mysql_init, then allow check_mysql to compile. This was in 1.4.7, released just yesterday.

Phew! Sorted!

Not quite.

Now, it’s too aggressive! I have a Redhat server that no longer picks up mysql because AC_CHECK_LIB fails. And this wouldn’t be detected on the Tinderbox servers, because we ignore any plugins that don’t get compiled. Sigh.

It turns out the failure is because AC_CHECK_LIB needs to be told the dependent libraries. We think we have a good solution now. It seems others use the same techniques too.

As a bonus, I’ve separated out the mysql detection into an m4 file, called m4/np_mysqlclient.m4, so if there’s another project that needs mysql detection, they should be able to just take that m4 file, run autoconf with it and use our routines.

This should be in a 1.4.8 release, coming soon.

Hopefully other projects can use this, in the same way we use tricks from other projects.

Bookmark and Share

0 Response to “mysqlclient detection in Nagios Plugins”


  • No Comments

Leave a Reply

You must login to post a comment.