栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

python-psutil

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

python-psutil

yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel gcc python-devel
yum -y install epel-release

git clone https://github.com/giampaolo/psutil.git
cd psutil
pip install psutil

import psutil datetime

#cpu实例化
cpu = psutil.cpu_times()
#内存实例化
mem = psutil.virtual_memory()
#虚拟内存
swap = psutil.swap_memory()
#磁盘
disk = psutil.disk_partitions()
#网络
net = psutil.net_io_conunters()
net1 = psutil.net_if_addrs()

实例获取回环IP

>> net1['lo'][0].address
'127.0.0.1'

获取本机的IP,我的本机是虚拟机的

>> net1['ens3'][0].address
'192.168.1.83'

#系统登录用户信息
uses = psutil.users()
#系统当前时间
date = datetime.datetime.fromtimestamp(psutil.boot_time()).strftime("%Y-%m-%d %H:%M:%S")

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/223890.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号