in reply to disk check using perl
Rather than trying to parse the the df output yourself, you may find it easier to work with the Filesys::Df module.
To send an e-mail to yourself, you should look into one of the many modules that exist to make this easy. I like MIME::Lite.
Update: Here is some (untested) code to work with. You will have to modify the email message with your e-mail addresses, and you might want to tweak the language of the Subject and Data (body text) to suit your style. Otherwise, the script reads the percent disk used from / and e-mails you if the percentage if greater than a threshold amount (in this case 90%)
#!/usr/bin/perl use strict; use warnings; use Filesys::Df; use MIME::Lite; my $disk_info = df("/"); my $threshold = 90; my $disk_percent; if (defined($disk_info)){ my $disk_percent = $disk_info->{per}; } if ($disk_percent > $threshold) { my $message = MIME::Lite->new ( From =>'diskwatcher@yourcomputer.com', To =>'fixitguy@othercomputer.com', Cc =>'someonewhocares@somedomain.com', Subject =>'ALERT: Im in ur disk usin ur inodes!', Data => "It appears that the disk use threshold is + approaching the limit defined in your helpful script. You currently +have $disk_percent percent used. Perhaps you should check on this." ); $message -> send ; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: disk check using perl
by steadybompipi (Novice) on Dec 14, 2007 at 17:35 UTC | |
by pfaut (Priest) on Dec 14, 2007 at 17:39 UTC | |
by poolpi (Hermit) on Dec 14, 2007 at 18:23 UTC |
In Section
Seekers of Perl Wisdom