Python 服务器监控
一、安装 paramiko 和 psutil
二、实现远程监控
三、问题 CryptographyDeprecationWarning
一、安装 paramiko 和 psutil
pip install paramiko
pip install psutil
1
2
二、实现远程监控
监控入口 run_perf.py
import os
from utils import *
def run_perf(host, port, user, password):
"""
读取脚本,执行监控
""""
base = os.getcwd()
cmd_file = base + r'/script.txt'
client = connect_to_server(host, port, user, password)
with open(cmd_file) as fp:
cmd = fp.read()
exec_script(client, cmd)
close_connection(client)
if __name__ == '__main__':
run_perf('10.2.2.100', 22, 'root', 'password')
远程连接 utils.py
import json
import paramiko
import psutil
def connect_to_server(host, por
Python 服务器监控
最新推荐文章于 2024-05-14 20:00:00 发布
![](https://img-home.csdnimg.cn/images/20240611030827.png)