aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am2
-rw-r--r--NEWS10
-rw-r--r--README5
-rw-r--r--acinclude.m42
-rw-r--r--configure.ac4
-rw-r--r--setup/Makefile.am2
-rw-r--r--setup/mysqlstat-setup.pl8
-rw-r--r--src/Makefile.am2
-rw-r--r--src/mysqlstat.86
-rw-r--r--src/mysqlstat.c51
-rw-r--r--src/mysqlstat.h2
-rw-r--r--src/mysqlstat_mib.mib2c2
12 files changed, 57 insertions, 39 deletions
diff --git a/Makefile.am b/Makefile.am
index df581f5..d0f6fbb 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,5 +1,5 @@
# This file is part of Mysqlstat -*- autoconf -*-
-# Copyright (C) 2016 Sergey Poznyakoff
+# Copyright (C) 2016-2020 Sergey Poznyakoff
#
# Mysqlstat is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/NEWS b/NEWS
index ed6df2a..fe61abd 100644
--- a/NEWS
+++ b/NEWS
@@ -1,9 +1,13 @@
-Mysqlstatb NEWS -- history of user-visible changes. 2016-06-08
-Copyright (C) 2016 Sergey Poznyakoff
+Mysqlstat NEWS -- history of user-visible changes. 2020-01-23
See the end of file for copying conditions.
Please send Mysqlstat bug reports to <bug-mysqlstat@gnu.org.ua>
+Version 1,1, 2020-01-23
+
+* Minor fixes in mysqlstat-setup
+* Provide default values for NULL columns
+
Version 1.0, 2016-06-08
Initial release.
@@ -11,7 +15,7 @@ Initial release.
* Copyright information:
-Copyright (C) 2016 Sergey Poznyakoff
+Copyright (C) 2016-2020 Sergey Poznyakoff
Permission is granted to anyone to make or distribute verbatim copies
of this document as received, in any medium, provided that the
diff --git a/README b/README
index 87c029a..f99699c 100644
--- a/README
+++ b/README
@@ -1,5 +1,4 @@
Mysqlstat README
-Copyright (C) 2016 Sergey Poznyakoff
See the end of file for copying conditions.
* Introduction
@@ -81,7 +80,7 @@ Send bug reports and suggestions to <bug-mysqlstat@gnu.org.ua>.
* Copyright information:
-Copyright (C) 2016 Sergey Poznyakoff
+Copyright (C) 2016-2020 Sergey Poznyakoff
Permission is granted to anyone to make or distribute verbatim copies
of this document as received, in any medium, provided that the
@@ -101,4 +100,4 @@ version-control: never
End:
- \ No newline at end of file
+
diff --git a/acinclude.m4 b/acinclude.m4
index 1f9ba07..a843d55 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -1,5 +1,5 @@
# This file is part of Mysqlstat -*- autoconf -*-
-# Copyright (C) 2014-2016 Sergey Poznyakoff
+# Copyright (C) 2014-2020 Sergey Poznyakoff
#
# Mysqlstat is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/configure.ac b/configure.ac
index 3ecbdc2..8d3487d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,5 +1,5 @@
# This file is part of Mysqlstat -*- autoconf -*-
-# Copyright (C) 2016 Sergey Poznyakoff
+# Copyright (C) 2016-2020 Sergey Poznyakoff
#
# Mysqlstat is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -15,7 +15,7 @@
# along with Mysqlstat. If not, see <http://www.gnu.org/licenses/>.
AC_PREREQ(2.69)
-AC_INIT([mysqlstat], 1.0, [bug-mailstat@gnu.org])
+AC_INIT([mysqlstat], 1.1, [bug-mysqlstat@gnu.org.ua])
AC_CONFIG_SRCDIR(src/mysqlstat_mib.mib2c)
AM_CONFIG_HEADER(config.h)
AC_CONFIG_AUX_DIR([build-aux])
diff --git a/setup/Makefile.am b/setup/Makefile.am
index 0aa4dfe..12d1acb 100644
--- a/setup/Makefile.am
+++ b/setup/Makefile.am
@@ -1,5 +1,5 @@
# This file is part of Mysqlstat -*- automake -*-
-# Copyright (C) 2016 Sergey Poznyakoff
+# Copyright (C) 2016-2020 Sergey Poznyakoff
#
# Mysqlstat is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/setup/mysqlstat-setup.pl b/setup/mysqlstat-setup.pl
index 6c8eecc..53e14d8 100644
--- a/setup/mysqlstat-setup.pl
+++ b/setup/mysqlstat-setup.pl
@@ -1,6 +1,6 @@
#!/usr/bin/perl
# This file is part of Mysqlstat
-# Copyright (C) 2016 Sergey Poznyakoff
+# Copyright (C) 2016-2020 Sergey Poznyakoff
#
# Mysqlstat is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -263,15 +263,17 @@ sub db_modify {
my $dbd = shift;
my $q = shift;
my $sth = $dbd->prepare($q);
- my $res = $sth->execute(@_) or croak($sth->errstr);
+ my $res = $sth->execute(@_) or die($sth->errstr);
$sth->finish;
return $res;
}
sub sql_create_user {
my $dbd = db_connect();
- my $q = q{GRANT PROCESS, REPLICATION CLIENT ON *.* TO ?@?};
my @args = ($snmp_user, $snmp_host);
+ db_modify($dbd, q{CREATE USER IF NOT EXISTS ?@?}, @args);
+
+ my $q = q{GRANT PROCESS, REPLICATION CLIENT ON *.* TO ?@?};
if ($snmp_password) {
push @args, $snmp_password;
$q .= ' IDENTIFIED BY ?';
diff --git a/src/Makefile.am b/src/Makefile.am
index c17447f..bd85621 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,5 +1,5 @@
# This file is part of Mysqlstat -*- automake -*-
-# Copyright (C) 2016 Sergey Poznyakoff
+# Copyright (C) 2016-2020 Sergey Poznyakoff
#
# Mysqlstat is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/src/mysqlstat.8 b/src/mysqlstat.8
index e0bcb7f..6eb62ca 100644
--- a/src/mysqlstat.8
+++ b/src/mysqlstat.8
@@ -1,5 +1,5 @@
.\" This file is part of Mysqlstat -*- nroff -*-
-.\" Copyright (C) 2016 Sergey Poznyakoff
+.\" Copyright (C) 2016-2020 Sergey Poznyakoff
.\"
.\" Mysqlstat is free software; you can redistribute it and/or modify
.\" it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
.\"
.\" You should have received a copy of the GNU General Public License
.\" along with Mysqlstat. If not, see <http://www.gnu.org/licenses/>.
-.TH MYSQLSTAT 8 "June 8, 2016" "mysqlstat"
+.TH MYSQLSTAT 8 "January 23, 2020" "mysqlstat"
.SH NAME
mysqlstat \- net-snmp module for collecting MySQL statistics
.SH SYNOPSIS
@@ -100,7 +100,7 @@ Sergey Poznyakoff
.SH "BUG REPORTS"
Report bugs to <gray@gnu.org>.
.SH COPYRIGHT
-Copyright \(co 2016 Sergey Poznyakoff
+Copyright \(co 2016-2020 Sergey Poznyakoff
.br
.na
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
diff --git a/src/mysqlstat.c b/src/mysqlstat.c
index 4eb5a18..7b25c3f 100644
--- a/src/mysqlstat.c
+++ b/src/mysqlstat.c
@@ -1,5 +1,5 @@
/* This file is part of Mysqlstat
- * Copyright (C) 2016 Sergey Poznyakoff
+ * Copyright (C) 2016-2020 Sergey Poznyakoff
*
* Mysqlstat is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -18,6 +18,7 @@
#include <mysql/mysql.h>
#undef NDEBUG
#include <assert.h>
+#include <errno.h>
#include "mysqlstat_mib.h"
static char *config_file = CONFDIR "/mysqlstat.cnf";
@@ -182,23 +183,34 @@ process_first(struct process_list **state)
static long
val_Slave_IO_Running(char const *val)
{
- if (strcmp(val, "Yes") == 0)
- return 1;
- else if (strcmp(val, "No") == 0)
- return 2;
- else if (strcmp(val, "Connected") == 0)
- return 3;
+ if (val) {
+ if (strcmp(val, "Yes") == 0)
+ return 1;
+ else if (strcmp(val, "No") == 0)
+ return 2;
+ else if (strcmp(val, "Connected") == 0)
+ return 3;
+ }
return 4;
}
static long
val_bool(char const *val)
{
- if (strcmp(val, "Yes") == 0)
+ if (val && strcmp(val, "Yes") == 0)
return 1;
return 2;
}
+static u_long
+var_num(char const *val, u_long dfl)
+{
+ if (!val)
+ return dfl;
+ return strtoul(val, NULL, 10);
+}
+
+
static void
store_slave_status_row(struct replSlaveStatusTable_entry *ent,
char const *name, char const *value)
@@ -210,17 +222,17 @@ store_slave_status_row(struct replSlaveStatusTable_entry *ent,
} else if (STREQ(Master_User, name)) {
ASSIGN_STRING(ent, replMasterUser, value);
} else if (STREQ(Master_Port, name)) {
- ent->replMasterPort = strtoul(value, NULL, 10);
+ ent->replMasterPort = var_num(value, 65536);
} else if (STREQ(Connect_Retry, name)) {
- ent->replConnectRetry = strtoul(value, NULL, 10);
+ ent->replConnectRetry = var_num(value, 0);
} else if (STREQ(Master_Log_File, name)) {
ASSIGN_STRING(ent, replMasterLogFile, value);
} else if (STREQ(Read_Master_Log_Pos, name)) {
- ent->replReadMasterLogPos = strtoul(value, NULL, 10);
+ ent->replReadMasterLogPos = var_num(value, 0);
} else if (STREQ(Relay_Log_File, name)) {
ASSIGN_STRING(ent, replRelayLogFile, value);
} else if (STREQ(Relay_Log_Pos, name)) {
- ent->replRelayLogPos = strtoul(value, NULL, 10);
+ ent->replRelayLogPos = var_num(value, 0);
} else if (STREQ(Relay_Master_Log_File, name)) {
ASSIGN_STRING(ent, replMasterLogFile, value);
} else if (STREQ(Slave_IO_Running, name)) {
@@ -240,19 +252,19 @@ store_slave_status_row(struct replSlaveStatusTable_entry *ent,
} else if (STREQ(Replicate_Wild_Ignore_Table, name)) {
ASSIGN_STRING(ent, replReplicateWildIgnoreTable, value);
} else if (STREQ(Last_IO_Errno, name)) {
- ent->replLastIOErrno = strtoul(value, NULL, 10);
+ ent->replLastIOErrno = var_num(value, EINVAL);
} else if (STREQ(Last_IO_Error, name)) {
ASSIGN_STRING(ent, replLastIOError, value);
} else if (STREQ(Last_SQL_Errno, name)) {
- ent->replLastSQLErrno = strtoul(value, NULL, 10);
+ ent->replLastSQLErrno = var_num(value, 0);
} else if (STREQ(Last_SQL_Error, name)) {
ASSIGN_STRING(ent, replLastSQLError, value);
} else if (STREQ(Skip_Counter, name)) {
- ent->replSkipCounter = strtoul(value, NULL, 10);
+ ent->replSkipCounter = var_num(value, 0);
} else if (STREQ(Exec_Master_Log_Pos, name)) {
- ent->replExecMasterLogPos = strtoul(value, NULL, 10);
+ ent->replExecMasterLogPos = var_num(value, 0);
} else if (STREQ(Relay_Log_Space, name)) {
- ent->replRelayLogSpace = strtoul(value, NULL, 10);
+ ent->replRelayLogSpace = var_num(value, 0);
} else if (STREQ(Until_Condition, name)) {
ASSIGN_STRING(ent, replUntilCondition, value);
} else if (STREQ(Until_Log_File, name)) {
@@ -272,7 +284,8 @@ store_slave_status_row(struct replSlaveStatusTable_entry *ent,
} else if (STREQ(Master_SSL_Key, name)) {
ASSIGN_STRING(ent, replMasterSSLKey, value);
} else if (STREQ(Seconds_Behind_Master, name)) {
- ent->replSecondsBehindMaster = strtoul(value, NULL, 10) * 100;
+ /* FIXME: default? */
+ ent->replSecondsBehindMaster = var_num(value, 0) * 100;
} else if (STREQ(Master_SSL_Verify_Server_Cert, name)) {
ent->replMasterSSLVerifyServerCert = val_bool(value);
} else {
@@ -375,7 +388,7 @@ store_master_status_row(struct replMasterStatusTable_entry *ent,
if (STREQ(File, name)) {
ASSIGN_STRING(ent, replMasterCurrentLogFile, value);
} else if (STREQ(Position, name)) {
- ent->replMasterCurrentLogPos = strtoul(value, NULL, 10);
+ ent->replMasterCurrentLogPos = var_num(value, 0);
} else if (STREQ(Binlog_Do_DB, name)) {
ASSIGN_STRING(ent, replMasterBinlogDoDB, value);
} else if (STREQ(Binlog_Ignore_DB, name)) {
diff --git a/src/mysqlstat.h b/src/mysqlstat.h
index cc10749..4917c1b 100644
--- a/src/mysqlstat.h
+++ b/src/mysqlstat.h
@@ -1,5 +1,5 @@
/* This file is part of Mysqlstat -*- autoconf -*-
- * Copyright (C) 2016 Sergey Poznyakoff
+ * Copyright (C) 2016-2020 Sergey Poznyakoff
*
* Mysqlstat is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
diff --git a/src/mysqlstat_mib.mib2c b/src/mysqlstat_mib.mib2c
index 45f8885..0a24af7 100644
--- a/src/mysqlstat_mib.mib2c
+++ b/src/mysqlstat_mib.mib2c
@@ -1,5 +1,5 @@
# This file is part of Mysqlstat -*- c -*-
-# Copyright (C) 2016 Sergey Poznyakoff
+# Copyright (C) 2016-2020 Sergey Poznyakoff
#
# Mysqlstat is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

Return to:

Send suggestions and report system problems to the System administrator.