File: automount

package info (click to toggle)
logwatch 5.2.2-5
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,112 kB
  • ctags: 42
  • sloc: perl: 9,032; sh: 65; makefile: 54
file content (100 lines) | stat: -rwxr-xr-x 3,490 bytes parent folder | download
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
#!/usr/bin/perl -w
##########################################################################
# $Id: automount,v 1.7 2003/12/15 18:09:23 kirk Exp $
##########################################################################

########################################################
# This was written and is maintained by:
#    Gerald Teschl <gerald@esi.ac.at>
#
# Please send all comments, suggestions, bug reports,
#    etc, to kirk@kaybee.org.
########################################################

$Detail = $ENV{'LOGWATCH_DETAIL_LEVEL'} || 0;
$MountAttempts = 0;

while (defined($ThisLine = <STDIN>)) {
   if ( ($ThisLine =~ /^using kernel protocol version .*$/) or
         ($ThisLine =~ /^expired .*$/) or
         ($ThisLine =~ /^>> mount: .*$/) ) {
      # don't care about these
   }
   elsif ( ($ThisMount) = ($ThisLine =~ /^attempting to mount entry (.*)$/) ) {
      # store Mount
      $Mount= $ThisMount;
      $MountAttempts++;
   }
   elsif ($ThisLine =~ /^mount\(nfs\): nfs: mount failure .*:.* on .*$/) {
      $Failed{$Mount}{'nfsm'}++;
   }
   elsif ($ThisLine =~ /^mount\(nfs\): entry .* lookup failure$/) {
      $Failed{$Mount}{'nfsl'}++;
   }
   elsif ( $ThisLine =~ /^mount\(generic\): failed to mount .* on .*$/) {
      $Failed{$Mount}{'mnt'}++;
   }
   elsif ( ($ThisMount) = ( $ThisLine =~ /^(.*): mount failed!$/) ) {
      $FailedStartup{$ThisMount}++;
   }
   elsif ( $ThisLine =~ /^lookup\(file\): lookup for .* failed$/) {
      $Failed{$Mount}{'file'}++;
   }
   elsif ( ($ThisMount) = ($ThisLine =~ /^starting automounter version .* path = (.*), maptype = .*, mapname = .*$/) ) {
      $StartStop{$ThisMount}{'start'}++;
      $StartStop{$ThisMount}{'stop'}+=0;
   }
   elsif ( ($ThisMount) = ($ThisLine =~ /^shutting down, path = (.*)$/) ) {
      $StartStop{$ThisMount}{'stop'}++;
   }
   else {
      # Report any unmatched entries...
      chomp($ThisLine);
      $OtherList{$ThisLine}++;
   }
}

if (keys %FailedStartup) {
   print "\nFailed Startups:\n";
   foreach $ThisOne (keys %FailedStartup) {
      print "   $ThisOne       " . $FailedStartup{$ThisOne} . " Time(s)\n";
   }
}

if (keys %Failed) {
   print "\nFailed mounts:\n";
   foreach $ThisOne (keys %Failed) {
      print "   $ThisOne       ";
      if ($Failed{$ThisOne}{'nfsm'}) {
         print "NFS Mount Failure $Failed{$ThisOne}{'nfsm'} Time(s)"; }
      if ($Failed{$ThisOne}{'nfsl'}) {
         print "NFS Lookup Failure $Failed{$ThisOne}{'nfsl'} Time(s)"; }
      if ($Failed{$ThisOne}{'mnt'}) {
         print "Mount Failure $Failed{$ThisOne}{'mnt'} Time(s)"; }
      if ($Failed{$ThisOne}{'file'}) {
         print "File Lookup Failure $Failed{$ThisOne}{'file'} Time(s)"; }
      print "\n";
   }
}

if ( ($Detail >= 10) and (keys %StartStop) ) {
   print "\nStatistics:\n";
   print "   Total number of mount attempts: $MountAttempts\n";
   foreach $ThisOne (keys %StartStop) {
      $StartStop{$ThisOne}{'start'} = 0 unless defined $StartStop{$ThisOne}{'start'};
      $StartStop{$ThisOne}{'stop'} = 0 unless defined $StartStop{$ThisOne}{'stop'};
      print "   $ThisOne: Started $StartStop{$ThisOne}{'start'} and stopped $StartStop{$ThisOne}{'stop'} Time(s)\n";
   }
}

if (keys %OtherList) {
   print "\n**Unmatched Entries**\n";
   foreach $ThisOne (keys %OtherList) {
      print "$ThisOne: $OtherList{$ThisOne} Time(s)\n";
   }
}                                                                                       
    
exit(0);

# vi: shiftwidth=3 tabstop=3 et