File: onlyservice

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 (36 lines) | stat: -rwxr-xr-x 1,257 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
#!/usr/bin/perl -w
##########################################################################
# $Id: onlyservice,v 1.5 2003/12/15 22:15:49 kirk Exp $
##########################################################################

########################################################
# This was written and is maintained by:
#    Kirk Bauer <kirk@kaybee.org>
#
# Please send all comments, suggestions, bug reports,
#    etc, to kirk@kaybee.org.
########################################################

# This will pick out only the wanted service from a logfile
# in the standard /var/log/messages format.  Case insensitive.

$ServiceName = $ARGV[0];
if ( $ENV{'LOGWATCH_DEBUG'} > 5 ) {
   print STDERR "DEBUG: Inside OnlyService for $ServiceName\n";
}

while (defined($ThisLine = <STDIN>)) {
    if ($ThisLine =~ m/^... .. ..:..:.. [^ ]* $ServiceName\[[0123456789]*\]: /io) {
      print $ThisLine;
    }
    elsif ($ThisLine =~ m/^... .. ..:..:.. [^ ]* [^ ]*\[[0123456789]*\]: \[ID [0-9]+ $ServiceName/io) {
      print $ThisLine;
    }
    elsif ($ThisLine =~ m/^... .. ..:..:.. [^ ]* [^ ]*: \[ID [0-9]+ $ServiceName/io) {
      print $ThisLine;
    }
    elsif ($ThisLine =~ m/^... .. ..:..:.. [^ ]* $ServiceName: /io) {
      print $ThisLine;
    }
}