diff options
-rw-r--r-- | REQUIREMENTS | 5 | ||||
-rw-r--r-- | configure.in | 87 | ||||
-rw-r--r-- | plugins/Makefile.am | 2 | ||||
-rw-r--r-- | plugins/check_mysql.c | 4 | ||||
-rw-r--r-- | plugins/check_mysql_query.c | 4 | ||||
-rw-r--r-- | plugins/t/check_mysql.t | 2 |
6 files changed, 63 insertions, 41 deletions
diff --git a/REQUIREMENTS b/REQUIREMENTS index 12552df..f16de93 100644 --- a/REQUIREMENTS +++ b/REQUIREMENTS | |||
@@ -40,11 +40,6 @@ check_mysql, check_mysql_query: | |||
40 | Redhat Powertools Source: mysql-3.20.32a-3.i386.rpm, mysql-devel-3.20.32a-3.i386.rpm (these seem to be broken, however) | 40 | Redhat Powertools Source: mysql-3.20.32a-3.i386.rpm, mysql-devel-3.20.32a-3.i386.rpm (these seem to be broken, however) |
41 | RPMS from www.mysql.org work better | 41 | RPMS from www.mysql.org work better |
42 | 42 | ||
43 | If you use the Mac OS X package from mysql.org, you need to add two soft links for ./configure | ||
44 | to find the mysql libraries correctly: | ||
45 | cd /usr/local/mysql/lib && ln -s . mysql | ||
46 | cd /usr/local/mysql/include && ln -s . mysql | ||
47 | |||
48 | check_pqsql: | 43 | check_pqsql: |
49 | - Requires the PostgreSQL libraries available from | 44 | - Requires the PostgreSQL libraries available from |
50 | http://www.postgresql.org | 45 | http://www.postgresql.org |
diff --git a/configure.in b/configure.in index d1ef954..e02dc89 100644 --- a/configure.in +++ b/configure.in | |||
@@ -253,49 +253,72 @@ else | |||
253 | fi | 253 | fi |
254 | LIBS="$_SAVEDLIBS" | 254 | LIBS="$_SAVEDLIBS" |
255 | 255 | ||
256 | |||
257 | dnl Check for mysql libraries | 256 | dnl Check for mysql libraries |
258 | _SAVEDLIBS="$LIBS" | 257 | _SAVEDLIBS="$LIBS" |
259 | _SAVEDCPPFLAGS="$CPPFLAGS" | 258 | _SAVEDCPPFLAGS="$CPPFLAGS" |
259 | FOUNDMYSQL="no" | ||
260 | AC_ARG_WITH(mysql, | 260 | AC_ARG_WITH(mysql, |
261 | ACX_HELP_STRING([--with-mysql=DIR], | 261 | ACX_HELP_STRING([--with-mysql=DIR], |
262 | [sets path to mysql installation (assumes lib/mysql and include subdirs]), | 262 | [sets path to mysql installation (assumes lib/lib64 and include subdirs)]), |
263 | MYSQL=$withval,) | 263 | MYSQL=$withval,) |
264 | # Find the mysql client libs | ||
264 | if test -n "$MYSQL"; then | 265 | if test -n "$MYSQL"; then |
266 | MYSQLLIBDIR=$MYSQL/lib | ||
267 | MYSQLLIB64DIR=$MYSQL/lib64 | ||
268 | elif test -f /usr/lib/libmysqlclient.so -o -f /usr/lib/libmysqlclient.a ; then | ||
269 | MYSQL="/usr" | ||
270 | MYSQLLIBDIR=$MYSQL/lib | ||
271 | MYSQLLIB64DIR=$MYSQL/lib64 | ||
272 | elif test -f /usr/lib/mysql/libmysqlclient.so -o -f /usr/lib/mysql/libmysqlclient.a ; then | ||
273 | MYSQL="/usr" | ||
265 | MYSQLLIBDIR=$MYSQL/lib/mysql | 274 | MYSQLLIBDIR=$MYSQL/lib/mysql |
266 | CPPFLAGS="-I$MYSQL/include" | 275 | MYSQLLIB64DIR=$MYSQL/lib64/mysql |
267 | AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz" check_mysql_LDFLAGS="-L$MYSQLLIBDIR " check_mysql_query_LDFLAGS="-L$MYSQLLIBDIR ",,-L$MYSQLLIBDIR -lz) | 276 | elif test -f /usr/local/lib/libmysqlclient.so -o -f /usr/local/lib/libmysqlclient.a ; then |
268 | AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient") | 277 | MYSQL="/usr/local" |
269 | elif test -f /usr/lib/libmysqlclient.so; then | 278 | MYSQLLIBDIR=$MYSQL/lib |
270 | AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz",,-lz) | 279 | MYSQLLIB64DIR=$MYSQL/lib64 |
271 | AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient") | 280 | elif test -f /usr/local/lib/mysql/libmysqlclient.so -o -f /usr/local/lib/mysql/libmysqlclient.a ; then |
272 | elif test -f /usr/lib/libmysqlclient.a; then | 281 | MYSQL="/usr/local" |
282 | MYSQLLIBDIR=$MYSQL/lib/mysql | ||
283 | MYSQLLIB64DIR=$MYSQL/lib64/mysql | ||
284 | elif test -f /usr/local/mysql/lib/libmysqlclient.so -o -f /usr/local/mysql/lib/libmysqlclient.a ; then | ||
285 | MYSQL="/usr/local/mysql" | ||
286 | MYSQLLIBDIR=$MYSQL/lib | ||
287 | MYSQLLIB64DIR=$MYSQL/lib64 | ||
288 | fi | ||
289 | |||
290 | # Check libs okay | ||
291 | if test -n "$MYSQL" ; then | ||
292 | CPPFLAGS="-L$MYSQLLIBDIR -L$MYSQLLIB64DIR" | ||
273 | AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz",,-lz) | 293 | AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz",,-lz) |
274 | AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient") | 294 | AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient") |
275 | elif test -f /usr/lib/mysql/libmysqlclient.so; then | ||
276 | AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz" check_mysql_LDFLAGS="-L/usr/lib/mysql" check_mysql_query_LDFLAGS="-L/usr/lib/mysql",,-L/usr/lib/mysql -lz) | ||
277 | AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient" check_mysql_LDFLAGS="-L/usr/lib/mysql" check_mysql_query_LDFLAGS="-L/usr/lib/mysql",,-L/usr/lib/mysql) | ||
278 | elif test -f /usr/lib/mysql/libmysqlclient.a; then | ||
279 | AC_CHECK_LIB(mysqlclient,mysql_init,MYSQLLIBS="-lmysqlclient -lz" check_mysql_LDFLAGS="-L/usr/lib/mysql" check_mysql_query_LDFLAGS="-L/usr/lib/mysql",,-L/usr/lib/mysql -lz) | ||
280 | AC_CHECK_LIB(mysqlclient,mysql_close,MYSQLLIBS="-lmysqlclient" check_mysql_LDFLAGS="-L/usr/lib/mysql" check_mysql_query_LDFLAGS="-L/usr/lib/mysql",,-L/usr/lib/mysql) | ||
281 | fi | 295 | fi |
296 | |||
297 | # Check headers okay | ||
282 | if test "$ac_cv_lib_mysqlclient_mysql_init" = "yes" -o "$ac_cv_lib_mysqlclient_mysql_close" = "yes"; then | 298 | if test "$ac_cv_lib_mysqlclient_mysql_init" = "yes" -o "$ac_cv_lib_mysqlclient_mysql_close" = "yes"; then |
283 | AC_CHECK_HEADERS(mysql/mysql.h mysql/errmsg.h, MYSQLINCLUDE="-I$MYSQL/include" ) | 299 | CPPFLAGS="-I$MYSQL/include" |
284 | if test "$ac_cv_header_mysql_mysql_h" = "yes" -a "$ac_cv_header_mysql_errmsg_h" = "yes"; then | 300 | AC_CHECK_HEADERS(mysql.h errmsg.h, FOUNDMYSQL="yes" MYSQLINCLUDE="-I$MYSQL/include") |
285 | EXTRAS="$EXTRAS check_mysql check_mysql_query" | 301 | if test x"$FOUNDMYSQL" != x"yes" ; then |
286 | AC_SUBST(MYSQLINCLUDE) | 302 | AC_CHECK_HEADERS(mysql/mysql.h mysql/errmsg.h, FOUNDMYSQL="yes" MYSQLINCLUDE="-I$MYSQL/include/mysql") |
287 | AC_SUBST(MYSQLLIBS) | 303 | fi |
288 | AC_SUBST(check_mysql_LDFLAGS) | 304 | fi |
289 | AC_SUBST(check_mysql_query_LDFLAGS) | 305 | |
290 | else | 306 | # Setup mysql plugins |
291 | AC_MSG_WARN([Skipping mysql plugin]) | 307 | if test $FOUNDMYSQL = "yes" ; then |
292 | AC_MSG_WARN([install mysql client headers to compile this plugin (see REQUIREMENTS).]) | 308 | EXTRAS="$EXTRAS check_mysql check_mysql_query" |
309 | if test -d $MYSQLLIB64DIR ; then | ||
310 | MYSQLLIBS="-L$MYSQLLIB64DIR -rpath $MYSQLLIB64DIR $MYSQLLIBS" | ||
311 | fi | ||
312 | if test -d $MYSQLLIBDIR ; then | ||
313 | MYSQLLIBS="-L$MYSQLLIBDIR -rpath $MYSQLLIBDIR $MYSQLLIBS" | ||
293 | fi | 314 | fi |
315 | AC_SUBST(MYSQLINCLUDE) | ||
316 | AC_SUBST(MYSQLLIBS) | ||
294 | else | 317 | else |
295 | AC_MSG_WARN([Skipping mysql plugin]) | 318 | AC_MSG_WARN([Skipping mysql plugin]) |
296 | AC_MSG_WARN([install mysql client libs to compile this plugin (see REQUIREMENTS).]) | 319 | AC_MSG_WARN([install mysql client libs to compile this plugin (see REQUIREMENTS).]) |
297 | fi | 320 | fi |
298 | CPPFLAGS="$_SAVEDCPPFLAGS $MYSQLINCLUDE" | 321 | CPPFLAGS="$_SAVEDCPPFLAGS" |
299 | LIBS="$_SAVEDLIBS" | 322 | LIBS="$_SAVEDLIBS" |
300 | 323 | ||
301 | AC_CHECK_HEADERS(unistd.h) | 324 | AC_CHECK_HEADERS(unistd.h) |
@@ -442,7 +465,7 @@ fi | |||
442 | 465 | ||
443 | 466 | ||
444 | dnl openssl detection/configuration | 467 | dnl openssl detection/configuration |
445 | if ! test "$with_openssl" = "no"; then | 468 | if ! test x"$with_openssl" = x"no"; then |
446 | dnl Check for OpenSSL location if it wasn't already specified | 469 | dnl Check for OpenSSL location if it wasn't already specified |
447 | if ! test -d "$with_openssl"; then | 470 | if ! test -d "$with_openssl"; then |
448 | for d in $OPENSSL_DIRS; do | 471 | for d in $OPENSSL_DIRS; do |
@@ -456,18 +479,20 @@ if ! test "$with_openssl" = "no"; then | |||
456 | _SAVEDLDFLAGS="$LDFLAGS" | 479 | _SAVEDLDFLAGS="$LDFLAGS" |
457 | dnl Check for OpenSSL header files | 480 | dnl Check for OpenSSL header files |
458 | unset FOUNDINCLUDE | 481 | unset FOUNDINCLUDE |
459 | CPPFLAGS="$CPPFLAGS -I$OPENSSL/include" | 482 | if test x"$with_openssl" != x"/usr" ; then |
460 | LDFLAGS="$LDFLAGS -R$OPENSSL/lib" | 483 | CPPFLAGS="$CPPFLAGS -I$with_openssl/include" |
484 | LDFLAGS="$LDFLAGS -R$with_openssl/lib" | ||
485 | fi | ||
461 | 486 | ||
462 | dnl check for openssl in $dir/include/openssl | 487 | dnl check for openssl in $dir/include/openssl |
463 | AC_CHECK_HEADERS(openssl/ssl.h openssl/x509.h openssl/rsa.h openssl/pem.h openssl/crypto.h openssl/err.h, | 488 | AC_CHECK_HEADERS(openssl/ssl.h openssl/x509.h openssl/rsa.h openssl/pem.h openssl/crypto.h openssl/err.h, |
464 | SSLINCLUDE="-I$OPENSSL/include" | 489 | SSLINCLUDE="-I$with_openssl/include" |
465 | FOUNDINCLUDE=yes, | 490 | FOUNDINCLUDE=yes, |
466 | FOUNDINCLUDE=no) | 491 | FOUNDINCLUDE=no) |
467 | dnl else check to see if $dir/include has it | 492 | dnl else check to see if $dir/include has it |
468 | if test "$FOUNDINCLUDE" = "no"; then | 493 | if test "$FOUNDINCLUDE" = "no"; then |
469 | AC_CHECK_HEADERS(ssl.h x509.h rsa.h pem.h crypto.h err.h, | 494 | AC_CHECK_HEADERS(ssl.h x509.h rsa.h pem.h crypto.h err.h, |
470 | SSLINCLUDE="-I$OPENSSL/include" | 495 | SSLINCLUDE="-I$with_openssl/include" |
471 | FOUNDINCLUDE=yes, | 496 | FOUNDINCLUDE=yes, |
472 | FOUNDINCLUDE=no) | 497 | FOUNDINCLUDE=no) |
473 | fi | 498 | fi |
diff --git a/plugins/Makefile.am b/plugins/Makefile.am index 7f9d745..9a1f6d0 100644 --- a/plugins/Makefile.am +++ b/plugins/Makefile.am | |||
@@ -63,7 +63,9 @@ check_ldap_LDADD = $(NETLIBS) $(LDAPLIBS) | |||
63 | check_load_LDADD = $(BASEOBJS) popen.o | 63 | check_load_LDADD = $(BASEOBJS) popen.o |
64 | check_mrtg_LDADD = $(BASEOBJS) | 64 | check_mrtg_LDADD = $(BASEOBJS) |
65 | check_mrtgtraf_LDADD = $(BASEOBJS) | 65 | check_mrtgtraf_LDADD = $(BASEOBJS) |
66 | check_mysql_CPPFLAGS = $(MYSQLINCLUDE) | ||
66 | check_mysql_LDADD = $(NETLIBS) $(MYSQLLIBS) | 67 | check_mysql_LDADD = $(NETLIBS) $(MYSQLLIBS) |
68 | check_mysql_query_CPPFLAGS = $(MYSQLINCLUDE) | ||
67 | check_mysql_query_LDADD = $(NETLIBS) $(MYSQLLIBS) | 69 | check_mysql_query_LDADD = $(NETLIBS) $(MYSQLLIBS) |
68 | check_nagios_LDADD = $(BASEOBJS) runcmd.o | 70 | check_nagios_LDADD = $(BASEOBJS) runcmd.o |
69 | check_nt_LDADD = $(NETLIBS) | 71 | check_nt_LDADD = $(NETLIBS) |
diff --git a/plugins/check_mysql.c b/plugins/check_mysql.c index 92ac7ff..9d547dd 100644 --- a/plugins/check_mysql.c +++ b/plugins/check_mysql.c | |||
@@ -25,8 +25,8 @@ const char *email = "nagiosplug-devel@lists.sourceforge.net"; | |||
25 | #include "utils.h" | 25 | #include "utils.h" |
26 | #include "netutils.h" | 26 | #include "netutils.h" |
27 | 27 | ||
28 | #include <mysql/mysql.h> | 28 | #include <mysql.h> |
29 | #include <mysql/errmsg.h> | 29 | #include <errmsg.h> |
30 | 30 | ||
31 | char *db_user = NULL; | 31 | char *db_user = NULL; |
32 | char *db_host = NULL; | 32 | char *db_host = NULL; |
diff --git a/plugins/check_mysql_query.c b/plugins/check_mysql_query.c index 321af7a..b542fb4 100644 --- a/plugins/check_mysql_query.c +++ b/plugins/check_mysql_query.c | |||
@@ -22,8 +22,8 @@ const char *email = "nagiosplug-devel@lists.sourceforge.net"; | |||
22 | #include "utils.h" | 22 | #include "utils.h" |
23 | #include "netutils.h" | 23 | #include "netutils.h" |
24 | 24 | ||
25 | #include <mysql/mysql.h> | 25 | #include <mysql.h> |
26 | #include <mysql/errmsg.h> | 26 | #include <errmsg.h> |
27 | 27 | ||
28 | char *db_user = NULL; | 28 | char *db_user = NULL; |
29 | char *db_host = NULL; | 29 | char *db_host = NULL; |
diff --git a/plugins/t/check_mysql.t b/plugins/t/check_mysql.t index 78413c6..852926a 100644 --- a/plugins/t/check_mysql.t +++ b/plugins/t/check_mysql.t | |||
@@ -48,7 +48,7 @@ SKIP: { | |||
48 | $result = NPTest->testCmd("./check_mysql -H $mysqlserver $mysql_login_details"); | 48 | $result = NPTest->testCmd("./check_mysql -H $mysqlserver $mysql_login_details"); |
49 | cmp_ok( $result->return_code, '==', 0, "Login okay"); | 49 | cmp_ok( $result->return_code, '==', 0, "Login okay"); |
50 | 50 | ||
51 | $result = NPTest->testCmd("./check_mysql -H $mysqlserver -u dummy"); | 51 | $result = NPTest->testCmd("./check_mysql -H $mysqlserver -u dummy -pdummy"); |
52 | cmp_ok( $result->return_code, '==', 2, "Login failure"); | 52 | cmp_ok( $result->return_code, '==', 2, "Login failure"); |
53 | like( $result->output, $bad_login_output, "Expected login failure message"); | 53 | like( $result->output, $bad_login_output, "Expected login failure message"); |
54 | 54 | ||