Fix to count "Unsafe statement written to the binary log" in mysql error

Chris <[email protected]> Sat, 27 Sep 2014 23:32:49 +0200
Newsgroups gmane.comp.log.logwatch.devel
Message-ID <[email protected]>
Hi,

sorry didn't noticed the readme of logwatch which states that patches
should be sent to this mailinglist.

Please find attached a fix to count "Unsafe statement written to the
binary log" in mysql error which i have also posted here:

https://sourceforge.net/p/logwatch/patches/37/

------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk

_______________________________________________
Logwatch-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/logwatch-devel
mysql.patch (text/plain, 4.1 KB)
--- mysql.org	2014-09-13 15:34:12.555299199 +0200
+++ mysql	2014-09-13 15:47:28.004803545 +0200
@@ -1,17 +1,15 @@
 #!/usr/bin/perl
-#!/usr/bin/perl -w
-#
+###############################################################################
 # $Id: mysql 184 2014-01-26 13:46:58Z stefjakobs $
+###############################################################################
 #
 # Logwatch service for mysqld error log
-# To be placed in 
-#	/etc/logwatch/scripts/mysql
 #
 # Processes all messages and summarizes them
 # Each message is given with a timestamp and RMS
-#
-########################################################
-##(C) 2006 by Jeremias Reith <[email protected]>
+
+#######################################################
+## Copyright (C) 2006 by Jeremias Reith <[email protected]>
 ## Modified 2009 by Michael Baierl
 ## Covered under the included MIT/X-Consortium License:
 ##    http://www.opensource.org/licenses/mit-license.php
@@ -25,7 +23,7 @@
 ## contributions.  If you have made significant
 ## contributions to this script and want to claim
 ## copyright please contact [email protected].
-######################################################### 
+#########################################################
 
 use strict;
 use Logwatch ':dates';
@@ -42,11 +40,12 @@
 		  Sep => 8, Oct => 9, Nov => 10, Dec => 11 );
 
 # array of message categories (we do not use a hash to keep the order)
-# first element: catorory name 
+# first element: catorory name
 # second element: matching regexp ($1 should contain the message)
 # third element: anonymous hash ref (stores message  counts)
 my @message_categories = (['Errors', qr/\[ERROR\] (.*)$/o, {}],
 			  ['Note', qr/\[Note\] (.*)$/o, {}],
+			  ['Warnings', qr/\[Warning] (.*)$/o, {}],
 			  ['Other', qr/(.*)$/o, {}]);
 
 # counting messages
@@ -65,19 +64,19 @@
 
    # Count lines with increasing number as one:
    #  [Warning] Aborted connection 107194 to db: ...
-   $line =~ s/(Aborted connection) \d+ (to db)/$1 $2/;
+   #$line =~ s/(Aborted connection) \d+ (to db)/$1 $2/;
 
     foreach my $cur_cat (@message_categories) {
 	if($line =~ /$cur_cat->[1]/) {
 	    my $msgs = $cur_cat->[2];
 	    $msgs->{$1} = {count => '0',
 			   first_occurrence => $time,
-			   sum => 0, 
+			   sum => 0,
 			   sqrsum => 0} unless exists $msgs->{$1};
 	    $msgs->{$1}->{'count'}++;
 	    # summing up timestamps and squares of timestamps
 	    # in order to calculate the rms
-	    # using first occurrence of message as offset in calculation to 
+	    # using first occurrence of message as offset in calculation to
 	    # prevent an integer overflow
 	    $msgs->{$1}->{'sum'} += $time - $msgs->{$1}->{'first_occurrence'};
 	    $msgs->{$1}->{'sqrsum'} += ($time - $msgs->{$1}->{'first_occurrence'}) ** 2;
@@ -100,7 +99,7 @@
 
     foreach my $msg (@sorted_msgs) {
 	# grouping messages by number of occurrence
-	print "\n", $msgs->{$msg}->{'count'}, " times:\n" unless $last_count == $msgs->{$msg}->{'count'};   
+	print "\n", $msgs->{$msg}->{'count'}, " times:\n" unless $last_count == $msgs->{$msg}->{'count'};
 	my $rms = 0;
 
 
@@ -110,16 +109,16 @@
 	if($msgs->{$msg}->{'count'} > 1) {
 	    # calculating rms
 	    $rms = int(sqrt(
-			   ($msgs->{$msg}->{'count'} * 
-			    $msgs->{$msg}->{'sqrsum'} - 
-			    $msgs->{$msg}->{'sum'}) / 
-			   ($msgs->{$msg}->{'count'} * 
+			   ($msgs->{$msg}->{'count'} *
+			    $msgs->{$msg}->{'sqrsum'} -
+			    $msgs->{$msg}->{'sum'}) /
+			   ($msgs->{$msg}->{'count'} *
 			    ($msgs->{$msg}->{'count'} - 1))));
 
 	    print strftime($date_format, localtime($msgs->{$msg}->{'first_occurrence'}+int($rms/2)));
 
 	    print ' +/-';
-	    
+
 	    # printing rms
 	    if($rms > 86400) {
 		print int($rms/86400) , ' day(s)';
@@ -134,11 +133,17 @@
 	    # we have got this message a single time
 	    print strftime($date_format, localtime($msgs->{$msg}->{'first_occurrence'}));
 	}
-	   
-	print '] ', $msg, "\n";	
+
+	print '] ', $msg, "\n";
 	$last_count = $msgs->{$msg}->{'count'};
     }
 
     print "\n";
 }
 
+# vi: shiftwidth=3 tabstop=3 et
+# Local Variables:
+# mode: perl
+# perl-indent-level: 3
+# indent-tabs-mode: nil
+# End: