! defined($Cap{$slice})) {
$Cap{$slice} = "sent";
bw_cap_mail($slice);
- if (! $debug) {
- log_bandwidth_cap($slice, $Maxrate{$slice});
- cap_bandwidth($slice, $Maxrate{$slice});
- }
+ log_bandwidth_cap($slice, $Maxrate{$slice});
+ cap_bandwidth($slice, $Maxrate{$slice});
}
} else {
# Token bucket for this slice is gone!
foreach $line ( @Lines ) {
if ($line =~ /qdisc pfifo (.*): dev/) {
$sliceid = hex($1);
+ # "Capped" buckets all begin with 0x1000. Ignore the root
+ # (0x1000) and default (0x1fff) buckets, as well as
+ # "exempt" buckets that begin with 0x2000 (or anything
+ # other than 0x1000).
+ if (($sliceid & 0xf000) == 0x1000 &&
+ $sliceid != 0x1000 && $sliceid != 0x1fff) {
+ $sliceid = $sliceid & 0x0fff;
+ } else {
+ $sliceid = 0xffff;
+ }
} else {
if ($line =~ /Sent (.*) bytes/) {
my $bytes = $1;
}
$Maxrate{$slice} = $limit;
$Cutoff{$slice} = $cutoff;
- if ($debug) {
- print "Slice $slice, maxrate $Maxrate{$slice}, ".
- "cutoff $Cutoff{$slice}\n";
- }
}
}
}
my $subject = "Subject: $_[1]\n";
my $msg = $_[2];
- open(SENDMAIL, "|$sendmail") or die "Cannot open $sendmail: $!";
- print SENDMAIL $to;
- print SENDMAIL $from;
- print SENDMAIL $subject;
- print SENDMAIL "Content-type: text/plain\n\n";
- print SENDMAIL $msg;
- close(SENDMAIL);
+ if ($debug) {
+ print $to;
+ print $subject;
+ } else {
+ open(SENDMAIL, "|$sendmail") or die "Cannot open $sendmail: $!";
+ print SENDMAIL $to;
+ print SENDMAIL $from;
+ print SENDMAIL $subject;
+ print SENDMAIL "Content-type: text/plain\n\n";
+ print SENDMAIL $msg;
+ close(SENDMAIL);
+ }
}
sub cap_bandwidth {