python利用wmi模块统计windows下网卡信息和连接数
2012-09-03 13:55
766 查看
# -*- coding: utf-8 -*-
#import
########################################################################
import os, sys
import time
import wmi
########################################################################
#function
########################################################################
def get_network_info() :
tmplist = []
c = wmi.WMI ()
intfid1 = 0
for interface in c.Win32_NetworkAdapterConfiguration (IPEnabled=1):
tmpdict = {}
tmpdict["Description"] = interface.Description
tmpdict["IPAddress"] = interface.IPAddress[0]
tmpdict["IPSubnet"] = interface.IPSubnet[0]
tmpdict["MAC"] = interface.MACAddress
tmpdict["MTU"] = interface.MTU
intfid2 = 0
for interfacePerf in c.Win32_PerfFormattedData_Tcpip_NetworkInterface():
if intfid1 == intfid2:
dir(interfacePerf)
tmpdict["BytesRSec"] = interfacePerf.BytesReceivedPerSec
tmpdict["BytesSSec"] = interfacePerf.BytesSentPerSec
tmpdict["BytesRPkg"] = interfacePerf.PacketsReceivedPersec
tmpdict["BytesSPkg"] = interfacePerf.PacketsSentPersec
intfid2 += 1
tmplist.append(tmpdict)
intfid1 += 1
return tmplist
def tcpvalues():
c = wmi.WMI ()
for interfacePerfTCP in c.Win32_PerfRawData_Tcpip_TCPv4():
return interfacePerfTCP.ConnectionsEstablished
if __name__ == "__main__":
print '-------------------'
print get_network_info()
print '-------------------'
print tcpvalues()
其他python网站访问地址:http://bbs.pythonfan.org/thread-2347-1-1.html本文出自 “学海无涯苦作伴” 博客,请务必保留此出处http://linuxshow.blog.51cto.com/1572053/980632
#import
########################################################################
import os, sys
import time
import wmi
########################################################################
#function
########################################################################
def get_network_info() :
tmplist = []
c = wmi.WMI ()
intfid1 = 0
for interface in c.Win32_NetworkAdapterConfiguration (IPEnabled=1):
tmpdict = {}
tmpdict["Description"] = interface.Description
tmpdict["IPAddress"] = interface.IPAddress[0]
tmpdict["IPSubnet"] = interface.IPSubnet[0]
tmpdict["MAC"] = interface.MACAddress
tmpdict["MTU"] = interface.MTU
intfid2 = 0
for interfacePerf in c.Win32_PerfFormattedData_Tcpip_NetworkInterface():
if intfid1 == intfid2:
dir(interfacePerf)
tmpdict["BytesRSec"] = interfacePerf.BytesReceivedPerSec
tmpdict["BytesSSec"] = interfacePerf.BytesSentPerSec
tmpdict["BytesRPkg"] = interfacePerf.PacketsReceivedPersec
tmpdict["BytesSPkg"] = interfacePerf.PacketsSentPersec
intfid2 += 1
tmplist.append(tmpdict)
intfid1 += 1
return tmplist
def tcpvalues():
c = wmi.WMI ()
for interfacePerfTCP in c.Win32_PerfRawData_Tcpip_TCPv4():
return interfacePerfTCP.ConnectionsEstablished
if __name__ == "__main__":
print '-------------------'
print get_network_info()
print '-------------------'
print tcpvalues()
其他python网站访问地址:http://bbs.pythonfan.org/thread-2347-1-1.html本文出自 “学海无涯苦作伴” 博客,请务必保留此出处http://linuxshow.blog.51cto.com/1572053/980632
相关文章推荐
- python利用wmi模块统计windows下硬盘信息
- python利用wmi模块统计windows下cpu信息
- python利用wmi统计windows下内存信息
- python使用wmi模块获取windows下的系统信息 监控系统
- python使用wmi模块获取windows下硬盘信息的方法
- python使用wmi模块获取windows下硬盘信息的方法
- python使用wmi模块获取windows下的系统信息 监控系统
- python使用WMI检测windows系统信息、硬盘信息、网卡信息的方法
- Python用WMI模块获取Windows系统的硬件信息
- python利用platform模块获取windows系统信息
- python利用WMI等监控获取windows状态如CPU、内存、硬盘等信息
- 利用python 与 wmi 获取WINDOWS基本信息
- python使用WMI检测windows系统信息、硬盘信息、网卡信息的方法
- (3)Python笔记:使用WMI模块+TCP/IP来远程监控系统信息
- 利用Python的requests模块爬取当当网的书籍信息(待续)
- Python3.5 Windows 7下 利用百度识图来获得图片信息
- javascript利用wmi获取客户端网卡信息
- PYWIN32 + WMI模块:获取WINDOWS系统基本信息
- Python WMI获取Windows系统信息 监控系统
- python写的用WMI检测windows系统信息的脚本