Commit 578e7233 authored by Leigh B Stoller's avatar Leigh B Stoller

Mostly cleanup and debugging stuff, but also implement fixed threshold

for signaling an unauthorized transmission. Using -0.95 for now.
parent 48715151
......@@ -220,67 +220,109 @@ sub HandleChild($)
my %rflimits = ();
my %violaters = ();
while (my $line = <$socket>) {
push(@lines, $line);
print $line
if ($debug);
}
# Close the connection, we do not tell the other side anything.
$socket->close();
my $processLine = sub {
my ($line) = @_;
if (@lines <= 1) {
print STDERR "Only one line from $address:$port. Ignoring.\n";
exit(0);
}
#
# The first line is a header, to make sure we agree on the format.
#
my $header = shift(@lines);
chomp($header);
if ($header ne $FORMAT) {
print STDERR "Improper format from $address:$port. Ignoring.\n";
exit(1);
}
while (@lines) {
my $line = pop(@lines);
chomp($line);
next
# Blank line.
return undef
if ($line =~ /^$/);
# Not sure why we are seeing a 0,0,0,0
return undef
if ($line =~ /^0,/);
my ($portid,$timestamp,$frequency,$power) = split(",", $line);
if (!(defined($portid) && defined($frequency) &&
defined($power) && defined($timestamp))) {
print STDERR "Missing data: '$line'\n";
next;
return undef;
}
if ($timestamp !~ /^[\.\d]+$/ ||
$frequency !~ /^[\.\d]+$/ ||
$power !~ /^[-\.\d]+$/) {
print STDERR "Improper float(s) from $address:$port:\n";
print STDERR " $line\n";
return undef;
}
#
# The portid is node:iface.
#
my ($nodeid,$iface) = split(":", $portid);
if (!(defined($nodeid) && defined($iface))) {
print STDERR "Improper portid from $address:$port: $portid.\n";
next;
print STDERR "Improper portid from $address:$port:\n";
print STDERR " $line\n";
return undef;
}
if (! TBcheck_dbslot($nodeid, "nodes", "node_id",
TBDB_CHECKDBSLOT_WARN|TBDB_CHECKDBSLOT_ERROR)) {
if ($nodeid !~ /^[-\w]+$/) {
print STDERR "Improper nodeid from $address:$port: $nodeid\n";
next;
return undef;
}
my $node = Node->Lookup($nodeid);
if (!$node) {
print STDERR "No such node $nodeid\n";
next;
}
my $measurement = {
return {
"node" => $node,
"node_id" => $nodeid,
"iface" => $iface,
"frequency" => $frequency,
"power" => $power,
"timestamp" => $timestamp,
};
};
while (my $line = <$socket>) {
$line =~ s/\r?\n//;
push(@lines, $line);
print $line . "\n"
if ($debug);
}
# Close the connection, we do not tell the other side anything.
$socket->close();
if (@lines < 10) {
print STDERR "Not enough data from $address:$port. Ignoring.\n";
exit(0);
}
#
# The first line is a header, to make sure we agree on the format.
#
my $header = shift(@lines);
chomp($header);
if ($header ne $FORMAT) {
print STDERR "Improper format from $address:$port. Ignoring.\n";
exit(1);
}
for (my $i = 0; $i < scalar(@lines); $i++) {
my $line = $lines[$i];
chomp($line);
my $measurement = &$processLine($line);
next
if (!defined($measurement));
my $node = $measurement->{"node"};
my $nodeid = $measurement->{"node_id"};
my $iface = $measurement->{"iface"};
my $frequency = $measurement->{"frequency"} + 0.0;
my $power = $measurement->{"power"} + 0.0;
my $timestamp = $measurement->{"timestamp"};
#
# This is bogus, I was expecting the monitor to only send me
# messages for actual transmission, not 1000s of lines. So I
# need to prune out anything that looks like noise. How do I
# do that? Not really sure, but with some playing around, it
# appears that -90 DB might be okay.
#
next
if ($power < -95);
print "Above threshold: $nodeid:$iface: $frequency,$power\n";
#
# Check for a report that comes in after we have powered off the
......@@ -463,7 +505,7 @@ sub HandleViolations($$)
print $subject . "\n";
print $body;
}
if (ShouldNotify($nodeid, "user")) {
if (!$impotent && ShouldNotify($nodeid, "user")) {
my $headers = undef;
if (defined($CC)) {
$headers = "CC: $CC";
......@@ -527,6 +569,11 @@ sub NodeNotify($$$)
{
my ($nodeid, $which, $mesg) = @_;
print "$mesg\n";
return
if ($impotent);
if (!ShouldNotify($nodeid, $which)) {
return;
}
......@@ -534,7 +581,7 @@ sub NodeNotify($$$)
"RF Daemon Critical Notification",
$mesg,
$TBOPS);
NodeNotified($nodeid, $which, $mesg);
}
......
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