$log_thresh = 85;
$change_thresh = 5;
$min_thresh = 10;
- #$byte_cutoff = 16000000000; # 16GB
- $byte_cutoff = 5000000000; # 5GB
+ $byte_cutoff = 16000000000; # 16GB
+ #$byte_cutoff = 5000000000; # 5GB
$bwmon_sleep = 900;
$sendmail = "/usr/sbin/sendmail -t -f$from_addr";
# Could save the list of capped slices in a file in order to
# avoid re-sending mails if the daemon restarts.
# Also may want a list of slices that are exempt from capping.
- if (defined(%Cap)) {
- undef %Cap;
+ if (defined(%Start)) { undef %Start; }
+ if (defined(%Now)) { undef %Now; }
+
+ if (defined(%Cap)) {
+ # Reset bandwidth limits here
+ chomp($cap = `cat /etc/planetlab/bwcap`);
+ foreach $slice ( sort ( keys %Cap ) ) {
+ cap_bandwidth ($slice, $cap);
+ }
+ undef %Cap;
}
- # Need to reset bandwidth limits here
-
syslog("info", "pl_mom: Beginning bandwidth monitoring for $now");
}
$slicename = get_slice_name($slice);
if ($slicename) {
bw_cap_mail($slicename);
+ # Cap bandwidth here
+ cap_bandwidth($slicename, $bwcap);
} else {
syslog("warning", "pl_mom: Could not find slice name".
" for slice ID $slice");
}
- # Add bandwidth cap here
}
} else {
# The /proc/virtual/<id> directory is gone...
close(SENDMAIL);
}
+sub cap_bandwidth {
+ # Arg 0: slice name
+ # Arg 1: bandwidth cap for 'tc'
+ `bwlimit setcap $_[0] $_[1]`;
+ `bwlimit on $_[0]`;
+}
+
sub get_date {
my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdat)
= localtime(time);
syslog("warning", "pl_mom: Capping bandwidth of slice ".
"$slicename at $bwcap until midnight GMT.");
- send_mail("acb\@planet-lab.org",
+ send_mail($alias_addr,
"$proc capped bandwidth of slice $slicename on $hostname",
"Slice $slicename has transmitted more than ${sent}GB today".
" on $hostname. ".