Tuna has asked for the wisdom of the Perl Monks concerning the following question:
May the laughter commence.......#!/usr/local/bin/perl -w use strict; use Sys::Hostname; my ($fs, $kbytes, $used, $avail, $cap, $mount); my $line; my $host = hostname(); my $date = `date +%Y%m%d%H`; my $outfile = "/export/home/steve/disk_log.$host.$date"; my $sendmail ='/usr/lib/sendmail -t '; my $mailhdr = "To: steve\@foo.com\n". "Subject: Disk usage alarm - $host - $date\n====================== +================================\n\n"; open (OUTFILE, ">$outfile") || die "Can't open $outfile: $!\n"; print OUTFILE $mailhdr; close (OUTFILE); open (OUTFILE, ">>$outfile") || die "Can't open $outfile: $!\n"; my $cmd = `df -k /usr >> $outfile`; close (OUTFILE); open (OUTFILE, "$outfile") || die "Can't open $outfile: $!\n"; while ($line = <OUTFILE>) { chomp $line; next unless ($line =~ /^\//); ($fs, $kbytes, $used, $avail, $cap, $mount) = split(' ', $line); $cap =~ s/\%//; } close (OUTFILE); if ($cap >= 50) { system( "$sendmail < $outfile") == 0 or die "Can't Mail: $!\n"; } else { exit; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re (tilly) 1: Partition monitor, aka, I told you it was ugly
by tilly (Archbishop) on Mar 02, 2001 at 03:08 UTC | |
(jeffa) Re: Partition monitor, aka, I told you it was ugly
by jeffa (Bishop) on Mar 02, 2001 at 04:44 UTC | |
Re: Partition monitor, aka, I told you it was ugly
by archon (Monk) on Mar 02, 2001 at 03:08 UTC | |
Re: Partition monitor, aka, I told you it was ugly
by chipmunk (Parson) on Mar 02, 2001 at 04:21 UTC | |
Re: Partition monitor, aka, I told you it was ugly
by BlueLines (Hermit) on Mar 02, 2001 at 04:55 UTC | |
by a (Friar) on Mar 02, 2001 at 10:29 UTC |