Skip to content

Commit

Permalink
net-analyzer/nagios-plugins: new revision to fix build failure with M…
Browse files Browse the repository at this point in the history
…ariaDB.

The latest -r2 adds a patch (which I've sent upstream) to fix a build
failure against newer versions of MariaDB.

Bug: https://bugs.gentoo.org/633548
Bug: https://bugs.gentoo.org/635106
Package-Manager: Portage-2.3.8, Repoman-2.3.3
  • Loading branch information
orlitzky committed Oct 27, 2017
1 parent d7029df commit 20d288e
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 0 deletions.
100 changes: 100 additions & 0 deletions net-analyzer/nagios-plugins/files/define-own-mysql-port-constant.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
From 43ff2e8607c0b7095c2a4dcab6e466bc67e2e2ff Mon Sep 17 00:00:00 2001
From: Michael Orlitzky <[email protected]>
Date: Thu, 26 Oct 2017 15:01:17 -0400
Subject: [PATCH 1/3] plugins/check_mysql*.c: define our own default MySQL
port.

The MYSQL_PORT constant used to be defined in mysql.h, and was used as
the default port in the two plugins check_mysql and check_mysql_query.
Now that mysql.h no longer defines that constant, our plugins fail to
build against newer versions of MySQL and MariaDB.

Since MYSQL_PORT used the "default port" on the local system, it
actually was not the best choice as the default for the check plugins:
when monitoring remote MySQL servers, the usual default of 3306 is
more likely to be correct than whatever the local server happens to be
listening on.

As a result, we fix the issue by defining our own constant, called
CHECK_PORT_DEFAULT, as "3306" at the top of both check_mysql.c and
check_mysql_query.c. The existing uses of MYSQL_PORT have been changed
to use the new CHECK_PORT_DEFAULT.

This change is backwards-incompatible: any users who compiled in a
MYSQL_PORT other than 3306 and who were running their checks on the
same server as the database will now need to specify that port
explicitly.

Closes: https://github.com/nagios-plugins/nagios-plugins/issues/288
---
plugins/check_mysql.c | 7 +++++--
plugins/check_mysql_query.c | 7 +++++--
2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/plugins/check_mysql.c b/plugins/check_mysql.c
index 83f89c85..c0b61292 100644
--- a/plugins/check_mysql.c
+++ b/plugins/check_mysql.c
@@ -36,6 +36,9 @@ const char *email = "[email protected]";

#define SLAVERESULTSIZE 70

+/* The default port that MySQL servers listen on. */
+#define CHECK_PORT_DEFAULT 3306
+
#include "common.h"
#include "utils.h"
#include "utils_base.h"
@@ -58,7 +61,7 @@ char *ciphers = NULL;
bool ssl = false;
char *opt_file = NULL;
char *opt_group = NULL;
-unsigned int db_port = MYSQL_PORT;
+unsigned int db_port = CHECK_PORT_DEFAULT;
int check_slave = 0, warn_sec = 0, crit_sec = 0;
int ignore_auth = 0;
int verbose = 0;
@@ -505,7 +508,7 @@ void
print_help (void)
{
char *myport;
- xasprintf (&myport, "%d", MYSQL_PORT);
+ xasprintf (&myport, "%d", CHECK_PORT_DEFAULT);

print_revision (progname, NP_VERSION);

diff --git a/plugins/check_mysql_query.c b/plugins/check_mysql_query.c
index 436e0685..e9c3acfb 100644
--- a/plugins/check_mysql_query.c
+++ b/plugins/check_mysql_query.c
@@ -33,6 +33,9 @@ const char *progname = "check_mysql_query";
const char *copyright = "1999-2014";
const char *email = "[email protected]";

+/* The default port that MySQL servers listen on. */
+#define CHECK_PORT_DEFAULT 3306
+
#include "common.h"
#include "utils.h"
#include "utils_base.h"
@@ -48,7 +51,7 @@ char *db_pass = NULL;
char *db = NULL;
char *opt_file = NULL;
char *opt_group = NULL;
-unsigned int db_port = MYSQL_PORT;
+unsigned int db_port = CHECK_PORT_DEFAULT;

int process_arguments (int, char **);
int validate_arguments (void);
@@ -300,7 +303,7 @@ void
print_help (void)
{
char *myport;
- xasprintf (&myport, "%d", MYSQL_PORT);
+ xasprintf (&myport, "%d", CHECK_PORT_DEFAULT);

print_revision (progname, NP_VERSION);

--
2.13.6

Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ DOCS=(
THANKS
)

PATCHES=( "${FILESDIR}/define-own-mysql-port-constant.patch" )

src_prepare() {
default

Expand Down

0 comments on commit 20d288e

Please sign in to comment.