File: mysql-mmm

package info (click to toggle)
logwatch 7.14-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,572 kB
  • sloc: perl: 8,290; sh: 354; makefile: 38
file content (152 lines) | stat: -rw-r--r-- 5,190 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152

########################################################
# Please file all bug reports, patches, and feature
# requests under:
#      https://sourceforge.net/p/logwatch/_list/tickets
# and copy:
#    Stefan Jakobs <logwatch at localside.net>
# Help requests and discusion can be filed under:
#      https://sourceforge.net/p/logwatch/discussion/
########################################################

###########################################################################
# This was written and is maintained by:
#    Stefan Jakobs <logwatch at localside.net>
#
# Please send all comments, suggestions, bug reports,
#    etc, to logwatch at localside.net.
###########################################################################
# Copyright (c) 2013 Stefan Jakobs
# Covered under the included MIT/X-Consortium License:
#    http://www.opensource.org/licenses/mit-license.php
# All modifications and contributions by other persons to
# this script are assumed to have been donated to the
# Logwatch project and thus assume the above copyright
# and licensing terms.  If you want to make contributions
# under your own copyright or a different license this
# must be explicitly stated in the contribution and the
# Logwatch project reserves the right to not accept such
# contributions.  If you have made significant
# contributions to this script and want to claim
# copyright please contact logwatch-devel@lists.sourceforge.net.
###########################################################################

use strict;

my $Detail      = $ENV{'LOGWATCH_DETAIL_LEVEL'} || 0;
my $Version     = 0.1;

# initialize logwatch variables
my $ThisLine    = "";
my %OtherList   = ();

# initialize variables which save the stats
my (%fatal, %info, %warn);
my (%mon_fatal, %mon_error);

### Parse the lines ###

while (defined($ThisLine = <STDIN>)) {
   chomp($ThisLine);
   $ThisLine =~ s/^\d{4}\/\d\d\/\d\d \d\d:\d\d:\d\d *//;
   if ( ($ThisLine =~ /^INFO We have some new roles added or old rules deleted!$/) or
        ($ThisLine =~ /^INFO END$/)
   ) {
      # ignore

   } elsif ($ThisLine =~ /^FATAL State of host '(\S+)' changed from (\S+) to (\S+)(?: .* for (?:only )?(\d+) seconds)?/) {
     my $sec = "";
     if ( $4 > 0 ) {
        $sec = "(for $4 s)";
     }
     $mon_fatal{"State change"}{"$1: $2 -> $3 $sec"}++;
   } elsif ($ThisLine =~ /^FATAL Agent on host '(\S+)' (.*)/) {
     $mon_fatal{"Agent on host"}{"$1: $2"}++;
   } elsif ($ThisLine =~ /^FATAL Can't reach agent on host '(\S+)'/) {
     $mon_fatal{"Agent on host"}{"$1: can't be reached"}++;
   } elsif ($ThisLine =~ /^FATAL (Couldn't open status file) '([^']+)'/) {
     $mon_fatal{"$1"}{"$2"}++;
   } elsif ($ThisLine =~ /^FATAL ([^\:]+)(?:: ERROR: (.*))?/) {
     $fatal{"$1"}{"$2"}++;
   } elsif ( (my ($srv, $host, $err, $msg) ) =
        ($ThisLine =~ /^ERROR Check '(\S+)' on '(\S+)' has (.*) Message: ERROR: ([^(]*)/) ) {
     $mon_error{"$host: $srv: $err $msg"}++;
   } elsif ($ThisLine =~ /^ERROR The (status of the (?:system|agent on host) '\S+' could not be determined)/) {
     $mon_error{"$1"}++;
   } elsif ($ThisLine =~ /^ERROR (Can't (?:reach agent on host|send offline status notification to)) '(\S+)'/) {
     $mon_error{"$2: $1"}++;
   } elsif ( $ThisLine =~ /^WARN (.*) Message: (UNKNOWN:) ([^(]*)/) {
     $warn{"$2: $1 $3"}++;
   } elsif ( $ThisLine =~ /^WARN (.*)/ ) {
     $warn{"$1"}++;
   } elsif ( $ThisLine =~ /^INFO (.*)/) {
     $info{"$1"}++;
   } else {
     # Report any unmatched entries...
     $OtherList{$ThisLine}++;
   }
}

### generate output ###

if (keys %mon_fatal) {
   print "\n  Monitoring FATAL:\n";
   foreach my $msg (keys %mon_fatal) {
      printf "    %-52s", $msg;
      foreach my $err (sort {$a cmp $b} keys %{$mon_fatal{$msg}}) {
         if ($err) {
            printf "\n\t%-48s: %4i time(s)", $err, $mon_fatal{$msg}{$err};
         } else {
            printf ": %4i time(s)\n", $mon_fatal{$msg}{$err};
         }
      }
      print "\n";
   }
}

if (keys %mon_error) {
   print "\n  Monitoring ERROR:\n";
   foreach my $msg (sort {$a cmp $b} keys %mon_error) {
      printf "    %-52s: %4i time(s)\n", $msg, $mon_error{$msg};
   }
}

if (keys %fatal) {
   print "\n  Agent FATAL:\n";
   foreach my $msg (sort {$a cmp $b} keys %fatal) {
      printf "    %-52s", $msg;
      foreach my $err (sort {$a cmp $b} keys %{$fatal{$msg}}) {
         if ($err) {
            printf "\n\t%-48s: %4i time(s)\n", $err, $fatal{$msg}{$err};
         } else {
            printf ": %4i time(s)\n", $fatal{$msg}{$err};
         }
      }
   }
}

if (keys %warn and $Detail > 1) {
   print "\n  Agent WARN:\n";
   foreach my $msg (sort {$a cmp $b} keys %warn) {
      printf "    %-52s: %4i time(s)\n", $msg, $warn{$msg};
   }
}

if (keys %info and $Detail > 5) {
   print "\n  INFO:\n";
   foreach my $msg (sort {$a cmp $b} keys %info) {
      printf "    %-52s: %5i time(s)\n", $msg, $info{$msg};
   }
}

if (keys %OtherList) {
   print "\n**** Unmatched entries ****\n";
   foreach my $Error (keys %OtherList) {
      print "    $Error : $OtherList{$Error} Time(s)\n";
   }
}

### return without a failure ###
exit(0);

# vi: shiftwidth=3 tabstop=3 syntax=perl et