Re: smard filter improvement
Roman Kononov <[email protected]>
| Newsgroups | gmane.comp.log.logwatch.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi, Please ignore the previous post. Here is a better one. If smartd is configured to log raw attribute values, logwatch should report the raw values instead of normalized ones. See "Why is my disk temperature s reported by smartd as 150 Celsius?": http://smartmontools.sourceforge.net/faq.html This patch changes logwatch so that: - raw values are reported when they are present; - temperatures are sorted numerically, not alphabetically; - the detail level uses the standard thresholds (0, 5 and 10); - indentation is fixed; Roman Kononov _______________________________________________ Logwatch-Devel mailing list [email protected] http://www2.list.logwatch.org:81/mailman/listinfo/logwatch-devel
smartd.patch
(text/x-patch, 3 KB)
Index: scripts/services/smartd
===================================================================
RCS file: /var/cvs/logwatch/scripts/services/smartd,v
retrieving revision 1.25
diff -r1.25 smartd
1c1
<
---
> #!/usr/bin/perl
125,129c125,127
< } elsif ( my ($Device,$AttribType,$Code,$Name,undef,undef,undef,$RawVal) = ($ThisLine =~ /^Device: ([^,]+), SMART ([A-Za-z]+) Attribute: ([0-9]+) (Temperature_Celsius) changed from ([0-9]+) (\[Raw [0-9]+\]) to ([0-9]+) \[Raw ([0-9]+)\]/)) {
< push @{$TempChanges{$Device}}, $RawVal;
< # smartd reports temperature changes this way only for SCSI disks
< } elsif ( my ($Device,$AttribType,$Code,$Name,undef,undef,$NewVal) = ($ThisLine =~ /^Device: ([^,]+), SMART ([A-Za-z]+) Attribute: ([0-9]+) ([A-Za-z_]+) changed from ([0-9]+) (\[Raw [0-9]+\] )?to ([0-9]+)/)) {
< push (@{$ParamChanges{$Device}{"$AttribType: $Name ($Code)"}}, $NewVal);
---
> } elsif ( my ($Device,$AttribType,$Code,$Name,undef,$NewVal,undef,$NewRawVal) = ($ThisLine =~ /^Device: ([^,]+), SMART (\w+) Attribute: (\d+) (\w+) changed from \d+( \[Raw \d+\])? to (\d+)( \[Raw (\d+)\])?/)) {
> my $arr=($Name eq "Temperature_Celsius") ? \@{$TempChanges{$Device}} : \@{$ParamChanges{$Device}{"$AttribType: $Name ($Code)"}};
> push @{$arr}, defined($NewRawVal) ? $NewRawVal : $NewVal;
202,203c200,201
< print "Temperature Changes\n==================\n";
< my (@min,@max);
---
> print "Temperature Changes\n==================\n";
> my (@min,@max);
205,224c203,222
< if($Detail < 10) {
< my @sorttemp = sort @{$TempChanges{$Device}};
< push @min, $sorttemp[0];
< push @max, $sorttemp[$#sorttemp];
< } elsif($Detail < 20) {
< my @sorttemp = sort @{$TempChanges{$Device}};
< print "$Device : $sorttemp[0] - $sorttemp[$#sorttemp]\n";
< } else {
< print "$Device : ";
< print join ", ",@{$TempChanges{$Device}};
< print "\n";
< }
< }
< if($Detail < 10) {
< my @sorttemp = sort @min;
< my $mint = $sorttemp[0];
< my @sorttemp = sort @max;
< my $maxt = $sorttemp[$#sorttemp];
< print "All devices: $mint - $maxt\n";
< }
---
> if($Detail < 5) {
> my @sorttemp = sort { $a <=> $b } @{$TempChanges{$Device}};
> push @min, $sorttemp[0];
> push @max, $sorttemp[$#sorttemp];
> } elsif($Detail < 10) {
> my @sorttemp = sort { $a <=> $b } @{$TempChanges{$Device}};
> print "$Device : $sorttemp[0] - $sorttemp[$#sorttemp]\n";
> } else {
> print "$Device : ";
> print join ", ",@{$TempChanges{$Device}};
> print "\n";
> }
> }
> if($Detail < 5) {
> my @sorttemp = sort { $a <=> $b } @min;
> my $mint = $sorttemp[0];
> my @sorttemp = sort { $a <=> $b } @max;
> my $maxt = $sorttemp[$#sorttemp];
> print "All devices: $mint - $maxt\n";
> }