$proc = "pl_mom";
$alias_addr = "pl-mom\@planet-lab.org";
$from_addr = "support\@planet-lab.org";
-$bwcap = "1.5Mbit";
+#$bwcap = "1.5Mbit";
+$bwcap = "off";
if (! $debug) {
$kill_thresh = 90;
$change_thresh = 5;
$min_thresh = 10;
$byte_cutoff = 16000000000; # 16GB
- #$byte_cutoff = 5000000000; # 5GB
$bwmon_sleep = 900;
$sendmail = "/usr/sbin/sendmail -t -f$from_addr";
$rebootfile = "/var/lib/misc/pl_mom.reboot";
$daily_log = "/var/lib/misc/pl_mom.daily";
$daily_stamp = "/var/lib/misc/pl_mom.stamp";
+ $configfile = "/etc/planetlab/pl_mom.conf";
} else {
$kill_thresh = 2;
$reboot_thresh = 20;
$rebootfile = "./pl_mom.reboot";
$daily_log = "./pl_mom.daily";
$daily_stamp = "./pl_mom.stamp";
+ $configfile = "./pl_mom.conf";
}
$sleep = 30;
system("echo $$ > $pidfile");
+read_config_file();
+
# Check to see whether pl_mom rebooted the node
if (-e $rebootfile) {
unlink($rebootfile);
$pid = fork();
if (! $pid) {
syslog ("info", "pl_mom: Launching bandwidth monitor");
+ if ($bwcap =~ /off/) {
+ syslog("info", "pl_mom: Bandwidth capping is off");
+ }
bandwidth_monitor();
die (0);
}
if (defined(%Cap)) {
# Reset bandwidth limits here
chomp($cap = `cat /etc/planetlab/bwcap`);
- foreach $slice ( sort ( keys %Cap ) ) {
+ foreach $sliceid ( sort ( keys %Cap ) ) {
+ $slice = get_slice_name($sliceid);
+ syslog("info", "pl_mom: Uncapping bandwidth of $slice");
cap_bandwidth ($slice, $cap);
}
undef %Cap;
}
}
close (BASE);
-
- foreach $slice ( sort (keys %Start) ) {
- if (defined $Now{$slice}) {
- $today = $Now{$slice} - $Start{$slice};
- if ($today >= $byte_cutoff && ! defined($Cap{$slice})) {
- $Cap{$slice} = "sent";
- $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");
+
+ if (!($bwcap =~ /off/)) {
+ foreach $slice ( sort (keys %Start) ) {
+ if (defined $Now{$slice}) {
+ $today = $Now{$slice} - $Start{$slice};
+ if ($today >= $byte_cutoff && ! defined($Cap{$slice})) {
+ $Cap{$slice} = "sent";
+ $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");
+ }
}
+ } else {
+ # Token bucket for this slice is gone!
}
- } else {
- # The /proc/virtual/<id> directory is gone...
}
}
}
}
+sub read_config_file {
+ if (-e $configfile) {
+ open (CONFIG, "<$configfile") ||
+ print "Cannot open $configfile; $!\n";
+ while (<CONFIG>) {
+ if (m/^(.*)=(.*)$/) {
+ ${$1} = $2;
+ if ($debug) {
+ print "read_config_file: $1 = ${$1}\n";
+ }
+ }
+ }
+ close CONFIG;
+ }
+}
+
sub send_mail {
# Arg 0: recipient addresses, comma-separated string
# Arg 1: subject line