Python——psutil的使用(收集系统基础信息)
2017-07-07 18:13
453 查看
>>> 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,at 4000 tr2,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)]
相关文章推荐
- 使用 python 收集获取 Linux 系统主机信息
- Python基础 获取系统信息 psutil
- python中系统信息获取psutil使用
- 使用Python收集获取Linux系统主机信息
- 使用Python收集获取Linux系统主机信息
- python自动化运维学习------使用模块psutil获取系统cpu、内存、磁盘、网络、进程等信息
- python3之模块psutil系统性能信息使用
- linux系统使用python获取cpu信息脚本分享
- linux系统使用python获取内存使用信息脚本分享
- 使用Python获取Linux系统的各种信息
- 使用 Python 获取 Linux 系统信息的代码
- 使用 Python 获取 Linux 系统信息的代码
- Python中的psutil:一个用于获得处理器和系统相关信息的模块
- python使用WMI检测windows系统信息、硬盘信息、网卡信息的方法
- 使用Python获取CPU、内存和硬盘等windowns系统信息的2个例子
- 使用python获取CPU和内存信息的思路与实现(linux系统)
- 使用python获取CPU和内存信息(linux系统)
- 使用Python获取CPU、内存和硬盘等windowns系统信息的2个例子
- 用python处理文本,本地文件系统以及使用数据库的知识基础
- python使用WMI检测windows系统信息、硬盘信息、网卡信息的方法