cancel
Showing results for 
Search instead for 
Did you mean: 
Post a Question
Danny
Pearl

One-liner for duplex settings summary

Jump to solution

Hello CheckMates,

I'm looking for a One-liner that provides a nice summary about the duplex settings and interface driver (vendor) of every network port in a system. I offer a Thank You badge worth 500 points in rewards.

cpstat os -f ifconfig already provides a nice summary of interface statistics, though missing duplex settings and interface drivers to identify if it's an Intel or a Broadcom or other interface type.

Yuri Slobodyanyuk‌ was creating something that goes into the right direction, but his one-liner is based on ifconfig, so it doesn't show any disabled interfaces. /etc/sysconfig/hwconf or the cpstat command shown above might be a better start to get all the interfaces within a system.

I'm looking forward to your entries. The one-liner that provides the best result wins.

1 Solution

Accepted Solutions
Admin
Admin

Re: One-liner for duplex settings summary

Jump to solution

In the interest of advancing the conversation, I will build on this a little. It's not perfect, but it gets closer to what i think you want:

[Expert@gateway:0]# ls -1 /sys/class/net | grep -v ^lo | xargs -I % sh -c 'ethtool %; ethtool -i %' | grep '^driver\|Speed\|Duplex\|Settings' | sed "s/^/ /g" | tr -d "\t" | tr -d "\n" | sed "s/Settings for/\nSettings for/g"                

Settings for eth0: Speed: 1000Mb/s Duplex: Full driver: e1000

Settings for eth1: Speed: 1000Mb/s Duplex: Full driver: e1000

Settings for eth2: Speed: 1000Mb/s Duplex: Full driver: e1000[Expert@gateway:0]#

No badges required for me Smiley Happy

8 Replies

Re: One-liner for duplex settings summary

Jump to solution

From expert mode:

dmesg | grep ": eth" | grep -v TSO | sort | uniq
e1000: eth0: e1000_probe: Intel(R) PRO/1000 Network Connection
e1000: eth0: e1000_watchdog_task: NIC Link is Up 1000 Mbps Full Duplex, Flow Control: None
e1000: eth1: e1000_probe: Intel(R) PRO/1000 Network Connection
e1000: eth1: e1000_watchdog_task: NIC Link is Up 1000 Mbps Full Duplex, Flow Control: None

or

grep ": eth" /var/log/messages* | grep -v TSO | cut -c66-999 | sort | uniq

 eth0: e1000_probe: Intel(R) PRO/1000 Network Connection
 eth0: e1000_watchdog_task: NIC Link is Up 1000 Mbps Full Duplex, Flow Control: None
 eth1: e1000_probe: Intel(R) PRO/1000 Network Connection
 eth1: e1000_watchdog_task: NIC Link is Up 1000 Mbps Full Duplex, Flow Control: None

--
My book "Max Power: Check Point Firewall Performance Optimization"
now available via http://maxpowerfirewalls.com.

"IPS Immersion Training" Self-paced Video Class
Now Available at http://www.maxpowerfirewalls.com
Danny
Pearl

Re: One-liner for duplex settings summary

Jump to solution

I've tested both One-liners on various Check Point Appliances and Open Servers without success. They don't reflect interfaces that start with names other than "eth" (e.g. Mgmt, Sync, Lan1, Lan2, ..) that somes Appliances use. But in general they don't work in most cases. Neither does dmesg contain any ": eth" entries nor does /var/log/messages always show the interface names before the Duplex setting or simply produces a big information overhead and no formatted summary. I'd still suggest that /etc/sysconfig/hwconf or the cpstat command are the best options to start from.

0 Kudos

Re: One-liner for duplex settings summary

Jump to solution
ls -1 /sys/class/net | grep -v ^lo | xargs -I % sh -c 'ethtool %; ethtool -i %' | grep '^driver\|Speed\|Duplex\|Settings' | tr -d "\t"  

Settings for eth0:
Speed: 1000Mb/s
Duplex: Full
driver: e1000
Settings for eth1:
Speed: 1000Mb/s
Duplex: Full
driver: e1000

--
My book "Max Power: Check Point Firewall Performance Optimization"
now available via http://maxpowerfirewalls.com.

"IPS Immersion Training" Self-paced Video Class
Now Available at http://www.maxpowerfirewalls.com
0 Kudos
Admin
Admin

Re: One-liner for duplex settings summary

Jump to solution

In the interest of advancing the conversation, I will build on this a little. It's not perfect, but it gets closer to what i think you want:

[Expert@gateway:0]# ls -1 /sys/class/net | grep -v ^lo | xargs -I % sh -c 'ethtool %; ethtool -i %' | grep '^driver\|Speed\|Duplex\|Settings' | sed "s/^/ /g" | tr -d "\t" | tr -d "\n" | sed "s/Settings for/\nSettings for/g"                

Settings for eth0: Speed: 1000Mb/s Duplex: Full driver: e1000

Settings for eth1: Speed: 1000Mb/s Duplex: Full driver: e1000

Settings for eth2: Speed: 1000Mb/s Duplex: Full driver: e1000[Expert@gateway:0]#

No badges required for me Smiley Happy

Danny
Pearl

Re: One-liner for duplex settings summary

Jump to solution

Thanks! This is extactly what I was looking for.

I've added this One-liner to our ccc-script.

0 Kudos
Admin
Admin

Re: One-liner for duplex settings summary

Jump to solution

Give the points/badge to Tim, all I did was make the output slightly prettier. Smiley Happy

0 Kudos
Danny
Pearl

Re: One-liner for duplex settings summary

Jump to solution

I gave Tim a badge with 1000 points.

Re: One-liner for duplex settings summary

Jump to solution

Indeed old habits die hard - in the Linux world ifconfig is long gone.
A fix would be (I will update the blog post as well) to replace ifconfig with ip add :

for ii in $(ip address | awk -F: ' /UP/ {print $2}') ;do ethtool  $ii; done | egrep 'Settings|Speed|Duplex'
Settings for lo:
Settings for eth1:
        Speed: 1000Mb/s
        Duplex: Full
Settings for eth5:
        Speed: 1000Mb/s
        Duplex: Full
Settings for eth2:
        Speed: 100Mb/s
        Duplex: Full

BTW Regarding disabled/downed interfaces - I just couldn't think of possible reason to learn their state...

Thanks @https://community.checkpoint.com/people/dantr917b8439-9d5c-34f0-b86a-f0e1b0a14cbd  for reminding me I have it at all Smiley Happy .

0 Kudos