获取网络总的io信息
[root@bogon python_auto]# vim net.py
!/usr/bin/env python
import psutil
net_information = psutil.net_io_counters()
print net_information
执行查看网络信息
[root@bogon python_auto]# python net.py
snetio(bytes_sent=29111743, bytes_recv=396060467, packets_sent=250211, packets_recv=487923, errin=0, errout=0, dropin=0, dropout=0)
获取每个网络接口的io信息
!/usr/bin/env python
import psutil
net_information = psutil.net_io_counters()
net_information = psutil.net_io_counters(pernic=True)
print net_information
执行查看每个网络接口的io信息
[root@bogon python_auto]# python net.py
{'lo': snetio(bytes_sent=4748000, bytes_recv=4748000, packets_sent=8607, packets_recv=8607, errin=0, errout=0, dropin=0, dropout=0), 'eth0': snetio(bytes_sent=24368607, bytes_recv=391319509, packets_sent=241645, packets_recv=479394, errin=0, errout=0, dropin=0, dropout=0)}
网友评论