All new accounts created on Gitlab now require administrator approval. If you invite any collaborators, please let Flux staff know so they can approve the accounts.

Commit 38c82737 authored by Mike Hibler's avatar Mike Hibler

Break out send and receive for packets/bytes.

parent 00f5daaa
#!/usr/bin/perl -w
#
# Copyright (c) 2017 University of Utah and the Flux Group.
# Copyright (c) 2017-2018 University of Utah and the Flux Group.
#
# {{{EMULAB-LICENSE
#
......@@ -133,6 +133,7 @@ my $rateivs = 1;
my $maillast = 0;
my $mailsent = 0;
my @mailbody = ();
my @maildetails = ();
# Set this to turn off tblog in libraries.
$ENV{'TBLOG_OFF'} = "yep";
......@@ -212,6 +213,9 @@ $svar = "cnetwatch/mail_interval";
if (TBGetSiteVar($svar, \$tmp)) {
if ($tmp >= 0) {
$MAIL_IV = $tmp;
if ($MAIL_IV > 0) {
$sendmail = 1;
}
} else {
print STDERR "WARNING: invalid value for $svar sitevar, ignored.\n";
}
......@@ -452,6 +456,8 @@ sub sortem($$)
#
# Check for prolonged high traffic volumes from nodes.
# Counts: 0==s-bytes, 1==s-uni, 2==s-multi, 3==s-broad
# 4==r-bytes, 5==r-uni, 6==r-multi, 7==r-broad
#
sub reportevents($)
{
......@@ -468,13 +474,20 @@ sub reportevents($)
}
my $secs = $ref->{'tstamp'};
my @counts = @{$ref->{$node}{'counts'}};
my $pps = $counts[1] + $counts[2] + $counts[3] +
$counts[5] + $counts[6] + $counts[7];
my $bps = $counts[0] + $counts[4];
my $spkts = $counts[1] + $counts[2] + $counts[3];
my $rpkts = $counts[5] + $counts[6] + $counts[7];
my $sbytes = $counts[0];
my $rbytes = $counts[4];
$secs += $rates{$node}{'elapsed'};
$pps += $rates{$node}{'pkts'};
$bps += $rates{$node}{'bytes'};
$spkts += $rates{$node}{'spkts'};
$rpkts += $rates{$node}{'rpkts'};
$sbytes += $rates{$node}{'sbytes'};
$rbytes += $rates{$node}{'rbytes'};
my $pkts = $spkts + $rpkts;
my $bytes = $sbytes + $rbytes;
#
# XXX right now we do discrete intervals, we could do a sliding
......@@ -487,11 +500,18 @@ sub reportevents($)
my $ideal = ($rateivs * $interval);
logit("elapsed: actual=$sec, ideal=$ideal");
}
$pps = int($pps / $sec);
$bps = int($bps * 8 / $sec);
my $pps = int($pkts / $sec);
my $bps = int($bytes * 8 / $sec);
if (($MAX_PPS && $pps > $MAX_PPS) ||
($MAX_BPS && $bps > $MAX_BPS)) {
logit("$node: WARNING: pkts/sec=$pps, bits/sec=$bps over $sec seconds");
my $spps = int($spkts / $sec);
my $sbps = int($sbytes * 8 / $sec);
my $rpps = int($rpkts / $sec);
my $rbps = int($rbytes * 8 / $sec);
logit("$node: WARNING: pkts/sec=$pps (send=$spps, recv=$rpps)".
", bits/sec=$bps (send=$sbps, recv=$rbps)".
" over $sec seconds");
if ($sendmail) {
if (@mailbody == 0) {
my $pth = $bth = "no limit on";
......@@ -508,21 +528,37 @@ sub reportevents($)
sprintf("%20s %30s %8s %8s %s",
"Node:port", "Expt", "Pkts/sec", "Mb/sec", "When"));
}
if (@maildetails == 0) {
push(@maildetails,
"\nDetails:");
push(@maildetails,
sprintf("%20s %17s %17s %s",
"Node:port", "Send/Recv pps", "Send/Recv Mbs", "Duration"));
}
my $stamp = POSIX::strftime("20%y-%m-%d %H:%M:%S",
localtime($ref->{'start'}));
push(@mailbody,
sprintf("%20s %30s %8d %8d %s for %d sec",
$node, $pcs{$node}{'exp'}, $pps,
int($bps/1000000), $stamp, $secs));
push(@maildetails,
sprintf("%20s %8d/%-8d %8d/%-8d %d sec",
$node, $spps, $rpps,
int($sbps/1000000), int($rbps/1000000),
$secs));
}
}
$rates{$node}{'pkts'} = 0;
$rates{$node}{'bytes'} = 0;
$rates{$node}{'spkts'} = 0;
$rates{$node}{'rpkts'} = 0;
$rates{$node}{'sbytes'} = 0;
$rates{$node}{'rbytes'} = 0;
$rates{$node}{'iv'} = 0;
$rates{$node}{'elapsed'} = 0;
} else {
$rates{$node}{'pkts'} = $pps;
$rates{$node}{'bytes'} = $bps;
$rates{$node}{'spkts'} = $spkts;
$rates{$node}{'rpkts'} = $rpkts;
$rates{$node}{'sbytes'} = $sbytes;
$rates{$node}{'rbytes'} = $rbytes;
$rates{$node}{'iv'} = $iv;
$rates{$node}{'elapsed'} = $secs;
}
......@@ -538,17 +574,24 @@ sub reportevents($)
}
SENDMAIL($MAILTO,
"Excessive traffic on control network",
join("\n", @mailbody),
join("\n", @mailbody, @maildetails),
$TBOPS);
$maillast = time();
@mailbody = ();
@maildetails = ();
}
}
#
# Make a periodic report.
# Counts: 0==s-bytes, 1==s-uni, 2==s-multi, 3==s-broad
# 4==r-bytes, 5==r-uni, 6==r-multi, 7==r-broad
#
sub report($)
{
my ($ref) = @_;
# XXX allow for differentiation down the road
my $send = 1;
my $recv = 1;
......@@ -575,7 +618,7 @@ sub report($)
$bpkts += $counts[7];
}
$ref->{$node}{'totals'} =
[ $oct, $upkts, $mpkts, $upkts + $mpkts + $bpkts];
[ $oct, $upkts, $mpkts, $upkts + $mpkts + $bpkts ];
$pcs{$node}{'total'} = $upkts + $mpkts + $bpkts;
push(@list, $node);
}
......@@ -676,8 +719,10 @@ sub getnodeinfo($)
$newpcs{$cnet}{'name'} = $pc;
if (!exists($pcs{$cnet})) {
$rates{$cnet}{'pkts'} = 0;
$rates{$cnet}{'bytes'} = 0;
$rates{$cnet}{'spkts'} = 0;
$rates{$cnet}{'rpkts'} = 0;
$rates{$cnet}{'sbytes'} = 0;
$rates{$cnet}{'rbytes'} = 0;
$rates{$cnet}{'iv'} = 0;
$rates{$cnet}{'elapsed'} = 0;
if ($whine) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment