码迷,mamicode.com
首页 > 其他好文 > 详细

psutil模块

时间:2019-09-16 13:43:40      阅读:93      评论:0      收藏:0      [点我收藏+]

标签:ack   out   pack   pre   virt   小数   psutil   util   核数   

import psutil
# cpu 详情
# re = psutil.cpu_percent(interval=1) # 返回cpu使用百分比
# re = psutil.cpu_count() # 返回CPU核数

# 内存
# re = psutil.virtual_memory() # 获取内存
# svmem(total=8476856320, available=4131033088, percent=51.3, used=4345823232, free=4131033088)
# a = float(re.total / (1024 * 1024 * 1024)) # 换成称G
# print (‘%.2f‘ %(a)) # 结果保留两位小数
# re = psutil.swap_memory() # 交换内存
# print(re)
# sswap(total=9819033600, used=5821399040, free=3997634560, percent=59.3, sin=0, sout=0)

# 硬盘
# disk = psutil.disk_usage(‘c:‘) # 硬盘使用情况
# print(disk)
# sdiskusage(total=127544819712, used=28217819136, free=99327000576, percent=22.1)
# io = psutil.disk_io_counters() # 读写情况
# read = io.read_bytes
# print(read/(1024*1024*1024))
# sdiskio(read_count=788575, write_count=531550, read_bytes=39608463360, write_bytes=28041613312, read_time=4995, write_time=1408)

# 网卡
# st = psutil.net_io_counters() # 总网卡流量
# print(st)
# snetio(bytes_sent=93165159, bytes_recv=3019070290, packets_sent=931277, packets_recv=2378624, errin=0, errout=0, dropin=0, dropout=0)
# bytes_sent=发送字节数 bytes_recv=接收字节数 packets_sent=发送的包数 packets_recv=接收包数 errin=接收错误的总数: errout=发送时错误的总数 dropin=被丢弃的传入包的总数 dropout=被丢弃的发出包的总数
# re = psutil.net_connections() # all网络信息
# print(re)

# 用户

psutil模块

标签:ack   out   pack   pre   virt   小数   psutil   util   核数   

原文地址:https://www.cnblogs.com/ZZYMiss/p/11526592.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!