首页 > 其他 > 详细

检查系统磁盘和内存使用情况

时间:2019-09-08 18:39:22      阅读:166      评论:0      收藏:0      [点我收藏+]
#!/usr/bin/python2.7
# -*- coding: utf-8 -*-
# @Time: 2019年8月14日
# @Author: trent

# 安装以下依赖工具
# python 2.7.5
# python-devel
# psutil-2.1.3

import psutil

def memissue():
    print(memory info: )
    mem = psutil.virtual_memory()
    # 单位换算为MB
    memtotal = float(mem.total/1024/1024)
    memused = float(mem.used/1024/1024)
    membaifen = memused/memtotal*100
    
    print(%.2fMB % memused)
    print(%.2fMB % memtotal)
    print(memory usage percent: %.2f % membaifen + %)

def disklist():
    print(disk info: )
    disk = psutil.disk_partitions()
    diskuse = psutil.disk_usage(/)
    #单位换算为GB
    diskused = float(diskuse.used / 1024 / 1024 / 1024)
    disktotal = float(diskuse.total / 1024 / 1024 / 1024)
    diskbaifen = diskused / disktotal * 100
    print(%.2fGB % diskused)
    print(%.2fGB % disktotal)
    print(disk usage percent: %.2f % diskbaifen + %)


memissue()
print(*******************)
disklist()

 

检查系统磁盘和内存使用情况

原文:https://www.cnblogs.com/fourw/p/11487512.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!