Created
April 24, 2014 19:26
-
-
Save arenzana/11266480 to your computer and use it in GitHub Desktop.
Check disk space and report on
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use FileHandle; | |
$mailfrom = "sender\@example.com"; | |
$mailto = "recipient\@example.com"; | |
@check=`df -k`; | |
@warn = grep { m/(\d+\%)/ and $1 >=90} @check; | |
$mail = new FileHandle; | |
$mail->open("| /usr/sbin/sendmail -t") || die "Cannot open: $!"; | |
$mail->print("From: $mailfrom\n"); | |
$mail->print("To: $mailto\n"); | |
$mail->print("Subject: Disk space is low!\n\n"); | |
foreach (@warn) | |
{ | |
$mail->print($_, "\n"); | |
} | |
$mail->close(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment