This file is indexed.

/usr/share/doc/mgetty/contrib/watchit.pl is in mgetty-docs 1.1.36-2ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
#!/usr/bin/perl
#
# watchit.pl
#
# watch mgetty log file (the "auth.log" syslog file) for repeated failure
# messages, alarming system administrator after repeated failures
#
# RCS: $Id: watchit.pl,v 1.2 1998/10/07 13:54:06 gert Exp $
#
# $Log: watchit.pl,v $
# Revision 1.2  1998/10/07 13:54:06  gert
# add RCS keywords
#
#
require 'getopts.pl';

# configuration section
#
# which file to monitor
$logfile="/var/log/auth.log";

# send mail after <n> "failed" mgetty startups
$max_fail=3;

# who you gonna call? This user gets the mail
$faxadmin="knarf";

# mail program
$mailprg="/usr/sbin/sendmail";


# options
#
# -d: debug = show what's going on (silent operation otherwise)

$opt_d = 0;
&Getopts('d') || do { print STDERR "$0: usage: watchit [-d]\n"; die; };


$cmd="tail -f $logfile |";
$skipped=0;

open( TAILF, $cmd ) ||
	die "Can't fork command '$cmd': $!\n";

while( <TAILF> )
{
# skip "old junk"
    $skipped++;
    next if ( $skipped<10 );

    chomp;

# skip non-mgetty messages
    next unless /mgetty/;

    print "DBUG: $_\n" if $opt_d;

# skip lines with no device name given
    next unless / dev=([^\s,]+)[, ]/;

    $dev=$1;

# set up status
    if ( /failed/ )
    {
	if ( $status{$dev} ne "FAIL" )
	    { $status{$dev}="FAIL"; $failures{$dev}=1; $failmsg{$dev}=$_; }
	else
	    { $failures{$dev}++;
	      $failmsg{$dev} .= "\n" . $_;
	      if ( $failures{$dev} >= $max_fail ) { &make_noise; };
	    }
    }
    else
    { $status{$dev}="GOOD" };

    print "DBUG: status\{$dev\} now ". $status{$dev}. 
			"(" . $failures{$dev} . ")\n" if $opt_d;
}

close TAILF;

sub make_noise
{
    open( PIPE, "|$mailprg $faxadmin" ) ||
		    die "can't open pipe to mail program: $!\n";

    print PIPE <<PEOF;
To: $faxadmin
From: root (Modem Watching Servant)
Subject: sick modem on $dev
Priority: urgent

Hello $faxadmin,

one of your modems ($dev) created $max_fail failure messages
in the logfile '$logfile'. You might want to investigate!!!

The offending lines in the log file are:

----------------- snip - snap - ouch --------------------------
PEOF
    print PIPE $failmsg{$dev};

    print PIPE <<PEOF2;

----------------- snip - snap - ouch --------------------------

Kind regards,

your ever happily watching modem servant.

PEOF2

    close PIPE;

    print "sent mail to $faxadmin\n" if $opt_d;

    $failures{$dev}=-57;	# complain again in 60 mgetty cycles
}