python 连接linux 获取cpu温度(python能做什么)

网友投稿 482 2022-09-01


python 连接linux 获取cpu温度(python能做什么)

# -*- coding: utf-8 -*-# @Time : 2022/3/31 9:05# @Author : wangyafeng# @FileName: ToLinux.py# @Email : # @Software: PyCharmimport paramiko,time,datetime# 创建SSHClient实例对象ssh = paramiko.SSHClient()# 调用方法,标识没有远程机器的公钥,允许访问# key = paramiko.RSAKey.from_private_key_file('/home/jeff/.ssh/id_rsa')ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())# 连接远程机器 地址端口用户名密码ssh.connect("192.168.2.203", 22, "root", "root")#查看内存while True: # print(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')) # stdin, stdout, stderr = ssh.exec_command("free -g") # out = str(stdout.read(), encoding='utf-8') # print("===================内存=================================") # print("total", out[97:99]) # print("buff/cache",out[146:148]) # print("available",out[158:160]) #同理 sensors同样 查看温度 print("=====温度======",datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')) sensorsstdin, sensorsstdout, sensorsstderr = ssh.exec_command("sensors") sensorsout=str(sensorsstdout.read(), encoding='utf-8') print(sensorsout) time.sleep(2)'''1、连接linux2、执行命令3、解析4、写入excle 5、加个while True: '''


版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:Spring5中SpringWebContext方法过时的解决方案
下一篇:1 浏览器的基本操作方法(1g等于多少mg)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~