def monitor(frist_invoke=1):
value_dic = {
'disk': {}
}
for part in psutil.disk_partitions(all=False):
if os.name == 'nt':
if 'cdrom' in part.opts or part.fstype == '':
# skip cd-rom drives with no disk in it; they may raise
# ENOENT, pop-up a Windows GUI error for a non-ready
# partition or just hang.
continue
mount_point = part.mountpoint
device = part.device
usage = psutil.disk_usage(part.mountpoint)
value_dic['disk'][mount_point] = {
'disk.device':device,
'disk.mount_point':mount_point,
'disk.total':usage.total/(1024*1024),
'disk.used':usage.used/(1024*1024),
'disk.free':usage.free/(1024*1024),
'disk.percent': usage.percent,
'disk.type':part.fstype,
}
return value_dic
评论列表
文章目录