* Changed scancore-update-states to report link speeds > 100 Gbps as 0.

* Added polling to update the network state as needed.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 8 years ago
parent f7616e4bb6
commit e983f27de7
  1. 6
      html/skins/alteeve/main.js
  2. 8
      tools/scancore-update-states

@ -2,12 +2,13 @@ $(function() {
var say_up = $('#network_link_state').data('up'); var say_up = $('#network_link_state').data('up');
var say_down = $('#network_link_state').data('down'); var say_down = $('#network_link_state').data('down');
var say_speed_suffix = $('#network_link_speed').data('mbps'); var say_speed_suffix = $('#network_link_speed').data('mbps');
console.log('say_up: ['+say_up+'], say_down: ['+say_down+'], say_speed_suffix: ['+say_speed_suffix+']'); //console.log('say_up: ['+say_up+'], say_down: ['+say_down+'], say_speed_suffix: ['+say_speed_suffix+']');
if($("#network_status").length) { if($("#network_status").length) {
//alert('network status exists.'); //alert('network status exists.');
setInterval(function() {
$.getJSON('/status/network.json', { get_param: 'value' }, function(data) { $.getJSON('/status/network.json', { get_param: 'value' }, function(data) {
$.each(data.networks, function(index, element) { $.each(data.networks, function(index, element) {
console.log('entry: ['+index+'], name: ['+element.name+'], mac: ['+element.mac+'], link: ['+element.link+']'); //console.log('entry: ['+index+'], name: ['+element.name+'], mac: ['+element.mac+'], link: ['+element.link+']');
var link = say_up; var link = say_up;
if (element.link == 0) { if (element.link == 0) {
link = say_down; link = say_down;
@ -17,6 +18,7 @@ $(function() {
$("#"+element.name+"_speed").text(element.speed+' '+say_speed_suffix); $("#"+element.name+"_speed").text(element.speed+' '+say_speed_suffix);
}); });
}); });
}, 1000);
} }
if($("#disk_status").length) { if($("#disk_status").length) {
//alert('disk status exists.'); //alert('disk status exists.');

@ -59,6 +59,12 @@ sub report_network
my $duplex = $an->Storage->read_file({file => $full_path."/duplex"}); # full or half? my $duplex = $an->Storage->read_file({file => $full_path."/duplex"}); # full or half?
my $operational = $an->Storage->read_file({file => $full_path."/operstate"}); # up or down my $operational = $an->Storage->read_file({file => $full_path."/operstate"}); # up or down
my $speed = $link_state ? $an->Storage->read_file({file => $full_path."/speed"}) : 0; # Mbps (ie: 1000 = Gbps), gives a very high number for unplugged link my $speed = $link_state ? $an->Storage->read_file({file => $full_path."/speed"}) : 0; # Mbps (ie: 1000 = Gbps), gives a very high number for unplugged link
if ($speed > 100000)
{
# This is probably 0 now... Though someday >100 Gbps will be reasonable and
# we'll need to change this.
$speed = 0;
}
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { $an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
interface => $interface, interface => $interface,
mac_address => $mac_address, mac_address => $mac_address,
@ -76,7 +82,7 @@ sub report_network
closedir(DIRECTORY); closedir(DIRECTORY);
$network_json =~ s/,$//s; $network_json =~ s/,$//s;
$network_json .= "]}\n"; $network_json .= "]}\n";
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { network_json => $network_json }}); $an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { network_json => $network_json }});
$network_xml .= "</network>\n"; $network_xml .= "</network>\n";
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { network_xml => $network_xml }}); $an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { network_xml => $network_xml }});

Loading…
Cancel
Save