想写一个REST API来获取OS的CPU,内存等系统信息,正准备苦哈哈的轮一个 /proc/stat 的parser,发现了psutil ~ 一个跨平台的获取系统信息的python库,支持linux,windows,osx,sunos, 可以说很好,很全面,很pythonic
https://github.com/giampaolo/psutil
简介:
psutil (python system and process utilities) is a cross-platform library for retrieving information on running processes and system utilization(CPU, memory, disks, network) in Python. It is useful mainly for system monitoring, profiling and limiting process resources and management of running processes. It implements many functionalities offered by command line tools such as: ps, top, lsof, netstat, ifconfig, who, df, kill, free, nice, ionice, iostat, iotop, uptime, pidof, tty, taskset, pmap. It currently supportsLinux, Windows, OSX, FreeBSD and Sun Solaris, both 32-bit and64-bit architectures, with Python versions from 2.6 to 3.4 (users of Python 2.4 and 2.5 may use 2.1.3 version).PyPy is also known to work.
转载于:https://blog.51cto.com/shinn1982/1616305