- bump release number to fix pl_conf restart
[mom.git] / pl_mom.pl
index 8ed352f..55da825 100755 (executable)
--- a/pl_mom.pl
+++ b/pl_mom.pl
@@ -5,7 +5,7 @@ use Sys::Syslog;
 use Sys::Hostname;
 #use LWP::Simple;
 
-$debug = 1;
+$debug = 0;
 $proc = "pl_mom";
 $alias_addr = "pl-mom\@planet-lab.org";
 $from_addr = "support\@planet-lab.org";
@@ -197,8 +197,8 @@ sub bandwidth_monitor {
                    $Cap{$slice} = "sent";
                    bw_cap_mail($slice);
                    if (! $debug) {
-                       log_bandwidth_cap($slice, $bwcap_default);
-                       cap_bandwidth($slice, $bwcap_default);
+                       log_bandwidth_cap($slice, $Maxrate{$slice});
+                       cap_bandwidth($slice, $Maxrate{$slice});
                    } 
                }
            } else {
@@ -251,7 +251,7 @@ sub get_baseline_counts {
     my $sliceid = "9999";
     @Lines = split(/\n/, $status);
     foreach $line ( @Lines ) {
-       if ($line =~ /qdisc pfifo (.*):/) {
+       if ($line =~ /qdisc pfifo (.*): dev/) {
            $sliceid = $1;
        } else {
            if ($line =~ /Sent (.*) bytes/) {
@@ -363,12 +363,12 @@ sub bw_cap_mail {
     my ($slicename) = @_;
     my $hostname = hostname();
     my $date = get_date();
-    my $sent = int($Cutoff{$slicename}/1000000000);
+    my $sent = int($Cutoff{$slicename}/(1024*1024));
     my $bwcap = $Maxrate{$slicename};
 
     send_mail("$alias_addr, $slicename\@slices.planet-lab.org",
              "$proc capped bandwidth of slice $slicename on $hostname",
-             "Slice $slicename has transmitted more than ${sent}GB today".
+             "Slice $slicename has transmitted more than ${sent}MB today".
              " on $hostname.  ".
              "Its bandwidth will be capped at $bwcap until midnight GMT.".
              "\n\n$date $hostname bwcap $slicename\n");