|
Packit Bot |
ea69bd |
########################################################
|
|
Packit Bot |
ea69bd |
## Copyright (c) 2014 Orion Poplawski
|
|
Packit Bot |
ea69bd |
## Covered under the included MIT/X-Consortium License:
|
|
Packit Bot |
ea69bd |
## http://www.opensource.org/licenses/mit-license.php
|
|
Packit Bot |
ea69bd |
## All modifications and contributions by other persons to
|
|
Packit Bot |
ea69bd |
## this script are assumed to have been donated to the
|
|
Packit Bot |
ea69bd |
## Logwatch project and thus assume the above copyright
|
|
Packit Bot |
ea69bd |
## and licensing terms. If you want to make contributions
|
|
Packit Bot |
ea69bd |
## under your own copyright or a different license this
|
|
Packit Bot |
ea69bd |
## must be explicitly stated in the contribution an the
|
|
Packit Bot |
ea69bd |
## Logwatch project reserves the right to not accept such
|
|
Packit Bot |
ea69bd |
## contributions. If you have made significant
|
|
Packit Bot |
ea69bd |
## contributions to this script and want to claim
|
|
Packit Bot |
ea69bd |
## copyright please contact logwatch-devel@lists.sourceforge.net.
|
|
Packit Bot |
ea69bd |
#########################################################
|
|
Packit Bot |
ea69bd |
|
|
Packit Bot |
ea69bd |
use strict;
|
|
Packit Bot |
ea69bd |
my $Detail = $ENV{'LOGWATCH_DETAIL_LEVEL'} || 0;
|
|
Packit Bot |
ea69bd |
my $PoolThreshold = $ENV{'pool_threshold'} || 0;
|
|
Packit Bot |
ea69bd |
my %PoolUsed;
|
|
Packit Bot |
ea69bd |
my $SnapshotThreshold = $ENV{'snapshot_threshold'} || 0;
|
|
Packit Bot |
ea69bd |
my %SnapshotUsed;
|
|
Packit Bot |
ea69bd |
my %MonitoringOn;
|
|
Packit Bot |
ea69bd |
my %MonitoringOff;
|
|
Packit Bot |
ea69bd |
my %OtherList;
|
|
Packit Bot |
ea69bd |
|
|
Packit Bot |
ea69bd |
while (defined(my $ThisLine = <STDIN>)) {
|
|
Packit Bot |
ea69bd |
chomp($ThisLine);
|
|
Packit Bot |
ea69bd |
if ($ThisLine =~ /^Thin (\S+) is now (\d+)% full/) {
|
|
Packit Bot |
ea69bd |
$PoolUsed{$1} = $2 if $2 >= $PoolThreshold;
|
|
Packit Bot |
ea69bd |
} elsif ($ThisLine =~ /^Monitoring thin (\S+)\./) {
|
|
Packit Bot |
ea69bd |
$MonitoringOn{$1}++;
|
|
Packit Bot |
ea69bd |
} elsif ($ThisLine =~ /^No longer monitoring thin (\S+)\./) {
|
|
Packit Bot |
ea69bd |
$MonitoringOff{$1}++;
|
|
Packit Bot |
ea69bd |
} elsif ($ThisLine =~ /^Snapshot (\S+) is now (\d+)% full/) {
|
|
Packit Bot |
ea69bd |
$SnapshotUsed{$1} = $2 if $2 >= $SnapshotThreshold;
|
|
Packit Bot |
ea69bd |
} else {
|
|
Packit Bot |
ea69bd |
$OtherList{$ThisLine}++;
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
|
|
Packit Bot |
ea69bd |
if (keys %PoolUsed) {
|
|
Packit Bot |
ea69bd |
print "Thin Pool Usage:\n";
|
|
Packit Bot |
ea69bd |
foreach my $Pool (sort {$a cmp $b} keys %PoolUsed) {
|
|
Packit Bot |
ea69bd |
print " $Pool: $PoolUsed{$Pool}% full\n";
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
print "\n";
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
|
|
Packit Bot |
ea69bd |
if (keys %SnapshotUsed) {
|
|
Packit Bot |
ea69bd |
print "Snapshot Usage:\n";
|
|
Packit Bot |
ea69bd |
foreach my $Snapshot (sort {$a cmp $b} keys %SnapshotUsed) {
|
|
Packit Bot |
ea69bd |
print " $Snapshot: $SnapshotUsed{$Snapshot}% full\n";
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
print "\n";
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
|
|
Packit Bot |
ea69bd |
if (keys %MonitoringOn and $Detail) {
|
|
Packit Bot |
ea69bd |
print "Monitoring started for:\n";
|
|
Packit Bot |
ea69bd |
foreach my $Pool (sort {$a cmp $b} keys %MonitoringOn) {
|
|
Packit Bot |
ea69bd |
print " $Pool: $MonitoringOn{$Pool} Time(s)\n";
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
print "\n";
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
|
|
Packit Bot |
ea69bd |
if (keys %MonitoringOff and $Detail) {
|
|
Packit Bot |
ea69bd |
print "Monitoring stopped for:\n";
|
|
Packit Bot |
ea69bd |
foreach my $Pool (sort {$a cmp $b} keys %MonitoringOff) {
|
|
Packit Bot |
ea69bd |
print " $Pool: $MonitoringOff{$Pool} Time(s)\n";
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
print "\n";
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
|
|
Packit Bot |
ea69bd |
if (keys %OtherList) {
|
|
Packit Bot |
ea69bd |
print "\n**Unmatched Entries**\n";
|
|
Packit Bot |
ea69bd |
foreach my $line (sort {$a cmp $b} keys %OtherList) {
|
|
Packit Bot |
ea69bd |
print " $line: $OtherList{$line} Time(s)\n";
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
}
|
|
Packit Bot |
ea69bd |
|
|
Packit Bot |
ea69bd |
exit(0);
|
|
Packit Bot |
ea69bd |
|
|
Packit Bot |
ea69bd |
# vi: shiftwidth=3 tabstop=3 syntax=perl et
|
|
Packit Bot |
ea69bd |
# Local Variables:
|
|
Packit Bot |
ea69bd |
# mode: perl
|
|
Packit Bot |
ea69bd |
# perl-indent-level: 3
|
|
Packit Bot |
ea69bd |
# indent-tabs-mode: nil
|
|
Packit Bot |
ea69bd |
# End:
|