>>> import psutil                                 #导入psutil
>>> a=psutil.virtual_memory()
>>> a.total #总虚拟内存
1023934464
>>> a.used #已用虚拟内存
214511616
>>> a.free #可用虚拟内存
427778048
>>> psutil.cpu_times() #cpu时间信息汇总
scputimes(user=18.26, nice=0.0, system=22.63, idle=5729.08, iowait=18.59, irq=0.0, softirq=0.46, steal=0.0, guest=0.0, guest_nice=0.0)
>>> psutil.cpu_times().user #cpu用户使用时间
18.27
>>> psutil.cpu_count() #cpu个数
1
>>> psutil.swap_memory() #查看交换内存
sswap(total=2147479552, used=0, free=2147479552, percent=0.0, sin=0, sout=0)
>>> psutil.virtual_memory() #查看虚拟内存
svmem(total=1023934464, available=656711680, percent=35.9, used=214511616, free=427778048, active=314855424, inactive=142458880, buffers=954368, cached=380690432, shared=7376896)
>>> psutil.disk_partitions() #查看分区情况
[sdiskpart(device='/dev/sda3', mountpoint='/', fstype='xfs', opts='rw,seclabel,relatime,attr2,inode64,noquota'), sdiskpart(device='/dev/sda1', mountpoint='/boot', fstype='xfs', opts='rw,seclabel,relatime,attr2,inode64,noquota')]
>>> psutil.disk_usage('/') #查看根目录使用情况
sdiskusage(total=19001245696, used=4089483264, free=14911762432, percent=21.5)
>>> psutil.disk_io_counters() #磁盘I/O个数
sdiskio(read_count=8307, write_count=4357, read_bytes=309452288, write_bytes=90153984, read_time=76537, write_time=9010, read_merged_count=14, write_merged_count=344, busy_time=30724)
>>> psutil.net_io_counters() #网络流量信息
snetio(bytes_sent=464928, bytes_recv=10280356, packets_sent=5316, packets_recv=9885, errin=0, errout=0, dropin=0, dropout=0)
>>> psutil.users() #用户信息
[suser(name='root', terminal='tty1', host='', started=1499413632.0), suser(name='root', terminal='pts/0', host='192.168.2.1', started=1499413760.0), suser(name='root', terminal='pts/1', host='192.168.2.1', started=1499414784.0)]

>>> datetime.datetime.fromtimestamp(psutil.boot_time()).strftime("%Y-%m-%d %H:%M:%S")     #获取开机时间,转换为易读的格式
'2018-02-21 19:22:32'
>>>


Python——psutil的使用(获取系统性能信息)的更多相关文章

  1. python之psutil模块(获取系统性能信息(CPU,内存,磁盘,网络)

    一.psutil模块 1. psutil是一个跨平台库(http://code.google.com/p/psutil/),能够轻松实现获取系统运行的进程和系统利用率(包括CPU.内存.磁盘.网络等) ...

  2. python 面向对象编程、获取对象信息

    面向对象与面向过程 参考链接:https://www.liaoxuefeng.com/wiki/0014316089557264a6b348958f449949df42a6d3a2e542c000/0 ...

  3. 测试成长记录:python调adb无法获取设备信息bug记录

    背景介绍: 一直在负责公司Android自动化的编写工作,采用的是uiautomator2,需要获取设备id来连接设备,就是 adb devices 问题描述: 之前一直用 subprocess.ch ...

  4. python+adb实现自动化获取手机信息

    首先我们先看一下使用adb查看Android手机信息的指令 #获取手机名称NAME = 'adb shell getprop ro.product.model'#获取手机版本VERSION = 'ad ...

  5. windows使用python原生组件包获取系统日志信息

    #coding=utf8 import sys import traceback import win32con import win32evtlog import win32evtlogutil i ...

  6. [Python] iupdatable包:获取电脑主板信息(csproduct)

    一.说明 使用命令行就可以获取到主板相关的信息 wmic csproduct get /value 输出内容如下: Caption=Computer System Product Descriptio ...

  7. 自动化之路 python psutil模块 收集硬件信息

    一.psutil模块 1. psutil是一个跨平台库,能够轻松实现获取系统运行的进程和系统利用率(包括CPU.内存.磁盘.网络等)信息.它主要应用于系统监控,分析和限制系统资源及进程的管理.它实现了 ...

  8. python psutil 模块

    一.获取系统性能信息 1 .CPU信息 User time,执行用户进程的时间百分比 System time,执行内核进程和中断的百分比 Wait IO,由于IO等待而使CPU处于idle(空闲)状态 ...

  9. python之psutil模块(获取系统性能数据)

    psutil模块 1.介绍 psutil是一个跨平台库(http://code.google.com/p/psutil/),能够轻松实现获取系统运行的进程和系统利用率(包括CPU.内存.磁盘.网络等) ...

随机推荐

  1. swiftlint 你所要知道的所有!!

    swiftin Should the opening brace of a function or control flow statement be on a new line or not ?:) ...

  2. python socket 网络编程selector用法 (实用)

    Server端: import socketimport selectors class Server(object):def init(self,sel,sock):self.sel = selse ...

  3. 完全卸载vs2013 2015

    /uninstall /force 解压你的vs2013的安装包(iso格式). cd到解压后的文件夹 vs_ultimate.exe /uninstall /force 或者创建一个快捷方式到桌面 ...

  4. 什么是RUP

    Rational统一过程(Rational  Unified  Process,RUP)是由Rational软件公司推出的一种完整且完美的软件过程. RUP总结了经过多年商业化验证的6条最有效的软件开 ...

  5. 使用DevExpress Reports和PDF Viewer创建AcroForm Designer

    众所周知,交互式表单(AcroForms)是PDF标准的重要组成部分,AcroForms允许开发者和开发者的用户创建可填写的PDF文档.尽管WinForms和WPF PDF Viewers不支持交互式 ...

  6. ssh 免密登陆

    A 要免密码登录要B 那么需要在A电脑上使用命令 ssh-keygen -t rsa 在~/.ssh/ 目录下生成id_rsa.pub 这个文件,然后将这个文件的内容拷到B电脑de ~/.ssh/au ...

  7. it网站

    1:http://www.importnew.com/    importnew  专注于java的论坛 2:Github是最活跃的开源代码库和版本控制平台,可以说是程序员当中知名度最高的技术社区.各 ...

  8. MVC4.0实现批量删除

    HTML: @using(Html.BeginForm("Delete","Home")){    <div>    <input type= ...

  9. 手机号的 AES/CBC/PKCS7Padding 加解密

    前言:接口中上次的手机号码和密码是传入的加密的,模拟自动化的时候也需要先对数据进行加密 1.各种语言实现 网上已经各种语言实现好的AES加密,可以点击查看:http://outofmemory.cn/ ...

  10. 客户端优化之使用javascript原生方法替代复杂的数学运算和jquery方法

    尽管jQuery等js框架相比原生javascript使用起来极为方便但是为什么在一些大型互联网公司还是一致强调前端开发人员的js基础,因为尽管javascript使用起来可能非常不便不仅体现在语法而 ...