mirror of https://github.com/aredn/aredn.git
aredn: Meshoween Mesh status page optimizations (#157)
* Memory and cpu performance improvements * Fix bandwidth reporting * Discard large arrays once we're done with them * Fixup whitespace * Improve string constructions * Use available mem * Print the Remote Nodes as we go (can be big) * Local variables * Stop re-reading arp/mac files * Reduce calls to system 'cat' * Simply lat/lon read * Only read route30 once * Whitespace * Make meshstatus limits configurable * and => &&, or => || * gzip content if we can fixes #155
This commit is contained in:
parent
f4a537a6df
commit
134532ab2a
|
@ -11,3 +11,5 @@ config map
|
||||||
option leafletjs 'http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.js'
|
option leafletjs 'http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.js'
|
||||||
option leafletcss 'http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.css'
|
option leafletcss 'http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.css'
|
||||||
option maptiles 'http://stamen-tiles-{s}.a.ssl.fastly.net/terrain/{z}/{x}/{y}.jpg'
|
option maptiles 'http://stamen-tiles-{s}.a.ssl.fastly.net/terrain/{z}/{x}/{y}.jpg'
|
||||||
|
|
||||||
|
config meshstatus
|
||||||
|
|
|
@ -162,6 +162,18 @@ push @setting, {
|
||||||
precallback => "restrictTunnelLimitToValidRange",
|
precallback => "restrictTunnelLimitToValidRange",
|
||||||
postcallback => "adjustTunnelInterfaceCount()"
|
postcallback => "adjustTunnelInterfaceCount()"
|
||||||
};
|
};
|
||||||
|
push @setting, {
|
||||||
|
key => "aredn.\@meshstatus[0].lowmem",
|
||||||
|
type => "string",
|
||||||
|
desc => "Specifies the low memory threshold (in KB) when we will truncate the mesh status page",
|
||||||
|
default => "10000"
|
||||||
|
};
|
||||||
|
push @setting, {
|
||||||
|
key => "aredn.\@meshstatus[0].lowroutes",
|
||||||
|
type => "string",
|
||||||
|
desc => "When low memory is detected, limit the number of routes shown on the mesh status page",
|
||||||
|
default => "1000"
|
||||||
|
};
|
||||||
push @setting, {
|
push @setting, {
|
||||||
key => "aredn.olsr.restart",
|
key => "aredn.olsr.restart",
|
||||||
type => "none",
|
type => "none",
|
||||||
|
|
|
@ -83,12 +83,29 @@ use perlfunc;
|
||||||
'MCS15' => '144.4',
|
'MCS15' => '144.4',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
# Limit displayed nodes and services to the most reachable routes if memory on the node is small
|
||||||
|
%lowMemoryLimits = (
|
||||||
|
memory => `/sbin/uci -q get aredn.\@meshstatus[0].lowmem` || 10000,
|
||||||
|
routes => `/sbin/uci -q get aredn.\@meshstatus[0].lowroutes` || 1000,
|
||||||
|
);
|
||||||
|
|
||||||
|
sub get_available_mem
|
||||||
|
{
|
||||||
|
foreach(`free`)
|
||||||
|
{
|
||||||
|
next unless /^Mem[:]/;
|
||||||
|
my @tmp = split /\s+/, $_;
|
||||||
|
return $tmp[6];
|
||||||
|
}
|
||||||
|
return "N/A";
|
||||||
|
}
|
||||||
|
|
||||||
# collect some variables
|
# collect some variables
|
||||||
$node = nvram_get("node");
|
$node = nvram_get("node");
|
||||||
$node = "NOCALL" if $node eq "";
|
$node = "NOCALL" if $node eq "";
|
||||||
$tactical = nvram_get("tactical");
|
$tactical = nvram_get("tactical");
|
||||||
$config = nvram_get("config");
|
$config = nvram_get("config");
|
||||||
$config = "not set" if $config eq "" or not -d "/etc/config.mesh";
|
$config = "not set" if $config eq "" || not -d "/etc/config.mesh";
|
||||||
($my_ip) = get_ip4_network(get_interface("wifi"));
|
($my_ip) = get_ip4_network(get_interface("wifi"));
|
||||||
${wifiif} = `uci -q get 'network.wifi.ifname'`;
|
${wifiif} = `uci -q get 'network.wifi.ifname'`;
|
||||||
chomp ${wifiif};
|
chomp ${wifiif};
|
||||||
|
@ -106,105 +123,103 @@ system "touch /tmp/web/automesh" if $parms{auto};
|
||||||
system "rm -f /tmp/web/automesh" if $parms{stop};
|
system "rm -f /tmp/web/automesh" if $parms{stop};
|
||||||
|
|
||||||
#get location info if available
|
#get location info if available
|
||||||
$lat_lon = "<strong>Location Not Available</strong>";
|
open my $rcgood, '<', '/etc/latlon';
|
||||||
if(-f "/etc/latlon") {
|
if ($rcgood)
|
||||||
$rcgood=open(FILE, "/etc/latlon");
|
|
||||||
if($rcgood) {
|
|
||||||
while(<FILE>){
|
|
||||||
chomp;
|
|
||||||
push @lat_lon,$_;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
close(FILE);
|
|
||||||
$lat_lon = "<center><strong>Location: </strong> $lat_lon[0] $lat_lon[1]</center>";
|
|
||||||
}
|
|
||||||
$olsrTotal = `/sbin/ip route list table 30 | wc -l`; #num hosts olsr is keeping track of
|
|
||||||
$olsrNodes = `/sbin/ip route list table 30 | egrep "/" | wc -l`; #num *nodes* on the network (minus other hosts)
|
|
||||||
$node_desc = `/sbin/uci -q get system.\@system[0].description`; #pull the node description from uci
|
|
||||||
|
|
||||||
# parse the txtinfo output
|
|
||||||
|
|
||||||
$table = "none";
|
|
||||||
chomp($tmperr = `mktemp /tmp/web/nc.XXXXXX`);
|
|
||||||
|
|
||||||
foreach(`echo /all | nc 127.0.0.1 2006 2>$tmperr`)
|
|
||||||
{
|
{
|
||||||
if(/^Table: (\w+)/)
|
$lat_lon = "<center><strong>Location: </strong> " . <$rcgood> . <$rcgood> . "</center>";
|
||||||
{
|
close $rcgood;
|
||||||
$table = $1;
|
|
||||||
next;
|
|
||||||
}
|
|
||||||
|
|
||||||
next if /^\s*$/ or /^\D/;
|
|
||||||
|
|
||||||
if($table eq "Links")
|
|
||||||
{
|
|
||||||
($junk, $ip, $junk, $lq, $nlq) = split /\s+/, $_;
|
|
||||||
$links{$ip}{lq} = $lq;
|
|
||||||
$links{$ip}{nlq} = $nlq;
|
|
||||||
|
|
||||||
$mac = `grep $ip /proc/net/arp | grep ${wifiif} | grep -v "00:00:00:00:00:00" | head -1`;
|
|
||||||
$mac =~ s/^.*(\w\w:\w\w:\w\w:\w\w:\w\w:\w\w).*$/$1/;
|
|
||||||
chomp $mac;
|
|
||||||
|
|
||||||
if (! $mac or ! -e "/sys/kernel/debug/ieee80211/${phy}/netdev:${wifiif}/stations/$mac" )
|
|
||||||
{
|
|
||||||
$mbps = "";
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
$lat_lon = "<strong>Location Not Available</strong>";
|
||||||
|
}
|
||||||
|
@route30 = `/sbin/ip route list table 30`;
|
||||||
|
$olsrTotal = scalar @route30;
|
||||||
|
$olsrNodes = scalar grep /\//, @route30;
|
||||||
|
$node_desc = `/sbin/uci -q get system.\@system[0].description`; #pull the node description from uci
|
||||||
|
undef @route30;
|
||||||
|
|
||||||
|
# parse the txtinfo output
|
||||||
|
|
||||||
|
chomp($tmperr = `mktemp /tmp/web/nc.XXXXXX`);
|
||||||
|
|
||||||
|
foreach(`echo /rou | nc 127.0.0.1 2006 2>>$tmperr`)
|
||||||
|
{
|
||||||
|
next if /^\D/;
|
||||||
|
my ($ip, $junk, $junk, $etx) = split /\s+/, $_;
|
||||||
|
my ($net, $cidr) = split /\//, $ip;
|
||||||
|
if ( $etx <= 50 ) { $routes{$net}{etx} = $etx; }
|
||||||
|
}
|
||||||
|
if ($olsrTotal > $lowMemoryLimits{routes} && get_available_mem() < $lowMemoryLimits{memory})
|
||||||
|
{
|
||||||
|
my @oroutes = sort { $routes{$a}{etx} <=> $routes{$b}{etx} } keys %routes;
|
||||||
|
foreach ( @oroutes[$lowMemoryLimits{routes} .. $#oroutes] )
|
||||||
|
{
|
||||||
|
delete $routes{$_};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@arps = {};
|
||||||
|
open my $fh, '<', '/proc/net/arp';
|
||||||
|
foreach (<$fh>) { push @arps, $_ if (/$wifiif/ && !/00:00:00:00:00:00/) }
|
||||||
|
close $fh;
|
||||||
|
foreach(`echo /lin | nc 127.0.0.1 2006 2>>$tmperr`)
|
||||||
|
{
|
||||||
|
next if /^\D/;
|
||||||
|
my ($junk, $ip, $junk, $lq, $nlq) = split /\s+/, $_;
|
||||||
|
$links{$ip} = {
|
||||||
|
lq => $lq,
|
||||||
|
nlq => $nlq,
|
||||||
|
mbps => ""
|
||||||
|
};
|
||||||
|
$neighbor{$ip} = 1;
|
||||||
|
|
||||||
|
my ($mac) = grep /^$ip/, @arps;
|
||||||
|
$mac =~ s/^.*(\w\w:\w\w:\w\w:\w\w:\w\w:\w\w).*$/$1/;
|
||||||
|
chomp $mac;
|
||||||
|
|
||||||
|
open my $fh, '<', "/sys/kernel/debug/ieee80211/${phy}/netdev:${wifiif}/stations/$mac/rc_stats_csv";
|
||||||
|
if ( $mac && $fh )
|
||||||
|
{
|
||||||
|
my @csv = <$fh>;
|
||||||
|
close $fh;
|
||||||
#802.11b/n
|
#802.11b/n
|
||||||
$mbps = `egrep '^([^,]*,){3}A' /sys/kernel/debug/ieee80211/${phy}/netdev\:${wifiif}/stations/$mac/rc_stats_csv`;
|
my ($mbps) = grep /^([^,]*,){3}A/, @csv;
|
||||||
if ($mbps)
|
if ($mbps)
|
||||||
{
|
{
|
||||||
($gi, $dummy, $rate, $dummy, $ewma) = $mbps =~ /^[^,]*,([^,]*),([^,]*,){2}([^,]*),([^,]*,){4}([^,]*).*$/ ;
|
my ($gi, $dummy, $rate, $dummy, $ewma) = $mbps =~ /^[^,]*,([^,]*),([^,]*,){2}([^,]*),([^,]*,){4}([^,]*).*$/ ;
|
||||||
$rate =~ s/[ \t]//g;
|
$rate =~ s/[ \t]//g;
|
||||||
$mbps = $gi eq "SGI" ? $rateS{$rate}*$ewma/100 : $rateL{$rate}*$ewma/100 ;
|
$mbps = $gi eq "SGI" ? $rateS{$rate}*$ewma/100 : $rateL{$rate}*$ewma/100 ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#802.11a/b/g
|
#802.11a/b/g
|
||||||
$mbps = `egrep \"^A" /sys/kernel/debug/ieee80211/${phy}/netdev\:${wifiif}/stations/$mac/rc_stats_csv`;
|
($mbps) = grep /^A/, @csv;
|
||||||
if ($mbps)
|
if ($mbps)
|
||||||
{
|
{
|
||||||
$mbps =~ /^[^,]*,([^,]*),([^,]*,){4}([^,]*).*$/;
|
$mbps =~ /^[^,]*,([^,]*),([^,]*,){4}([^,]*).*$/;
|
||||||
$mbps = $1*$3/100;
|
$mbps = $1*$3/100;
|
||||||
}
|
}
|
||||||
else { $mbps = "0"; }
|
|
||||||
}
|
}
|
||||||
if ( ! $mbps eq "" )
|
$links{$ip}{mbps} = $mbps ? sprintf "%.1f", $mbps / $chanbw : "0.0";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
undef @arps;
|
||||||
|
foreach(`echo /hna | nc 127.0.0.1 2006 2>>$tmperr`)
|
||||||
{
|
{
|
||||||
$mbps /= $chanbw;
|
next if /^\D/;
|
||||||
$links{$ip}{mbps} = sprintf "%.1f",$mbps;
|
my ($iproute, $ip) = split /\s+/, $_;
|
||||||
}
|
my ($net, $cidr) = split /\//, $iproute;
|
||||||
else { $links{$ip}{mbps} = "0.0"; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
elsif($table eq "Neighbors")
|
|
||||||
{
|
|
||||||
}
|
|
||||||
elsif($table eq "Topology")
|
|
||||||
{
|
|
||||||
}
|
|
||||||
elsif($table eq "HNA")
|
|
||||||
{
|
|
||||||
($iproute, $ip) = split /\s+/, $_;
|
|
||||||
($net, $cidr) = split /\//, $iproute;
|
|
||||||
if ( $net eq "0.0.0.0" ) { $wangateway{$ip} = 1; }
|
if ( $net eq "0.0.0.0" ) { $wangateway{$ip} = 1; }
|
||||||
}
|
}
|
||||||
elsif($table eq "MID")
|
foreach(`echo /mid | nc 127.0.0.1 2006 2>>$tmperr`)
|
||||||
{
|
{
|
||||||
($ip, $junk) = $_ =~ /^(\S+)\s+(.*)$/;
|
next if /^\D/;
|
||||||
foreach $aip ( split /\s+/, $junk ) { $ipalias{$aip} = $ip }
|
my ($ip, $junk) = $_ =~ /^(\S+)\s+(.*)$/;
|
||||||
}
|
foreach $aip ( split /\s+/, $junk )
|
||||||
elsif($table eq "Routes")
|
|
||||||
{
|
{
|
||||||
($ip, $junk, $junk, $etx) = split /\s+/, $_;
|
$ipalias{$aip} = $ip;
|
||||||
($net, $cidr) = split /\//, $ip;
|
$neighbor{$aip} = 1;
|
||||||
$routes{$net}{cidr} = $cidr;
|
if ( $links{$aip} ) { $neighbor{$ip} = 1 }
|
||||||
$routes{$net}{etx} = $etx;
|
|
||||||
$routes{$net}{value} = ip2decimal($net);
|
|
||||||
$routes{$net}{mask} = 0xffffffff - ((1 << (32 - $cidr)) - 1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,11 +229,13 @@ $txtinfo_err = $parts[4];
|
||||||
unlink $tmperr;
|
unlink $tmperr;
|
||||||
|
|
||||||
# load the local hosts file
|
# load the local hosts file
|
||||||
foreach(`cat /etc/hosts`)
|
|
||||||
|
open my $fh, '<', '/etc/hosts';
|
||||||
|
foreach (<$fh>)
|
||||||
{
|
{
|
||||||
next unless /^10[.]/;
|
next unless /^10[.]/;
|
||||||
chomp;
|
chomp;
|
||||||
($ip, $name, $tactical) = split /\s+/, $_;
|
my ($ip, $name, $tactical) = split /\s+/, $_;
|
||||||
next if $name =~ /^(localhost|localnode|localap|dtdlink\..*)$/;
|
next if $name =~ /^(localhost|localnode|localap|dtdlink\..*)$/;
|
||||||
if ( $name !~ /\./ ) { $name="${name}.local.mesh"; }
|
if ( $name !~ /\./ ) { $name="${name}.local.mesh"; }
|
||||||
if($ip eq $my_ip)
|
if($ip eq $my_ip)
|
||||||
|
@ -231,58 +248,71 @@ foreach(`cat /etc/hosts`)
|
||||||
if($tactical eq "#NOPROP") { push @{$localhosts{$my_ip}{noprops}}, $name; }
|
if($tactical eq "#NOPROP") { push @{$localhosts{$my_ip}{noprops}}, $name; }
|
||||||
if($tactical eq "#ALIAS") { push @{$localhosts{$my_ip}{aliases}}, $name; }
|
if($tactical eq "#ALIAS") { push @{$localhosts{$my_ip}{aliases}}, $name; }
|
||||||
}
|
}
|
||||||
|
close $fh;
|
||||||
|
|
||||||
# load the olsr hosts file
|
# load the olsr hosts file
|
||||||
foreach(`cat /var/run/hosts_olsr 2>/dev/null`)
|
open my $fh, '<', '/var/run/hosts_olsr';
|
||||||
|
foreach (<$fh>)
|
||||||
{
|
{
|
||||||
next unless /^\d/;
|
next unless /^\d/;
|
||||||
chomp;
|
chomp;
|
||||||
($ip, $name, undef, $originator, undef, undef) = split /\s+/, $_;
|
my ($ip, $name, undef, $originator, undef, undef) = split /\s+/, $_;
|
||||||
next unless $originator;
|
next unless $originator;
|
||||||
next if $originator eq "myself";
|
next if $originator eq "myself";
|
||||||
|
# Filter hosts which are unreachable
|
||||||
|
next unless $routes{$ip} || $routes{$originator};
|
||||||
|
|
||||||
|
my $etx = $routes{$ip}{etx} ? $routes{$ip}{etx} : $routes{$originator}{etx};
|
||||||
|
|
||||||
if (( $name !~ /\./ ) || ( $name =~ /^mid\.[^\.]*$/ )) { $name="${name}.local.mesh"; }
|
if (( $name !~ /\./ ) || ( $name =~ /^mid\.[^\.]*$/ )) { $name="${name}.local.mesh"; }
|
||||||
|
|
||||||
if ( $ip eq $originator )
|
if ( $ip eq $originator )
|
||||||
{
|
{
|
||||||
if($hosts{$ip}{name}) { $hosts{$ip}{tactical} = $name }
|
if ($hosts{$ip}{name})
|
||||||
|
{
|
||||||
|
$hosts{$ip}{tactical} = $name;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$hosts{$ip}{name} = $name;
|
$hosts{$ip}{name} = $name;
|
||||||
if ( $routes{$ip} ) { $hosts{$ip}{etx} = $routes{$ip}{etx} ; }
|
$hosts{$ip}{etx} = $etx;
|
||||||
else { $hosts{$ip}{etx} = "99.000"; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elsif ( $name =~ /^dtdlink\..*$/ )
|
elsif ( $name =~ /^dtdlink\..*$/ )
|
||||||
{
|
{
|
||||||
$hosts{$ip}{name} = $name;
|
|
||||||
$dtd{$originator} = 1;
|
$dtd{$originator} = 1;
|
||||||
if ( $routes{$ip} ) { $hosts{$ip}{etx} = $routes{$ip}{etx} ; }
|
if ( $links{$ip} ) { $links{$ip}{dtd} = 1 }
|
||||||
else { $hosts{$ip}{etx} = "99.000"; }
|
|
||||||
}
|
}
|
||||||
elsif ( $name =~ /^mid\d+\..*$/ )
|
elsif ( $name =~ /^mid\d+\..*$/ )
|
||||||
{
|
{
|
||||||
$midcount{$originator} = $midcount{$originator} ? $midcount{$originator}+1: 1 ;
|
$midcount{$originator} = $midcount{$originator} ? $midcount{$originator}+1: 1 ;
|
||||||
if (! $hosts{$ip}{name} )
|
if ( $links{$ip} ) { $links{$ip}{tun} = 1 }
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
if ( $routes{$ip} ) { $hosts{$ip}{etx} = $routes{$ip}{etx} ; }
|
push @{$hosts{$originator}{hosts}}, $name;
|
||||||
else { $hosts{$ip}{etx} = "99.000"; }
|
|
||||||
$hosts{$ip}{name} = $name;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else { push @{$hosts{$originator}{hosts}}, $name; }
|
close $fh;
|
||||||
}
|
|
||||||
|
# Discard
|
||||||
|
undef %routes;
|
||||||
|
|
||||||
# load the olsr services file
|
# load the olsr services file
|
||||||
foreach(`cat /var/run/services_olsr 2>/dev/null`)
|
open my $fh, '<', '/var/run/services_olsr';
|
||||||
|
foreach (<$fh>)
|
||||||
{
|
{
|
||||||
next unless /^\w/;
|
next unless /^\w/;
|
||||||
chomp;
|
chomp;
|
||||||
($url, $junk, $name) = split /\|/, $_;
|
my ($url, $junk, $name) = split /\|/, $_;
|
||||||
next unless defined $name;
|
next unless defined $name;
|
||||||
($protocol, $host, $port, $path) = $url =~ /^(\w+):\/\/([\w\-\.]+):(\d+)\/(.*)/;
|
my ($protocol, $host, $port, $path) = $url =~ /^(\w+):\/\/([\w\-\.]+):(\d+)\/(.*)/;
|
||||||
next unless defined $path;
|
next unless defined $path;
|
||||||
($name, $originator) = split /\#/, $name;
|
my ($name, $originator) = split /\#/, $name;
|
||||||
|
|
||||||
|
# Filter services for unreachable hosts
|
||||||
|
next unless $hosts{$originator}{name} || $originator eq " my own service";
|
||||||
|
|
||||||
$name =~ s/\s+$//;
|
$name =~ s/\s+$//;
|
||||||
|
|
||||||
if ( $host !~ /\./ ) { $host="${host}.local.mesh"; }
|
if ( $host !~ /\./ ) { $host="${host}.local.mesh"; }
|
||||||
|
@ -293,9 +323,11 @@ foreach(`cat /var/run/services_olsr 2>/dev/null`)
|
||||||
|
|
||||||
$services{$host}{$name} = $port ? "<a href='${protocol}://${host}:${port}/${path}' target='_blank'>$name</a>" : $name;
|
$services{$host}{$name} = $port ? "<a href='${protocol}://${host}:${port}/${path}' target='_blank'>$name</a>" : $name;
|
||||||
}
|
}
|
||||||
|
close $fh;
|
||||||
|
|
||||||
# load the node history
|
# load the node history
|
||||||
foreach(`cat /tmp/node.history 2>/dev/null`)
|
open my $fh, '<', '/tmp/node.history';
|
||||||
|
foreach (<$fh>)
|
||||||
{
|
{
|
||||||
chomp;
|
chomp;
|
||||||
($ip, $age, $host) = split / /, $_;
|
($ip, $age, $host) = split / /, $_;
|
||||||
|
@ -305,12 +337,23 @@ foreach(`cat /tmp/node.history 2>/dev/null`)
|
||||||
$history{$ip}{age} = $age;
|
$history{$ip}{age} = $age;
|
||||||
$history{$ip}{host} = $host;
|
$history{$ip}{host} = $host;
|
||||||
}
|
}
|
||||||
|
close $fh;
|
||||||
|
|
||||||
#delete $hosts{"127.0.0.1"};
|
#delete $hosts{"127.0.0.1"};
|
||||||
|
|
||||||
|
# compress the output if we can
|
||||||
|
if ( $ENV{HTTP_ACCEPT_ENCODING} =~ /gzip/ )
|
||||||
|
{
|
||||||
|
print "Content-type: text/html\r\nCache-Control: no-store\r\nContent-Encoding: gzip\r\n\r\n";
|
||||||
|
open my $zout, "|gzip";
|
||||||
|
select $zout;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print "Content-type: text/html\r\nCache-Control: no-store\r\n\r\n";
|
||||||
|
}
|
||||||
|
|
||||||
# generate the page
|
# generate the page
|
||||||
http_header();
|
|
||||||
html_header("$node mesh status", 0);
|
html_header("$node mesh status", 0);
|
||||||
print "<meta http-equiv='refresh' content='10;url=/cgi-bin/mesh'>\n" if -f "/tmp/web/automesh";
|
print "<meta http-equiv='refresh' content='10;url=/cgi-bin/mesh'>\n" if -f "/tmp/web/automesh";
|
||||||
print "</head>\n";
|
print "</head>\n";
|
||||||
|
@ -353,7 +396,7 @@ if($txtinfo_err)
|
||||||
|
|
||||||
print "</nobr><br><br>\n";
|
print "</nobr><br><br>\n";
|
||||||
|
|
||||||
unless(keys %localhosts or keys %links)
|
unless(keys %localhosts || keys %links)
|
||||||
{
|
{
|
||||||
print "No other nodes are available.\n";
|
print "No other nodes are available.\n";
|
||||||
print "</center></form>";
|
print "</center></form>";
|
||||||
|
@ -373,13 +416,13 @@ print "<tr><td colspan=5><hr></td></tr>\n";
|
||||||
|
|
||||||
if(keys %localhosts)
|
if(keys %localhosts)
|
||||||
{
|
{
|
||||||
%rows = ();
|
my %rows = ();
|
||||||
|
|
||||||
foreach $ip (keys %localhosts)
|
foreach $ip (keys %localhosts)
|
||||||
{
|
{
|
||||||
$host = $localhosts{$ip}{name};
|
my $host = $localhosts{$ip}{name};
|
||||||
$localpart = $host =~ s/.local.mesh//r;
|
my $localpart = $host =~ s/.local.mesh//r;
|
||||||
$tactical = $localhosts{$ip}{tactical} ? " / " . $localhosts{$ip}{tactical} : "";
|
my $tactical = $localhosts{$ip}{tactical} ? " / " . $localhosts{$ip}{tactical} : "";
|
||||||
$rows{$host} = sprintf "<tr><td valign=top><nobr>%s</nobr>", $localpart . $tactical;
|
$rows{$host} = sprintf "<tr><td valign=top><nobr>%s</nobr>", $localpart . $tactical;
|
||||||
|
|
||||||
if ( $wangateway{$ip} ) { $nodeiface = "wan" ; }
|
if ( $wangateway{$ip} ) { $nodeiface = "wan" ; }
|
||||||
|
@ -397,15 +440,14 @@ if(keys %localhosts)
|
||||||
foreach $dmzhost (@{$localhosts{$ip}{hosts}})
|
foreach $dmzhost (@{$localhosts{$ip}{hosts}})
|
||||||
{
|
{
|
||||||
#find non-propagated and aliased hosts and change color
|
#find non-propagated and aliased hosts and change color
|
||||||
$nopropd = 0;
|
my $nopropd = 0;
|
||||||
$aliased = 0;
|
my $aliased = 0;
|
||||||
if(grep { /$dmzhost/ } @{$localhosts{$ip}{noprops}}) { $nopropd = 1; }
|
if(grep { /$dmzhost/ } @{$localhosts{$ip}{noprops}}) { $nopropd = 1; }
|
||||||
if(grep { /$dmzhost/ } @{$localhosts{$ip}{aliases}}) { $aliased = 1; }
|
if(grep { /$dmzhost/ } @{$localhosts{$ip}{aliases}}) { $aliased = 1; }
|
||||||
$localpart = $dmzhost =~ s/.local.mesh//r;
|
$localpart = $dmzhost =~ s/.local.mesh//r;
|
||||||
if(!$nopropd and !$aliased) { $rows{$host} .= "<tr><td valign=top><nobr> <img src='/dot.png'>$localpart</nobr></td>"; }
|
if(!$nopropd && !$aliased) { $rows{$host} .= "<tr><td valign=top><nobr> <img src='/dot.png'>$localpart</nobr></td>"; }
|
||||||
elsif($aliased) { $rows{$host} .= "<tr><td class=aliased-hosts valign=top title='Aliased Host'><nobr> <img src='/dot.png'>$localpart</nobr></td>"; }
|
elsif($aliased) { $rows{$host} .= "<tr><td class=aliased-hosts valign=top title='Aliased Host'><nobr> <img src='/dot.png'>$localpart</nobr></td>"; }
|
||||||
else { $rows{$host} .= "<tr><td class=hidden-hosts valign=top title='Non Propagated Host'><nobr> <img src='/dot.png'>$localpart</nobr></td>"; }
|
else { $rows{$host} .= "<tr><td class=hidden-hosts valign=top title='Non Propagated Host'><nobr> <img src='/dot.png'>$localpart</nobr></td>"; }
|
||||||
|
|
||||||
$rows{$host} .= "<td colspan=3></td><td>\n";
|
$rows{$host} .= "<td colspan=3></td><td>\n";
|
||||||
foreach(sort keys %{$services{$dmzhost}})
|
foreach(sort keys %{$services{$dmzhost}})
|
||||||
{
|
{
|
||||||
|
@ -429,67 +471,52 @@ print "<tr><td> </td></tr>\n";
|
||||||
print "<tr><th align=left><nobr>Remote Nodes</nobr></th><th> </th><th>ETX</th><th> </th><th align=left>Services</th></tr>\n";
|
print "<tr><th align=left><nobr>Remote Nodes</nobr></th><th> </th><th>ETX</th><th> </th><th align=left>Services</th></tr>\n";
|
||||||
print "<tr><td colspan=5><hr></td></tr>\n";
|
print "<tr><td colspan=5><hr></td></tr>\n";
|
||||||
|
|
||||||
%rows = ();
|
my $row;
|
||||||
%sortrows = ();
|
foreach $ip (sort { $hosts{$a}{etx} <=> $hosts{$b}{etx} } keys %hosts)
|
||||||
foreach $ip (keys %hosts)
|
|
||||||
{
|
{
|
||||||
next if $links{$ip};
|
next if $neighbor{$ip};
|
||||||
next if $ipalias{$ip};
|
my $host = $hosts{$ip}{name};
|
||||||
|
next unless $host;
|
||||||
|
my $localpart = $host =~ s/.local.mesh//r;
|
||||||
|
my $tactical = $hosts{$ip}{tactical} ? " / " . $hosts{$ip}{tactical} : "";
|
||||||
|
my $etx = sprintf "%.2f", $hosts{$ip}{etx};
|
||||||
|
|
||||||
$isNeig=0;
|
$row = sprintf "<tr><td valign=top><nobr><a href='http://%s:8080/'>%s</a>", $host, $localpart . $tactical;
|
||||||
foreach $aip (keys %ipalias)
|
|
||||||
{
|
|
||||||
if ($ipalias{$aip} eq $ip ) { if ($links{$aip} ) { $isNeig=1; last;} }
|
|
||||||
}
|
|
||||||
next if $isNeig;
|
|
||||||
|
|
||||||
$host = $hosts{$ip}{name};
|
my $nodeiface;
|
||||||
$localpart = $host =~ s/.local.mesh//r;
|
my $mcount = 0 + $midcount{$ip};
|
||||||
$tactical = $hosts{$ip}{tactical} ? " / " . $hosts{$ip}{tactical} : "";
|
if ( $dtd{$ip} ) { $mcount -= 1; } # extra mid entry matching and with dtdlink in hosts_olsrd
|
||||||
$etx = sprintf "%.2f", $hosts{$ip}{etx};
|
if ( $hosts{$ip}{tactical} ) { $mcount -= 1; } # extra mid entry if tactical name defined
|
||||||
next if ($etx > 50 );
|
if ( $mcount > 0 ) { $nodeiface = "tun*$mcount" ; }
|
||||||
next if ($etx == 0 );
|
|
||||||
|
|
||||||
$rows{$host} = sprintf "<tr><td valign=top><nobr><a href='http://%s:8080/'>%s</a>", $host, $localpart . $tactical;
|
|
||||||
|
|
||||||
undef $nodeiface;
|
|
||||||
if ( $dtd{$ip} )
|
|
||||||
{
|
|
||||||
if ( $midcount{$ip} ) { $midcount{$ip} -= 1; } # extra mid entry matching and with dtdlink in hosts_olsrd
|
|
||||||
}
|
|
||||||
if ( $hosts{$ip}{tactical} ) { $midcount{$ip} -= 1; } # extra mid entry if tactical name defined
|
|
||||||
if ( $midcount{$ip} ) { $nodeiface = "tun*$midcount{$ip}" ; }
|
|
||||||
if ( $wangateway{$ip} ) { $nodeiface = $nodeiface ? $nodeiface . ",wan" : "wan" ; }
|
if ( $wangateway{$ip} ) { $nodeiface = $nodeiface ? $nodeiface . ",wan" : "wan" ; }
|
||||||
|
|
||||||
if ( $nodeiface ) { $rows{$host} .= " <small>($nodeiface)</small>"; }
|
if ( $nodeiface ) { $row .= " <small>($nodeiface)</small>"; }
|
||||||
|
|
||||||
$rows{$host} .= sprintf "</nobr></td><td></td><td align=right valign=top>%s</td><td></td><td>\n", $etx;
|
$row .= sprintf "</nobr></td><td></td><td align=right valign=top>%s</td><td></td><td>\n", $etx;
|
||||||
foreach(sort keys %{$services{$host}})
|
foreach(sort keys %{$services{$host}})
|
||||||
{
|
{
|
||||||
$rows{$host} .= "<nobr>" . $services{$host}{$_} . "</nobr><br>\n";
|
$row .= "<nobr>" . $services{$host}{$_} . "</nobr><br>\n";
|
||||||
}
|
}
|
||||||
$rows{$host} .= "</td></tr>\n";
|
$row .= "</td></tr>\n";
|
||||||
|
|
||||||
# add advertised dmz hosts
|
# add advertised dmz hosts
|
||||||
foreach $dmzhost (@{$hosts{$ip}{hosts}})
|
foreach $dmzhost (@{$hosts{$ip}{hosts}})
|
||||||
{
|
{
|
||||||
$localpart = $dmzhost =~ s/.local.mesh//r;
|
my $localpart = $dmzhost =~ s/.local.mesh//r;
|
||||||
$rows{$host} .= "<tr><td valign=top><nobr> <img src='/dot.png'>$localpart</nobr></td>";
|
$row .= "<tr><td valign=top><nobr> <img src='/dot.png'>$localpart</nobr></td>";
|
||||||
$rows{$host} .= "<td colspan=3></td><td>\n";
|
$row .= "<td colspan=3></td><td>\n";
|
||||||
foreach(sort keys %{$services{$dmzhost}})
|
foreach(sort keys %{$services{$dmzhost}})
|
||||||
{
|
{
|
||||||
$rows{$host} .= "<nobr>" . $services{$dmzhost}{$_} . "</nobr><br>\n";
|
$row .= "<nobr>" . $services{$dmzhost}{$_} . "</nobr><br>\n";
|
||||||
}
|
}
|
||||||
$rows{$host} .= "</td></tr>\n";
|
$row .= "</td></tr>\n";
|
||||||
}
|
}
|
||||||
$sortrows{$ip}=$host;
|
print $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(keys %rows)
|
undef %neighbor;
|
||||||
{
|
|
||||||
foreach(sort { $hosts{$a}{etx} <=> $hosts{$b}{etx} } keys %sortrows) { print $rows{$sortrows{$_}} }
|
if(!$row)
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
print "<tr><td>none</td></tr>\n";
|
print "<tr><td>none</td></tr>\n";
|
||||||
}
|
}
|
||||||
|
@ -504,49 +531,51 @@ print "<tr><td colspan=7><hr></td></tr>\n";
|
||||||
|
|
||||||
if(keys %links)
|
if(keys %links)
|
||||||
{
|
{
|
||||||
%rows = ();
|
my %rows = ();
|
||||||
|
|
||||||
foreach $ip (keys %links)
|
foreach $ip (keys %links)
|
||||||
{
|
{
|
||||||
$ipmain = exists $ipalias{$ip} ? $ipalias{$ip} : $ip ;
|
my $ipmain = exists $ipalias{$ip} ? $ipalias{$ip} : $ip ;
|
||||||
$host = $hosts{$ipmain}{name} ? $hosts{$ipmain}{name} : $ipmain;
|
my $host = $hosts{$ipmain}{name} ? $hosts{$ipmain}{name} : $ipmain;
|
||||||
$localpart = $host =~ s/.local.mesh//r;
|
my $localpart = $host =~ s/.local.mesh//r;
|
||||||
$tactical = $hosts{$ipmain}{tactical} ? " / " . $hosts{$ipmain}{tactical} : "";
|
my $tactical = $hosts{$ipmain}{tactical} ? " / " . $hosts{$ipmain}{tactical} : "";
|
||||||
if ( $rows{$host} ) { $host .= " " ; } # avoid collision 2 links to same host {rf, dtd}
|
if ( $rows{$host} ) { $host .= " " ; } # avoid collision 2 links to same host {rf, dtd}
|
||||||
|
|
||||||
$no_space_host=$host;
|
my $no_space_host=$host;
|
||||||
$no_space_host =~ s/\s+$//;
|
$no_space_host =~ s/\s+$//;
|
||||||
$rows{$host} = sprintf "<tr><td valign=top><nobr><a href='http://%s:8080/'>%s</a>", $no_space_host, $localpart . $tactical;
|
my $row = sprintf "<tr><td valign=top><nobr><a href='http://%s:8080/'>%s</a>", $no_space_host, $localpart . $tactical;
|
||||||
|
|
||||||
undef $nodeiface;
|
my $nodeiface;
|
||||||
if ( $ipmain ne $ip ) # indicate if dtd or tunnel interface to neighbor
|
if ( $ipmain ne $ip ) # indicate if dtd or tunnel interface to neighbor
|
||||||
{
|
{
|
||||||
if ( $hosts{$ip}{name} =~ /^dtdlink\..*$/ ){ $nodeiface="dtd" ; }
|
if ( $links{$ip}{dtd} ){ $nodeiface="dtd" ; }
|
||||||
elsif ( $hosts{$ip}{name} =~ /^mid\d+\..*$/ ) { $nodeiface="tun" ; }
|
elsif ( $links{$ip}{tun} ){ $nodeiface="tun" ; }
|
||||||
else { $nodeiface="?" ; }
|
else { $nodeiface="?" ; }
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $wangateway{$ip} or $wangateway{$ipmain} ) { $nodeiface = $nodeiface ? $nodeiface . ",wan" : "wan" ; }
|
if ( $wangateway{$ip} || $wangateway{$ipmain} ) { $nodeiface = $nodeiface ? $nodeiface . ",wan" : "wan" ; }
|
||||||
if ( $nodeiface ) { $rows{$host} .= " <small>($nodeiface)</small>"; }
|
if ( $nodeiface ) { $row .= " <small>($nodeiface)</small>"; }
|
||||||
|
|
||||||
$rows{$host} .= sprintf ("</nobr></td><td></td><td align=right valign=top>%.0f%%</td><td align=right valign=top>%.0f%%</td><td align=right valign=top>%s</td><td></td><td>\n", 100*$links{$ip}{lq}, 100*$links{$ip}{nlq},$links{$ip}{mbps});
|
$row .= sprintf ("</nobr></td><td></td><td align=right valign=top>%.0f%%</td><td align=right valign=top>%.0f%%</td><td align=right valign=top>%s</td><td></td><td>\n", 100*$links{$ip}{lq}, 100*$links{$ip}{nlq},$links{$ip}{mbps});
|
||||||
|
|
||||||
if ( ! exists $neighservices{$host} )
|
if ( ! exists $neighservices{$host} )
|
||||||
{
|
{
|
||||||
foreach(sort keys %{$services{$host}}) { $rows{$host} .= "<nobr>" . $services{$host}{$_} . "</nobr><br>\n" }
|
foreach(sort keys %{$services{$host}}) { $row .= "<nobr>" . $services{$host}{$_} . "</nobr><br>\n" }
|
||||||
|
|
||||||
$rows{$host} .= "</td></tr>\n";
|
$row .= "</td></tr>\n";
|
||||||
|
|
||||||
# add advertised dmz hosts
|
# add advertised dmz hosts
|
||||||
foreach $dmzhost (@{$hosts{$ipmain}{hosts}})
|
foreach $dmzhost (@{$hosts{$ipmain}{hosts}})
|
||||||
{
|
{
|
||||||
$localpart = $dmzhost =~ s/.local.mesh//r;
|
my $localpart = $dmzhost =~ s/.local.mesh//r;
|
||||||
$rows{$host} .= "<tr><td valign=top><nobr> <img src='/dot.png'>$localpart</nobr></td><td colspan=5></td><td>\n";
|
$row .= "<tr><td valign=top><nobr> <img src='/dot.png'>$localpart</nobr></td><td colspan=5></td><td>\n";
|
||||||
foreach(sort keys %{$services{$dmzhost}}) { $rows{$host} .= $services{$dmzhost}{$_} . "<br>\n" }
|
foreach(sort keys %{$services{$dmzhost}}) { $row .= $services{$dmzhost}{$_} . "<br>\n" }
|
||||||
$rows{$host} .= "</td></tr>\n";
|
$row .= "</td></tr>\n";
|
||||||
}
|
}
|
||||||
$neighservices{$host}=1;
|
$neighservices{$host}=1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$rows{$host}=$row;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach(sort keys %rows) { print $rows{$_} }
|
foreach(sort keys %rows) { print $rows{$_} }
|
||||||
|
@ -556,6 +585,7 @@ else
|
||||||
print "<tr><td>none</td></tr>\n";
|
print "<tr><td>none</td></tr>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
undef %services;
|
||||||
|
|
||||||
# show previous neighbors
|
# show previous neighbors
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue