Hello all,
        I am working on a script to monitor the size of a particular file and the time 
stamp of the file. My objective is to alert some individuals via email when the file 
reaches a certain size and/or when the time stamp of the file does not match the 
current time. I'm stuck on how I can test for the time stamp. I have been looking at 
the file test operators, specifically, the -M. Some suggestions would be helpful.

#!/opt/bin/perl -w
#
## @(#) Checks event.log file for size and reports if file execeeds 1.5GB limit
#
use strict;
#my $now = localtime;
my $now = time();
my $logFile = "/var/adm/snm/event.log";
my $logSize = (stat($logFile))[7];
my $readtime = (stat($logFile))[9];
my $compareTime = scalar(localtime($readtime));

if ( $logSize > 1538118232 ) {
        $sendmail = "/usr/lib/sendmail";
                open(EMAIL, "| $sendmail -t") || die "Failed to open pipe";
                print EMAIL "Importance: high\n";
                print EMAIL "X-Priority: 1\n";
                print EMAIL "X-Message-Flag: For Your Information\n";
                print EMAIL "Content-Type: text/html\n";
                 print EMAIL "From:            root\n";
                print EMAIL "To: "email address"\n";
                print EMAIL "To: "email address"\n";
                print EMAIL "Subject:         Event.log file has exceeded the 1.5GB 
limit \n";
                close(EMAIL);
      }
exit;


Fred Johnson
Systems Engineer
Storagenetworks
225 Wyman Street
Waltham, MA
(781)622-6425(o)
(781)983-1170(m)
[EMAIL PROTECTED]


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to