disk.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:skynet 作者: skynetera 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号