Skip to main content

远程主机资源监控工具:SSH 采集 CPU / 内存 / 网络 / 磁盘 / 温度 + 持续 ping,支持 Web 实时面板与日志回放

Project description

fourier-resm · 远程主机监控工具

PyPI version Python versions License: MIT

持续 ping 目标 IP 并通过 SSH 采集目标机器的系统资源(CPU / 内存 / Swap / 网络 / 磁盘 IO / CPU 温度 / loadavg),实时写入 CSV 日志,并附带 Web 实时面板与日志回放。

PyPI: https://pypi.org/project/fourier-resm/

安装

pip install fourier-resm

快速开始

fourier-resm <user> <host>

默认会:交互式提示输入 SSH 密码 → 启动 Web 面板于 http://0.0.0.0:8000/

示例:

fourier-resm root 192.168.1.100
fourier-resm ubuntu 10.0.0.5 --ping-interval 0.5 --res-interval 1 -o ./logs
fourier-resm root 192.168.1.100 -k ~/.ssh/id_rsa --no-ask-pass    # 用密钥
fourier-resm root 192.168.1.100 --no-web                          # 仅 CLI
fourier-resm --replay-only ./logs                                 # 只读回放目录
fourier-resm --replay-only ./logs/ping_1.2.3.4_20260423_120000.csv # 只读回放单会话

功能

  • Ping:默认 1s 一次(可调 0.05 ~ 60s),延迟精度 0.001 ms。
  • SSH 资源采集:通过远端 /proc/* 计算 1 秒区间的 CPU / 网络 / 磁盘速率:
    • cpu_percent
    • mem_total/used/avail_MBmem_percent
    • swap_total/used_MBswap_percent
    • net_rx/tx(Mbps 与 MB/s 双单位)
    • disk_read/write(MB/s)
    • cpu_temp_C(优先 coretemp/k10temp/thermal_zone)
    • loadavg(1/5/15 分钟)
    • 每块网卡的 rx/tx 速率
  • 实时写盘:每条记录立即 flush 到 CSV。
  • Web 面板:6 个 KPI + 6 张 Chart.js 实时图,支持「最近 N 分钟」窗口、运行时调节采样频率。
  • 日志回放:列出历史会话,双端点时间滑块 + 播放头,全部图表同步回放,支持变速。
  • 断线自动重连:SSH 断开后指数退避重连;ping 线程独立不受影响。

参数

参数 说明 默认
user SSH 用户名(位置参数) 必填
host 目标 IP / 主机名(位置参数) 必填
-P/--port SSH 端口 22
-k/--key SSH 私钥路径 无(尝试 ssh-agent / 默认密钥)
-p/--password SSH 密码(不建议命令行传入)
--no-ask-pass 禁用交互式密码输入 默认开启交互
--ping-interval Ping 间隔(秒) 1.0
--res-interval 资源采样间隔(秒) 2.0
-o/--output 日志目录 ./logs
--replay-only PATH 只读回放模式:只读取历史日志目录或单个 CSV,会自动启用 Web,不进行采集与写盘
--no-web 禁用 Web 面板 默认开启 Web
--web-host Web 监听地址 0.0.0.0
--web-port Web 监听端口 8000

输出

-o 指定目录(默认 ./logs)下生成:

  • ping_<host>_<时间戳>.csvtimestamp, host, latency(ms), status
  • resource_<host>_<时间戳>.csv:含 CPU / 内存 / Swap / 网络(Mbps & MB/s) / 磁盘 / CPU 温度 / loadavg / 每网卡速率

控制台每 5 秒打印一次 ping 丢包 / min/avg/max 汇总。

目标机器要求

  • Linux,有 python3(或 python);仅读取 /proc/*/sys/class/thermal|hwmon
  • SSH 可连接。
  • 若 ICMP 被禁用,ping 会全部超时,但 SSH 资源采集仍正常工作。

源码开发

git clone https://gitlab.fftaicorp.com/pfs/resource_monitor.git
cd resource_monitor
pip install -e .
fourier-resm <user> <host>

License

MIT — 见 LICENSE

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fourier_resm-1.2.0.tar.gz (28.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fourier_resm-1.2.0-py3-none-any.whl (27.2 kB view details)

Uploaded Python 3

File details

Details for the file fourier_resm-1.2.0.tar.gz.

File metadata

  • Download URL: fourier_resm-1.2.0.tar.gz
  • Upload date:
  • Size: 28.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for fourier_resm-1.2.0.tar.gz
Algorithm Hash digest
SHA256 9c60977a99a32cd400c764bbd454edd7deecb5c1f8a418ed9b9c5c36e4a665e7
MD5 112c9047c7b07e4a5ca2e954b3f4d82d
BLAKE2b-256 01125d62b945adfa8c48ee0b7874fc3e496a47598aacf601e6d1bd6074443630

See more details on using hashes here.

File details

Details for the file fourier_resm-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: fourier_resm-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 27.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for fourier_resm-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 970315fb1fefae2b80fdbeec5441f7de667ba933a503e4ccdccf9b66c1c8a45e
MD5 bb1cf5ea6fd1ade92326a7a89b08b11f
BLAKE2b-256 8a287507faf7f1f21d51d49f783d18d686864bcd28e397e8b61486f84a826121

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page