python - 多台服务器的 CPU 利用率报告 - Python
问题描述
我正在尝试以 excel 或 csv 格式获取多台服务器的 ps -aux 命令输出。需要为不同工作表中的服务器打印输出。我无法做到这一点。有人可以通过完成此脚本来帮助我。
import paramiko
import subprocess
import json
import csv
with open(r'filepath\serverlist.json') as f:
data=json.load(f)
client = paramiko.SSHClient()
target_host = txt
un = 'root'
pwd = 'xxx'
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(hostname=target_host,username=un,password=pwd)
stdin, stdout, stderr = client.exec_command('ps -aux')
服务器的预期输出如下,并且需要为每个服务器保存在不同的工作表中。
解决方案
推荐阅读
- ios - 线程 17:EXC_BAD_INSTRUCTION 代码=EXC_1386_INVOP,子代码=0x0)
- javascript - 没有 CSS 和只有 JS 的手机和平板电脑的显示元素
- aws-lambda - 我想使用 python lamda 函数从事件日志中选择文件名
- operating-system - 为什么程序在内存而不是硬盘上执行?
- php - 即使使用 cookie 传输,Codeigniter Ajax 请求中也禁止 403
- xamarin - 如何显示所有页面通用的导航栏“TitleView”
- java - 如何在 Spring Boot 中启用 H2 数据库服务器模式
- arrays - 无法使用 Java 解决 IntelliJ 中 JSONArray 的符号错误
- gridview - VerticalGridView的焦点处理
- .net - FTP 传输代码失败并显示“[System.IO.FileStream] 不包含名为“CopyTo”的方法”