This is my code
my @usage = `df -hT | grep -e CC -e usr`;
foreach (@usage) {
if ($_ =~ m/([0-9]{0,3})% \/(.*)/) {
print "$1 - $2\n";
if ( ($2 == "CC" && $1 >= 80) || ($2 == "usr" && $1 >= 90) ) {
print "/$2 parition is at $1% utilization\n";
}
}
}
It is a simple script to check if a partitions usage. The problem is in the IF condition.
if ( ($2 == "CC" && $1 >= 80) || ($2 == "usr" && $1 >= 90)
Should translate to IF (partition is CC and if use is more than 80% ) OR (IF partition is usr and its use is more than 90%) then output.
The my CC partition is at 83% and my usr is at 85%. Therefore I should only see
/CC partition is at 83%
But I get
83 - usr
/usr parition is at 85% utilization
83 - CC
/CC parition is at 83% utilization
Aucun commentaire:
Enregistrer un commentaire