SF.net SVN: logwatch:[273] trunk/scripts/services/mysql
[email protected] Wed, 24 Dec 2014 13:21:28 +0000
| Newsgroups | gmane.comp.log.logwatch.devel |
|---|---|
| Message-ID | <[email protected]> |
Revision: 273
http://sourceforge.net/p/logwatch/code/273
Author: stefjakobs
Date: 2014-12-24 13:21:27 +0000 (Wed, 24 Dec 2014)
Log Message:
-----------
include patch#37: report mysql warnings as warnings (Thanks: Chris)
Modified Paths:
--------------
trunk/scripts/services/mysql
Modified: trunk/scripts/services/mysql
===================================================================
--- trunk/scripts/services/mysql 2014-12-24 11:31:59 UTC (rev 272)
+++ trunk/scripts/services/mysql 2014-12-24 13:21:27 UTC (rev 273)
@@ -1,16 +1,9 @@
-#!/usr/bin/perl -w
#
-# $Id$
-#
-# 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
@@ -24,7 +17,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';
@@ -41,11 +34,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
@@ -71,12 +65,12 @@
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;
@@ -99,7 +93,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;
@@ -109,16 +103,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)';
@@ -133,11 +127,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:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net