Skip Menu |

This queue is for tickets about the IO-Interface CPAN distribution.

Report information
The Basics
Id: 29777
Status: new
Priority: 0/
Queue: IO-Interface

People
Owner: Nobody in particular
Requestors: bryant.eadon [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.03
Fixed in: (no value)



Subject: additional interface statistics
I notice there's a few useful statistics which aren't captured by IO::Interface , or perhaps I've just missed them The 'Link Speed', 'Link Duplex', 'Autonegotiate' seem to be missing. I have a quick few lines for ndd here to get these statistics. You'll need to be root to use them ( of course ). While it's a bit dirty, with some cleanup I thought you might want to gather these statistics into IO::Interface with a requirement on root access or setuid root for ndd. ******************** my %results = ( "0000" => "Down, 10 Mbps, Half Duplex, AutoNeg off", "0001" => "Down, 10 Mbps, Half Duplex, AutoNeg on", "0010" => "Down, 10 Mbps, Full Duplex, AutoNeg off", "0011" => "Down, 10 Mbps, Full Duplex, AutoNeg on", "0100" => "Down, 100 Mbps, Half Duplex, AutoNeg off", "0101" => "Down, 100 Mbps, Half Duplex, AutoNeg on", "0110" => "Down, 100 Mbps, Full Duplex, AutoNeg off", "0111" => "Down, 100 Mbps, Full Duplex, AutoNeg on", "1000" => "Up, 10 Mbps, Half Duplex, AutoNeg off", "1001" => "Up, 10 Mbps, Half Duplex, AutoNeg on", "1010" => "Up, 10 Mbps, Full Duplex, AutoNeg off", "1011" => "Up, 10 Mbps, Full Duplex, AutoNeg on", "1100" => "Up, 100 Mbps, Half Duplex, AutoNeg off", "1101" => "Up, 100 Mbps, Half Duplex, AutoNeg on", "1110" => "Up, 100 Mbps, Full Duplex, AutoNeg off", "1111" => "Up, 100 Mbps, Full Duplex, AutoNeg on", "01000" => "Down, 10 Mbps, Half Duplex, AutoNeg off", "01001" => "Down, 10 Mbps, Half Duplex, AutoNeg on", "01010" => "Down, 10 Mbps, Full Duplex, AutoNeg off", "01011" => "Down, 10 Mbps, Full Duplex, AutoNeg on", "010000" => "Down, 100 Mbps, Half Duplex, AutoNeg off", "010001" => "Down, 100 Mbps, Half Duplex, AutoNeg on", "010010" => "Down, 100 Mbps, Full Duplex, AutoNeg off", "010011" => "Down, 100 Mbps, Full Duplex, AutoNeg on", "0100000" => "Down, 1000Mb/s, Half, AutoNeg off", "0100001" => "Down, 1000Mb/s, Half, AutoNeg on", "0100010" => "Down, 1000Mb/s, Full, AutoNeg off", "0100011" => "Down, 1000Mb/s, Full, AutoNeg on", "11000" => "Up, 10 Mbps, Half Duplex, AutoNeg off", "11001" => "Up, 10 Mbps, Half Duplex, AutoNeg on", "11010" => "Up, 10 Mbps, Full Duplex, AutoNeg off", "11011" => "Up, 10 Mbps, Full Duplex, AutoNeg on", "110000" => "Up, 100 Mbps, Half Duplex, AutoNeg off", "110001" => "Up, 100 Mbps, Half Duplex, AutoNeg on", "110010" => "Up, 100 Mbps, Full Duplex, AutoNeg off", "110011" => "Up, 100 Mbps, Full Duplex, AutoNeg on", "1100000" => "Up, 1000Mb/s, Half, AutoNeg off", "1100001" => "Up, 1000Mb/s, Half, AutoNeg on", "1100010" => "Up, 1000Mb/s, Full, AutoNeg off", "1100011" => "Up, 1000Mb/s, Full, AutoNeg on", "1e" => "Up?, 10 Mbps, Half Duplex, no AutoNeg" ); sub doNDD() { my $if = shift; #%pre: $if is defined to be a valid network interface. Uses ndd. Only called on Solaris. #%post: Returns the Link Status, Link Speed, Link Duplex and Autonegotiate settings for # $if. Encoded as per %res. my $RES = ""; if ($if =~ m/^(\D+)(\d+)$/) { my $dev = $1; my $instance = $2; # if it's a lance ethernet card, Just output defaults. (10 Half). if ($dev ne "le") { #select which interface if ($dev =~ "bg") { open(NDD, "/usr/sbin/ndd -get /dev/$dev$instance link_status link_speed link_duplex adv_autoneg_cap |") or die "Can't execute ndd command: $!"; } else { system ("/usr/sbin/ndd -set /dev/$dev instance $instance"); open(NDD, "/usr/sbin/ndd -get /dev/$dev link_status link_speed link_mode adv_autoneg_cap |") or die "Can't execute ndd command: $!"; } while (<NDD>){ chomp; if ($_ =~/^\d/){ $RES = $RES . $_ ; } } close NDD; } else { $RES = $dev; } } return $RES; } ************************* I also have an equivalent for Linux using ethtool : ************************* sub get_ethtool_stats { my $if_stats = shift; foreach my $if ( keys %$if_stats ) { if ( $if =~ /lo/ ) { $if_stats{$if}{'print'} = 0; next; } my $output = `$ETHTOOL_BIN $if`; $output =~ /\s+Speed:\s+(\S+).*Duplex:\s+(\w+).*Auto-negotiation:\s+(\w+)/s; $if_stats{$if}{'speed'} = $1; $if_stats{$if}{'duplex'} = $2; $if_stats{$if}{'autoneg'} = $3; $if_stats{$if}{'print'} = 1; print "OUTPUT $if:->$output<-\n"; print "->$1<- , ->$2<- , ->$3<-\n" } }