#!/usr/bin/perl -w

# Place this puppy in your /var/spool/cron/crontab/root
# cron file.  Use something like -
# 59 23 * * * /util/msg_log.perl > /dev/null 2>&1

# Copyright 1999 -Sneex- All Rights Reserved...

use strict;
use diagnostics;

my $SENDMAIL = '/usr/lib/sendmail';

# Example of DATE: Tue Feb  2 19:34:24 EST 1999
my $today = substr( `/usr/bin/date`, 4, 6); # Get just today...

# Find out if there are any errors of type ... grep -i ???? ...
my $cmd0  = "cat /var/adm/messages |grep -w \'$today\'";
my $cmd1  = "cat /var/adm/messages |grep -w \'$today\' | grep -i fail";
my $cmd2  = "cat /var/adm/messages |grep -w \'$today\' | grep -i snif";
my $cmd3  = "cat /var/adm/messages |grep -w \'$today\' | grep -i unkn";
# But do it only for log entries for $today...

open (MAIL, "| $SENDMAIL you") || die ("$0: Can't open $SENDMAIL: $!\n");
print MAIL "Reply-to: you\@your.addr.com\n";
print MAIL "From: \"x.Message.Log\" \<root\@your.addr.com\>\n";
print MAIL "To: you\n";
print MAIL "Subject: MsgLog Report at ", scalar localtime, "\n";
print MAIL "\n";

print MAIL "=================================================================\n";
print MAIL "NOTE:  This message was sent through the Msg.Monitor Perl System,\n";
print MAIL "       Msg Monitor v0.01 (Alpha) by W.C. Jones, FCCJ Webmaster...\n";
print MAIL "              Copyright 1998 -Sneex- All rights reserved...\n";
print MAIL "=================================================================\n";
print MAIL "\n";

print MAIL "\nSummary:\n--------\n\n";

print MAIL `$cmd0`;
print MAIL "\n....................\n";
print MAIL `$cmd1`;
print MAIL "\n....................\n";
print MAIL `$cmd2`;
print MAIL "\n....................\n";
print MAIL `$cmd3`;

print MAIL "\n\nEnd of Report...\n";

close (MAIL);

__END__
