Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The shell script outputs the network card rate of multiple hosts

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Background:

To record the previously written shell script, you need to sort out the speed of each network card of each host. The name of the network card is bond0 to bond3. You can use the ethtool bond1 command to check the speed of the corresponding network card. Because there are dozens of hosts, consider using the shell script to query.

Specific ideas:

Query the speed command of single host and single network card:

Ethtool bond1 | grep SpeedSpeed: 20000Mb/s

Query all bond network card rate commands of a single host, and output the network card name and the corresponding network card rate:

For i in {0.3}; do echo bond$i `/ usr/sbin/ethtool bond$i 2 > / dev/null | grep Speed`; donebond0bond1 Speed: 20000Mb/sbond2 Speed: 20000Mb/sbond3 Speed: 2000Mb/s

To query all bond Nic rate commands of a remote host, you can use ssh-tt to remotely execute commands:

Ssh-tt user@192.168.1.1 "command"

All the IP to be queried are in the / etc/hosts file

File format:

192.168.1.1 compute-1

192.168.1.2 compute-2

Filter out the IP of 192 network segments

Cat / etc/hosts | grep 192 | cut-d'-F1

Use expect to enter passwords automatically

Complete script: #! / bin/bashcat / etc/hosts | grep 192 | while read linedoecho $lineip= `echo $line | cut-d''- f1` / usr/bin/expect

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report