Hello community,
here is the log from the commit of package mylvmbackup for openSUSE:Factory checked in at 2014-12-10 23:44:53
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/mylvmbackup (Old)
and /work/SRC/openSUSE:Factory/.mylvmbackup.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "mylvmbackup"
Changes:
--------
--- /work/SRC/openSUSE:Factory/mylvmbackup/mylvmbackup.changes 2014-09-17 17:27:15.000000000 +0200
+++ /work/SRC/openSUSE:Factory/.mylvmbackup.new/mylvmbackup.changes 2014-12-10 23:44:44.000000000 +0100
@@ -1,0 +2,12 @@
+Tue Dec 2 14:48:09 UTC 2014 - lars@linux-schulserver.de
+
+- update to 0.16:
+ + Merged SNMP support from Alexandre Anriot - this adds support
+ for sending out SNMP traps in case of backup successes or
+ failures.
+ + BUG#1351000: fixed crash when specifying both --help and
+ $mail_report_on was set to 'always'
+- recommend MIME::Lite for mail report feature
+- recommend Net::SNMP for SNMP feature
+
+-------------------------------------------------------------------
Old:
----
mylvmbackup-0.15.tar.gz
New:
----
mylvmbackup-0.16.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ mylvmbackup.spec ++++++
--- /var/tmp/diff_new_pack.2l4oYR/_old 2014-12-10 23:44:44.000000000 +0100
+++ /var/tmp/diff_new_pack.2l4oYR/_new 2014-12-10 23:44:44.000000000 +0100
@@ -17,7 +17,7 @@
Name: mylvmbackup
-Version: 0.15
+Version: 0.16
Release: 0
Summary: Utility for creating MySQL backups via LVM snapshots
License: GPL-2.0+
@@ -36,6 +36,8 @@
Requires: perl(File::Temp)
Requires: perl(Getopt::Long)
Requires: perl(Sys::Hostname)
+Recommends: perl(MIME::Lite)
+Recommends: perl(Net::SNMP)
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildArch: noarch
++++++ mylvmbackup-0.15.tar.gz -> mylvmbackup-0.16.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mylvmbackup-0.15/CREDITS new/mylvmbackup-0.16/CREDITS
--- old/mylvmbackup-0.15/CREDITS 2013-05-30 14:56:15.000000000 +0200
+++ new/mylvmbackup-0.16/CREDITS 2014-11-21 09:48:39.000000000 +0100
@@ -56,7 +56,11 @@
warnings about a leaked file descriptor (DBD:mysql does not add
FD_CLOEXEC on the MySQL socket, requires DBD::mysql 4.019 and above)
-Alexandre Anriot contributed patches to provide the mail reporting
-method, which sends the log output via email as well as the "purge"
-action and "backupretention" option that allows to only keep a
-defined number of previous backups in the backup directory.
+Alexandre Anriot contributed multiple patches:
+
+ - The mail reporting method, which sends the log output via email.
+ - The "purge" action.
+ - The "backupretention" option that allows to only keep a defined number
+ of previous backups in the backup directory.
+ - SNMP support, which provides sending SNMP traps to specified SNMP target
+ hosts to indicate success or failure of a backup run.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mylvmbackup-0.15/ChangeLog new/mylvmbackup-0.16/ChangeLog
--- old/mylvmbackup-0.15/ChangeLog 2014-02-22 22:16:33.000000000 +0100
+++ new/mylvmbackup-0.16/ChangeLog 2014-11-21 09:48:39.000000000 +0100
@@ -1,3 +1,12 @@
+2014-09-14 Lenz Grimmer
+
+ - Merged SNMP support from Alexandre Anriot
+
+2014-09-14 Lenz Grimmer
+
+ - BUG#1351000: fixed crash when specifying both --help and $mail_report_on
+ was set to 'always'
+
2014-02-22 Lenz Grimmer
- BUG#1283094: The Option "--recoveryopts" did not actually work when
@@ -23,7 +32,7 @@
2013-08-08 Korjavin Ivan
-- Added zbackup backup type
+ - Added zbackup backup type
2013-06-11 Lenz Grimmer
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mylvmbackup-0.15/Makefile new/mylvmbackup-0.16/Makefile
--- old/mylvmbackup-0.15/Makefile 2013-06-27 05:56:26.000000000 +0200
+++ new/mylvmbackup-0.16/Makefile 2014-09-14 12:23:17.000000000 +0200
@@ -38,7 +38,7 @@
# define some variables
NAME = mylvmbackup
-VERSION = 0.15
+VERSION = 0.16
BUILDDATE = $(shell date +%Y-%m-%d)
MAN1 = man/$(NAME).1
HOOKS := $(wildcard hooks/*.pm)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mylvmbackup-0.15/README new/mylvmbackup-0.16/README
--- old/mylvmbackup-0.15/README 2014-02-16 02:40:04.000000000 +0100
+++ new/mylvmbackup-0.16/README 2014-11-21 09:48:39.000000000 +0100
@@ -51,8 +51,11 @@
is considered to be the backup).
mylvmbackup also provides several methods for logging and reporting the
-progress and success of a backup run. The log messages can either be printed to
-the console (STDOUT), logged via syslog or sent to you via email.
+progress and success of a backup run. The log messages can either be printed
+to the console (STDOUT) or logged via syslog.
+
+Additionally, a report can be sent to you via email, and you can receive
+notifications about failures or successes via SNMP.
It is required to run mylvmbackup on the same host where the MySQL server runs.
If your MySQL daemon is not listening on localhost or using the default socket
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mylvmbackup-0.15/man/mylvmbackup.1 new/mylvmbackup-0.16/man/mylvmbackup.1
--- old/mylvmbackup-0.15/man/mylvmbackup.1 2014-02-16 03:01:54.000000000 +0100
+++ new/mylvmbackup-0.16/man/mylvmbackup.1 2014-11-21 09:55:11.000000000 +0100
@@ -1,4 +1,4 @@
-.\" Automatically generated by Pod::Man 2.25 (Pod::Simple 3.16)
+.\" Automatically generated by Pod::Man 2.27 (Pod::Simple 3.28)
.\"
.\" Standard preamble:
.\" ========================================================================
@@ -38,6 +38,8 @@
. ds PI \(*p
. ds L" ``
. ds R" ''
+. ds C`
+. ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
@@ -48,17 +50,24 @@
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
-.ie \nF \{\
-. de IX
-. tm Index:\\$1\t\\n%\t"\\$2"
+.\"
+.\" Avoid warning from groff about undefined register 'F'.
+.de IX
..
-. nr % 0
-. rr F
-.\}
-.el \{\
-. de IX
+.nr rF 0
+.if \n(.g .if rF .nr rF 1
+.if (\n(rF:(\n(.g==0)) \{
+. if \nF \{
+. de IX
+. tm Index:\\$1\t\\n%\t"\\$2"
..
+. if !\nF==2 \{
+. nr % 0
+. nr F 2
+. \}
+. \}
.\}
+.rr rF
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear. Run. Save yourself. No user-serviceable parts.
@@ -124,7 +133,7 @@
.\" ========================================================================
.\"
.IX Title "MYLVMBACKUP 1"
-.TH MYLVMBACKUP 1 "2014-02-16" "perl v5.14.2" "User Contributed Perl Documentation"
+.TH MYLVMBACKUP 1 "2014-11-21" "perl v5.18.2" "User Contributed Perl Documentation"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
@@ -157,7 +166,7 @@
to perform the archiving.
.PP
The \fIrsync\fR backup can perform both local backups as well as backing up to a
-remote server using rsyncd or rsync via \s-1SSH\s0.
+remote server using rsyncd or rsync via \s-1SSH.\s0
.PP
\&\fIrsnap\fR is a wrapper around \fIrsync\fR to automatically maintain and rotate a
given number of last backups (7 by default). It utilizes hard links to link to
@@ -178,8 +187,10 @@
.PP
\&\fImylvmbackup\fR also provides several methods for logging and reporting the
progress and success of a backup run. The log messages can either be printed
-to the console (\s-1STDOUT\s0) or logged via \fIsyslog\fR. Additionally, a report can be
-sent to you via email.
+to the console (\s-1STDOUT\s0) or logged via \fIsyslog\fR.
+.PP
+Additionally, a report can be sent to you via email, and you can receive
+notifications about failures or successes via \s-1SNMP.\s0
.SH "GENERAL HINTS"
.IX Header "GENERAL HINTS"
It is required to run \fImylvmbackup\fR on the same host where the MySQL server
@@ -198,7 +209,7 @@
the backup directory.
.PP
If you plan to back up InnoDB tables using \s-1LVM\s0 snapshots, be advised that it
-is not sufficient to lock the tables and issue the \fI\s-1FLUSH\s0 \s-1TABLES\s0\fR command to
+is not sufficient to lock the tables and issue the \fI\s-1FLUSH TABLES\s0\fR command to
get the table files into a consistent state. When starting the MySQL server
from these restored files, InnoDB will detect these tables as being in an
inconsistent state and will perform a log recovery run before the tables can be
@@ -250,7 +261,7 @@
before a connection to the database server is established
.IP "\fBpreflush\fR" 4
.IX Item "preflush"
-before calling \s-1FLUSH\s0 \s-1TABLES\s0
+before calling \s-1FLUSH TABLES\s0
.IP "\fBpresnapshot\fR" 4
.IX Item "presnapshot"
before the file system snapshot is created
@@ -355,7 +366,7 @@
The default is \fI\-\-skip\-networking \-\-skip\-grant \-\-bootstrap \-\-skip\-syslog \-\-skip\-slave\-start\fR.
.IP "\fB\-\-skip_flush_tables\fR" 4
.IX Item "--skip_flush_tables"
-Don't issue a \fI\s-1FLUSH\s0 \s-1TABLES\s0 \s-1WITH\s0 \s-1READ\s0 \s-1LOCK\s0\fR command before creating
+Don't issue a \fI\s-1FLUSH TABLES WITH READ LOCK\s0\fR command before creating
the snapshot. Only use this option when backing up InnoDB tables (as
they don't support this function anyway and will require recovery in
any case). This option skips the (probably time consuming) flushing
@@ -363,7 +374,7 @@
.IP "\fB\-\-extra_flush_tables\fR" 4
.IX Item "--extra_flush_tables"
If your database performs a lot of writes, it may help to perform an
-extra initial \fI\s-1FLUSH\s0 \s-1TABLES\s0\fR so that the \fIlvcreate\fR can finish within
+extra initial \fI\s-1FLUSH TABLES\s0\fR so that the \fIlvcreate\fR can finish within
the interactivity timeout during the read-locked flush.
.IP "\fB\-\-pidfile=string\fR" 4
.IX Item "--pidfile=string"
@@ -760,6 +771,39 @@
The text to be used in the \fISubject:\fR header for email
reports (requires the \fImail_report\fR option to be set).
The default value is \*(L"mylvmbackup report for localhost\*(R".
+.IP "\fB\-\-snmp_report_on=string\fR" 4
+.IX Item "--snmp_report_on=string"
+Enable sending \s-1SNMP\s0 traps to specified \s-1SNMP\s0 target hosts.
+.Sp
+This option requires an installed \fINet::SNMP\fR Perl module.
+.Sp
+You should also review and adjust the \fIsnmp_base_oid\fR,
+\&\fIsnmp_targets\fR, \fIsnmp_community\fR \fIsnmp_port\fR configuration
+options to match you requirements.
+.Sp
+Supported values are \fInever\fR, this disables sending \s-1SNMP\s0
+traps completely. A value of \fIalways\fR sends an \s-1SNMP\s0 trap for
+each invocation of \fImylvmbackup\fR, \fIerrors\fR only sends an \s-1SNMP\s0
+trap in case of an error condition.
+.Sp
+The default value is \fInever\fR.
+.IP "\fB\-\-snmp_base_oid=string\fR" 4
+.IX Item "--snmp_base_oid=string"
+The \s-1SNMP\s0 object identifier (\s-1OID\s0) in dotted notation.
+The default is \fI1.3.6.1.4.1.0.0\fR.
+.IP "\fB\-\-snmp_targets=string\fR" 4
+.IX Item "--snmp_targets=string"
+A comma-separated list of host names or \s-1IP\s0 addresses to send
+\&\s-1SNMP\s0 traps to.
+The default is \fIlocalhost\fR.
+.IP "\fB\-\-snmp_community=string\fR" 4
+.IX Item "--snmp_community=string"
+The \s-1SNMP\s0 community name.
+The default is \fIpublic\fR.
+.IP "\fB\-\-snmp_port=number\fR" 4
+.IX Item "--snmp_port=number"
+The \s-1TCP\s0 port on the target host to send \s-1SNMP\s0 traps to.
+The default is \fI162\fR.
.IP "\fB\-\-configfile=string\fR" 4
.IX Item "--configfile=string"
Specify an alternative configuration file.
@@ -790,7 +834,7 @@
functionality. It also requires a functional local sendmail (or alternative)
facility.
.PP
-It also requires several other external programs: \s-1GNU\s0 \fItar\fR and \fIgzip\fR to back
+It also requires several other external programs: \s-1GNU \s0\fItar\fR and \fIgzip\fR to back
up the data, \s-1LVM\s0 utilities (\fIlvcreate\fR, \fIlvremove\fR and \fIlvs\fR) to create and
remove the \s-1LVM\s0 snapshot, and the system utilities \fImount\fR and \fIumount\fR.
Please note that \fImylvmbackup\fR requires Linux \s-1LVM\s0 Version 2 or higher. It does not
@@ -804,14 +848,14 @@
.SH "AUTHOR"
.IX Header "AUTHOR"
This program was initially written by Aleksey \*(L"Walrus\*(R" Kishkin from
-MySQL \s-1AB\s0, with suggestions from Peter Zaitsev and Lenz Grimmer.
+MySQL \s-1AB,\s0 with suggestions from Peter Zaitsev and Lenz Grimmer.
.PP
It is currently maintained by Lenz Grimmer
.SH "RESOURCES"
.IX Header "RESOURCES"
Main web site: http://www.lenzg.net/mylvmbackup
.PP
-Mailing list: https://launchpad.net/~mylvmbackup\-discuss https://launchpad.net/~mylvmbackup-discuss
+Mailing list: https://launchpad.net/~mylvmbackup\-discuss
.PP
Source code, bug tracker: https://launchpad.net/mylvmbackup
.SH "CREDITS"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mylvmbackup-0.15/man/mylvmbackup.pod new/mylvmbackup-0.16/man/mylvmbackup.pod
--- old/mylvmbackup-0.15/man/mylvmbackup.pod 2014-02-16 02:40:08.000000000 +0100
+++ new/mylvmbackup-0.16/man/mylvmbackup.pod 2014-11-21 09:48:39.000000000 +0100
@@ -50,8 +50,10 @@
I<mylvmbackup> also provides several methods for logging and reporting the
progress and success of a backup run. The log messages can either be printed
-to the console (STDOUT) or logged via I<syslog>. Additionally, a report can be
-sent to you via email.
+to the console (STDOUT) or logged via I<syslog>.
+
+Additionally, a report can be sent to you via email, and you can receive
+notifications about failures or successes via SNMP.
=head1 GENERAL HINTS
@@ -712,6 +714,44 @@
reports (requires the I option to be set).
The default value is "mylvmbackup report for localhost".
+=item B<--snmp_report_on=string>
+
+Enable sending SNMP traps to specified SNMP target hosts.
+
+This option requires an installed INet::SNMP Perl module.
+
+You should also review and adjust the I,
+I, I I configuration
+options to match you requirements.
+
+Supported values are I<never>, this disables sending SNMP
+traps completely. A value of I<always> sends an SNMP trap for
+each invocation of I<mylvmbackup>, I<errors> only sends an SNMP
+trap in case of an error condition.
+
+The default value is I<never>.
+
+=item B<--snmp_base_oid=string>
+
+The SNMP object identifier (OID) in dotted notation.
+The default is I<1.3.6.1.4.1.0.0>.
+
+=item B<--snmp_targets=string>
+
+A comma-separated list of host names or IP addresses to send
+SNMP traps to.
+The default is I<localhost>.
+
+=item B<--snmp_community=string>
+
+The SNMP community name.
+The default is I<public>.
+
+=item B<--snmp_port=number>
+
+The TCP port on the target host to send SNMP traps to.
+The default is I<162>.
+
=item B<--configfile=string>
Specify an alternative configuration file.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mylvmbackup-0.15/mylvmbackup new/mylvmbackup-0.16/mylvmbackup
--- old/mylvmbackup-0.15/mylvmbackup 2014-02-22 22:09:48.000000000 +0100
+++ new/mylvmbackup-0.16/mylvmbackup 2014-11-21 09:55:10.000000000 +0100
@@ -21,9 +21,9 @@
use Date::Format;
use DBD::mysql;
use DBI;
+use File::Basename;
use File::Copy;
use File::Copy::Recursive qw/ rcopy /;
-use File::Basename;
use File::Path;
use File::Temp qw/ mkstemps mktemp /;
use Getopt::Long;
@@ -34,8 +34,8 @@
use strict;
# Version is set from the Makefile
-my $version='0.15';
-my $build_date='2014-02-22';
+my $version='0.16';
+my $build_date='2014-11-21';
# syslog-related options
my $syslog_ident = 'mylvmbackup';
@@ -103,6 +103,11 @@
my $mail_from;
my $mail_to;
my $mail_subject;
+my $snmp_report_on;
+my $snmp_base_oid;
+my $snmp_targets;
+my $snmp_community;
+my $snmp_port;
my $use_thin_snapshots;
my $zbackup;
my $zbackuparg;
@@ -142,6 +147,11 @@
die ("You need to have MIME::Lite installed when enabling the mail report feature!\n") if $@;
}
+if ($snmp_report_on ne "never") {
+ eval 'use Net::SNMP qw(:ALL);';
+ die ("You need to have Net::SNMP installed when enabling the SNMP report feature!\n") if $@;
+}
+
if (lvm_version() =~ /^1/)
{
log_msg("Linux LVM Version 2 or higher is required to run mylvmbackup.", LOG_ERR);
@@ -433,11 +443,14 @@
$mail_from = $cfg->val ('reporting', 'mail_from', $mail_from);
$mail_to = $cfg->val ('reporting', 'mail_to', $mail_to);
$mail_subject = $cfg->val ('reporting', 'mail_subject', $mail_subject);
+ $snmp_report_on = $cfg->val ('reporting', 'snmp_report_on', $snmp_report_on);
+ $snmp_base_oid = $cfg->val ('reporting', 'snmp_base_oid', $snmp_base_oid);
+ $snmp_targets = $cfg->val ('reporting', 'snmp_targets', $snmp_targets);
+ $snmp_community = $cfg->val ('reporting', 'snmp_community', $snmp_community);
+ $snmp_port = $cfg->val ('reporting', 'snmp_port', $snmp_port);
$zbackup= $cfg->val ('zbackup', 'zbackup', $zbackup);
$zbackuparg= $cfg->val ('zbackup', 'zbackuparg', $zbackuparg);
-
-
}
# Please keep all 3 functions in the same order: load_config, load_args, load_defaults
@@ -520,6 +533,11 @@
"mail_from=s" => \$mail_from,
"mail_to=s" => \$mail_to,
"mail_subject=s" => \$mail_subject,
+ "snmp_report_on" => \&snmp_report_on,
+ "snmp_base_oid=s" => \&snmp_base_oid,
+ "snmp_targets=s" => \&snmp_targets,
+ "snmp_community=s" => \&snmp_community,
+ "snmp_port=i" => \&snmp_port,
) or help();
die help() unless $action eq "backup" or $action eq "purge";
@@ -595,15 +613,21 @@
$syslog_socktype = 'native';
$syslog_facility = '';
$syslog_remotehost = '';
+
+# reporting
$mail_report_on = 'never';
$mail_from = 'root@localhost';
$mail_to = 'root@localhost';
$mail_subject = 'mylvmbackup report for localhost';
+ $snmp_report_on = 'never';
+ $snmp_base_oid = '1.1.1.1.1.1.1.1';
+ $snmp_targets = '127.0.0.1';
+ $snmp_community = 'public';
+ $snmp_port = '162';
# zbackup
$zbackup='zbackup';
$zbackuparg='--non-encrypted';
-
}
sub flush_tables
@@ -971,6 +995,9 @@
}
sub help {
+# No need to send an email when printing the help output (BUG#1351000)
+$mail_report_on = 'never';
+$snmp_report_on = 'never';
print <session(
+ -hostname => $target,
+ -community => $snmp_community,
+ -port => $snmp_port,
+ -version => 'snmpv2c'
+ );
+
+ if (!defined($session)) {
+ printf("ERROR: %s.\n", $error);
+ exit 1;
+ }
+
+ # TIMETICKS: 0x43
+ # OBJECT_IDENTIFIER: 0x06
+ # OCTET_STRING: 0x04
+
+ my $result = $session->snmpv2_trap(
+ -varbindlist => [ '1.3.6.1.2.1.1.3.0', 0x43, 600, '1.3.6.1.6.3.1.1.4.1.0', 0x06, "$snmp_base_oid.$level", "$snmp_base_oid.$level", 0x04, $message ]);
+
+ if (!defined($result)) {
+ log_msg ("SNMP error while sending the trap $message to $target: $session->error()", LOG_ERR);
+ }
+ else {
+ log_msg ("Trap $message successfully sent to $target", LOG_INFO);
+ }
+
+ $session->close();
+ }
+}
+
END {
if ($mail_report_on eq "always" ||
($mail_report_on eq "errors" && $errorstate == 1))
@@ -1184,6 +1248,20 @@
$message->send;
}
+
+ if ($snmp_report_on eq "always" || $snmp_report_on eq "errors")
+ {
+ if ($errorstate == 1)
+ {
+ snmp_update("mylvmbackup critical, see log", 2);
+ } else {
+ if ($snmp_report_on eq "always")
+ {
+ snmp_update("mylvmbackup ok", 0);
+ }
+ }
+ }
+
exit 1 if ($errorstate == 1);
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mylvmbackup-0.15/mylvmbackup.conf new/mylvmbackup-0.16/mylvmbackup.conf
--- old/mylvmbackup-0.15/mylvmbackup.conf 2014-02-16 02:59:48.000000000 +0100
+++ new/mylvmbackup-0.16/mylvmbackup.conf 2014-11-21 09:48:39.000000000 +0100
@@ -124,7 +124,14 @@
# Mail reporting options
#
[reporting]
+# mail_report_on: always, never, errors
mail_report_on=never
mail_from=root@localhost
mail_to=root@localhost
mail_subject=mylvmbackup report for localhost
+# snmp_report_on: always, never, errors
+snmp_report_on=never
+snmp_base_oid=1.3.6.1.4.1.0.0
+snmp_targets=localhost
+snmp_community=public
+snmp_port=162
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mylvmbackup-0.15/mylvmbackup.pl.in new/mylvmbackup-0.16/mylvmbackup.pl.in
--- old/mylvmbackup-0.15/mylvmbackup.pl.in 2014-02-22 22:09:46.000000000 +0100
+++ new/mylvmbackup-0.16/mylvmbackup.pl.in 2014-11-21 09:48:39.000000000 +0100
@@ -21,9 +21,9 @@
use Date::Format;
use DBD::mysql;
use DBI;
+use File::Basename;
use File::Copy;
use File::Copy::Recursive qw/ rcopy /;
-use File::Basename;
use File::Path;
use File::Temp qw/ mkstemps mktemp /;
use Getopt::Long;
@@ -103,6 +103,11 @@
my $mail_from;
my $mail_to;
my $mail_subject;
+my $snmp_report_on;
+my $snmp_base_oid;
+my $snmp_targets;
+my $snmp_community;
+my $snmp_port;
my $use_thin_snapshots;
my $zbackup;
my $zbackuparg;
@@ -142,6 +147,11 @@
die ("You need to have MIME::Lite installed when enabling the mail report feature!\n") if $@;
}
+if ($snmp_report_on ne "never") {
+ eval 'use Net::SNMP qw(:ALL);';
+ die ("You need to have Net::SNMP installed when enabling the SNMP report feature!\n") if $@;
+}
+
if (lvm_version() =~ /^1/)
{
log_msg("Linux LVM Version 2 or higher is required to run mylvmbackup.", LOG_ERR);
@@ -433,11 +443,14 @@
$mail_from = $cfg->val ('reporting', 'mail_from', $mail_from);
$mail_to = $cfg->val ('reporting', 'mail_to', $mail_to);
$mail_subject = $cfg->val ('reporting', 'mail_subject', $mail_subject);
+ $snmp_report_on = $cfg->val ('reporting', 'snmp_report_on', $snmp_report_on);
+ $snmp_base_oid = $cfg->val ('reporting', 'snmp_base_oid', $snmp_base_oid);
+ $snmp_targets = $cfg->val ('reporting', 'snmp_targets', $snmp_targets);
+ $snmp_community = $cfg->val ('reporting', 'snmp_community', $snmp_community);
+ $snmp_port = $cfg->val ('reporting', 'snmp_port', $snmp_port);
$zbackup= $cfg->val ('zbackup', 'zbackup', $zbackup);
$zbackuparg= $cfg->val ('zbackup', 'zbackuparg', $zbackuparg);
-
-
}
# Please keep all 3 functions in the same order: load_config, load_args, load_defaults
@@ -520,6 +533,11 @@
"mail_from=s" => \$mail_from,
"mail_to=s" => \$mail_to,
"mail_subject=s" => \$mail_subject,
+ "snmp_report_on" => \&snmp_report_on,
+ "snmp_base_oid=s" => \&snmp_base_oid,
+ "snmp_targets=s" => \&snmp_targets,
+ "snmp_community=s" => \&snmp_community,
+ "snmp_port=i" => \&snmp_port,
) or help();
die help() unless $action eq "backup" or $action eq "purge";
@@ -595,15 +613,21 @@
$syslog_socktype = 'native';
$syslog_facility = '';
$syslog_remotehost = '';
+
+# reporting
$mail_report_on = 'never';
$mail_from = 'root@localhost';
$mail_to = 'root@localhost';
$mail_subject = 'mylvmbackup report for localhost';
+ $snmp_report_on = 'never';
+ $snmp_base_oid = '1.1.1.1.1.1.1.1';
+ $snmp_targets = '127.0.0.1';
+ $snmp_community = 'public';
+ $snmp_port = '162';
# zbackup
$zbackup='zbackup';
$zbackuparg='--non-encrypted';
-
}
sub flush_tables
@@ -971,6 +995,9 @@
}
sub help {
+# No need to send an email when printing the help output (BUG#1351000)
+$mail_report_on = 'never';
+$snmp_report_on = 'never';
print <session(
+ -hostname => $target,
+ -community => $snmp_community,
+ -port => $snmp_port,
+ -version => 'snmpv2c'
+ );
+
+ if (!defined($session)) {
+ printf("ERROR: %s.\n", $error);
+ exit 1;
+ }
+
+ # TIMETICKS: 0x43
+ # OBJECT_IDENTIFIER: 0x06
+ # OCTET_STRING: 0x04
+
+ my $result = $session->snmpv2_trap(
+ -varbindlist => [ '1.3.6.1.2.1.1.3.0', 0x43, 600, '1.3.6.1.6.3.1.1.4.1.0', 0x06, "$snmp_base_oid.$level", "$snmp_base_oid.$level", 0x04, $message ]);
+
+ if (!defined($result)) {
+ log_msg ("SNMP error while sending the trap $message to $target: $session->error()", LOG_ERR);
+ }
+ else {
+ log_msg ("Trap $message successfully sent to $target", LOG_INFO);
+ }
+
+ $session->close();
+ }
+}
+
END {
if ($mail_report_on eq "always" ||
($mail_report_on eq "errors" && $errorstate == 1))
@@ -1184,6 +1248,20 @@
$message->send;
}
+
+ if ($snmp_report_on eq "always" || $snmp_report_on eq "errors")
+ {
+ if ($errorstate == 1)
+ {
+ snmp_update("mylvmbackup critical, see log", 2);
+ } else {
+ if ($snmp_report_on eq "always")
+ {
+ snmp_update("mylvmbackup ok", 0);
+ }
+ }
+ }
+
exit 1 if ($errorstate == 1);
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/mylvmbackup-0.15/mylvmbackup.spec new/mylvmbackup-0.16/mylvmbackup.spec
--- old/mylvmbackup-0.15/mylvmbackup.spec 2014-02-16 03:01:54.000000000 +0100
+++ new/mylvmbackup-0.16/mylvmbackup.spec 2014-11-21 09:55:10.000000000 +0100
@@ -1,5 +1,5 @@
#
-# spec file for package mylvmbackup (Version 0.15)
+# spec file for package mylvmbackup (Version 0.16)
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
@@ -17,7 +17,7 @@
Name: mylvmbackup
Summary: Utility for creating MySQL backups via LVM snapshots
-Version: 0.15
+Version: 0.16
Release: 0
License: GPL
Group: Productivity/Archiving/Backup
--
To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org
For additional commands, e-mail: opensuse-commit+help@opensuse.org