my $speed = $link_state ? $anvil->Storage->read_file({file => $full_path."/speed"}) : 0; # Mbps (ie: 1000 = Gbps), gives a very high number for unplugged link
my $speed = $link_state ? $anvil->Storage->read_file({file => $full_path."/speed"}) : 0; # Mbps (ie: 1000 = Gbps), gives a very high number for unplugged link
my $media = "unknown";
my $media = "unknown";
my $type = "interface";
my $type = "interface";
my $driver = "";
my $tx_bytes = 0; # How many bytes transmitted
my $tx_bytes = 0; # How many bytes transmitted
my $rx_bytes = 0; # How many bytes received
my $rx_bytes = 0; # How many bytes received
@ -404,6 +406,7 @@ sub collect_data
$duplex =~ s/\n$//;
$duplex =~ s/\n$//;
$operational =~ s/\n$//;
$operational =~ s/\n$//;
$speed =~ s/\n$//;
$speed =~ s/\n$//;
$modalias =~ s/\n$//;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
interface => $interface,
interface => $interface,
link_state => $link_state,
link_state => $link_state,
@ -411,8 +414,17 @@ sub collect_data
duplex => $duplex,
duplex => $duplex,
operational => $operational,
operational => $operational,
speed => $speed,
speed => $speed,
modalias => $modalias,
}});
}});
### NOTE: This only parses virtio so far.
# Pick out our driver.
if ($modalias =~ /^virtio:/)
{
$driver = "virtio";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { driver => $driver }});
}
# The MAC address can faked by a number of ways, so we make an explicit call to 'ethtool' to get the permanent mac address.
# The MAC address can faked by a number of ways, so we make an explicit call to 'ethtool' to get the permanent mac address.
my $mac_address = "";
my $mac_address = "";
my $shell_call = $anvil->data->{path}{exe}{ethtool}." -P ".$interface;
my $shell_call = $anvil->data->{path}{exe}{ethtool}." -P ".$interface;
@ -490,7 +502,7 @@ sub collect_data
# If this is a virtual interface, set some fake values that don't actually exist on
# If this is a virtual interface, set some fake values that don't actually exist on
# the system for the sake of a cleaner display.
# the system for the sake of a cleaner display.
if ($mac_address =~ /^52:54:00/)
if (($mac_address =~ /^52:54:00/) or ($driver eq "virtio"))
{
{
### Set some fake values.
### Set some fake values.
# Speed is "as fast as possible", so we'll record 100 Gbps, but that is really kind of arbitrary.
# Speed is "as fast as possible", so we'll record 100 Gbps, but that is really kind of arbitrary.