zoukankan      html  css  js  c++  java
  • 系统内存与磁盘检测

    [root@swarm-213 ~]# cat systemissue.py 
    #!/usr/bin/env python3
    # -*- coding: utf-8 -*-
    # @Time    : 2018-12-17 17:16
    # @Author  : opsonly
    # @Site    : 
    # @File    : systemissue.py
    # @Software: PyCharm
    
    import psutil
    
    def memissue():
        print('内存信息:')
        mem = psutil.virtual_memory()
        # 单位换算为MB
        memtotal = mem.total/1024/1024
        memused = mem.used/1024/1024
    
        print('已用内存:%.2fMB' % memused)
        print('全部内存:%.2fMB' % memtotal)
        print('内存使用率:{:.2%}'.format(mem.used/mem.total))
    
    def disklist():
        print('磁盘信息:')
        disk = psutil.disk_partitions()
        diskuse = psutil.disk_usage('/')
        #单位换算为GB
        diskused = diskuse.used / 1024 / 1024 / 1024
        disktotal = diskuse.total / 1024 / 1024 / 1024
        diskbaifen = diskused / disktotal * 100
        print('硬盘使用:%.2fGB' % diskused)
        print('硬盘总大小:%.2fGB' % disktotal)
        print('硬盘使用率:{:.2%}'.format(diskbaifen/100))
        print('硬盘剩余率:{:.2%}'.format(diskuse.percent/100))
    
    
    memissue()
    print('*******************')
    disklist()
  • 相关阅读:
    sqlmap参数设置
    SQL注入
    SQL注入基本原理
    信息收集(shodan的使用)
    CDN
    2020软件工程个人作业06——软件工程实践总结作业
    问题清单
    2020软件工程作业05
    2020软件工程作业00——问题清单
    软件工程第三次作业
  • 原文地址:https://www.cnblogs.com/putihuakai/p/11413462.html
Copyright © 2011-2022 走看看