Skip to content

Instantly share code, notes, and snippets.

@arenzana
Created April 24, 2014 19:26
Show Gist options
  • Save arenzana/11266480 to your computer and use it in GitHub Desktop.
Save arenzana/11266480 to your computer and use it in GitHub Desktop.
Check disk space and report on
#!/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