c语言如何监控网卡信息,查看网卡信息及状态和网卡日志信息
查看網卡信息
1-mii-tool [-v/w] em1/em2/l0
em1: negotiated 100baseTx-FD, link ok
product info: vendor 00:aa:00, model 57 rev 1
basic mode:?? autonegotiation enabled
basic status: autonegotiation complete, link ok
capabilities: 1000baseT-FD 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD
advertising:? 1000baseT-FD 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD flow-control
link partner: 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD
mii-tool工具一定要指定網卡,不能查全部。
2- ifconfig /ifconfig -a
eth0??Link encap:Ethernet HWaddr
00:09:6B:09:08:FC??????????inet addr:192.168.10.1 Bcast:192.168.10.255
Mask:255.255.255.0?????????inet6 addr: fe80::209:6bff:fe09:8fc/64 Scope:Link??????????UPBROADCAST?RUNNING?MULTICAST?MTU:1500
Metric:1?????????RX packets:106732953 errors:0 dropped:0 overruns:0
frame:0?????????TX packets:104379788 errors:0 dropped:0 overruns:0
carrier:0?????????collisions:0 txqueuelen:100??????????RX bytes:2351331877 (2.1 GiB) TX bytes:391707945 (373.5
MiB)?????????Base address:0x2500
Memory:fbfe0000-fc000000???eth1???Link
encap:Ethernet HWaddr 00:09:6B:09:08:FD???????????BROADCAST
MULTICAST?MTU:1500 Metric:1?????????RX packets:0 errors:0 dropped:0 overruns:0 frame:0?????????TX packets:0 errors:0 dropped:0 overruns:0 carrier:0?????????collisions:0 txqueuelen:1000??????????RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)?????????Base address:0x2540 Memory:fbfc0000-fbfe0000
3- ethtool em1/em2/l0 查看指定網卡狀態
\Settings for em1:
Supported ports: [ TP ]
Supported link modes:?? 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Supported pause frame use: Symmetric
Supports auto-negotiation: Yes
Advertised link modes:? 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Advertised pause frame use: Symmetric
Advertised auto-negotiation: Yes
Speed: 100Mb/s
Duplex: Full
Port: Twisted Pair
PHYAD: 1
Transceiver: internal
Auto-negotiation: on
MDI-X: on (auto)
Supports Wake-on: pumbg
Wake-on: g
Current message level: 0x00000007 (7)
drv probe link
Link detected: yes
4- sar工具,清楚看到網卡帶寬是否打滿,監控網絡流量
sar -n DEV/EDEV/NFS/NFSD/SOCK/ALL
sar -n DEV (統計時間) (統計次數) :sar -n DEV 1 4(監控網絡流量)
sar-n顯示網絡信息,DEV顯示網絡接口信息,EDEV顯示網絡錯誤的統計數據,NFS統計活動的NFS客戶端信息,NFSD統計NFS服務器的信息,SOCK顯示套接字信息,ALL顯示所有5個開關
關注sar命令使用,統計、監控服務器信息
5-查看服務器網卡相關日志
/var/log/messages里面有沒有關于網卡的日志,有沒有網卡up/down的記錄
tail -n 100 /var/log/messages |grep (em1/em2/up/down/fail)
6- iptraf
實時查看網絡流量信息文本界面工具,不自帶
centos用yum -y install iptraf安裝
7-ifstat
查看實時網絡流量
8- iftop????實時查看網卡流量
總結
以上是生活随笔為你收集整理的c语言如何监控网卡信息,查看网卡信息及状态和网卡日志信息的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: C语言上证指数运行源码,个股对比上证指数
- 下一篇: 深度优先搜索c语言详解,深度优先搜索 —