#!/usr/bin/perl # check_diskspace.pl # # Description: This script will check disk capacity percentages # and send an email warning when it is above the warning or # panic levels. $warning = 84; $panic = 89; $email_list = "clearcase_admins\@mycompany.com"; $dfile = "/home/vobadm/clearcase/data/clearcase_diskspace"; $DF = "/bin/df"; $LS = "/bin/ls"; $host = `hostname`; $sendmail = '/usr/lib/sendmail -t'; chomp($host); @disks_to_check = ("server1:/clearcase","server2:/clearcase"); foreach $disk (@disks_to_check) { if ($disk =~ m/$host/) { ($dest,$disk2) = split(/:/,$disk); ($header_junk,$df_op,$blank_line) = `$DF -k $disk2`; } else { ($dest,$disk2) = split(/:/,$disk); `$LS /net/$dest/$disk2 > /dev/null`; ($header_junk,$df_op,$blank_line) = `$DF -k $disk`; } ($filesystem,$kbytes,$used,$avail,$capacity,$mount) = split(/\s+/,$df_op); #get rid of the % sign chop($capacity); if ($capacity > $panic) { $msg = "PANIC: The filesystem $disk is $capacity percent full."; open(MAIL, "| $sendmail"); print MAIL < $warning) { $msg = "WARNING: The filesystem $disk is $capacity percent full."; open(MAIL, "| $sendmail"); print MAIL <>${dfile}.${disk_ext}"); $now=time; $mbytes = int($kbytes/1024); $mused = int($used/1024); print DFILE $now . " " . $mbytes . " " . $mused . " " . "\n"; close(DFILE); }