* 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. 26
      html/skins/alteeve/main.js
  2. 8
      tools/scancore-update-states

@ -2,21 +2,23 @@ $(function() {
var say_up = $('#network_link_state').data('up');
var say_down = $('#network_link_state').data('down');
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) {
//alert('network status exists.');
$.getJSON('/status/network.json', { get_param: 'value' }, function(data) {
$.each(data.networks, function(index, element) {
console.log('entry: ['+index+'], name: ['+element.name+'], mac: ['+element.mac+'], link: ['+element.link+']');
var link = say_up;
if (element.link == 0) {
link = say_down;
}
$("#"+element.name+"_mac").text(element.mac);
$("#"+element.name+"_link").text(link);
$("#"+element.name+"_speed").text(element.speed+' '+say_speed_suffix);
setInterval(function() {
$.getJSON('/status/network.json', { get_param: 'value' }, function(data) {
$.each(data.networks, function(index, element) {
//console.log('entry: ['+index+'], name: ['+element.name+'], mac: ['+element.mac+'], link: ['+element.link+']');
var link = say_up;
if (element.link == 0) {
link = say_down;
}
$("#"+element.name+"_mac").text(element.mac);
$("#"+element.name+"_link").text(link);
$("#"+element.name+"_speed").text(element.speed+' '+say_speed_suffix);
});
});
});
}, 1000);
}
if($("#disk_status").length) {
//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 $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
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 => {
interface => $interface,
mac_address => $mac_address,
@ -76,7 +82,7 @@ sub report_network
closedir(DIRECTORY);
$network_json =~ s/,$//s;
$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";
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { network_xml => $network_xml }});

Loading…
Cancel
Save