Margrop
Articles243
Tags633
Categories6

Categories

1password 24GB VRAM 2K 3.6 Flash 30B dense 4-bit 量化 6-DoF SLAM AC ACP AI Agent AI Coding Assistant AI Tech AI tutor AI 安全 AI 应用 AI 日记 AI编程助手 ALTK-Evolve AMIE AP API API 定价 API 降价 ARC-AGI-3 ASR ATEM chat 模板 Agent Agent Harness Agent Memory Agent 入侵 Agent 工程 Agent 架构 Agent 检索 Agent 沙箱 Agent 系统 Agent 路由 Agentic AI Agentic tools Ai2 Alertmanager AllenAI Android 17 Antigravity AppDaemon AppWorld Aqara Astra Attention Baseten Benchmark CC-Switch CI/CD CLI Tools CLI工具 CPU 推理 Cache Hit Rate Caddy ChatGPT Claude Code Claude Sonnet ClawLoader Code Interpreter Codex ComfyUI Computer Use Cookie 认证 Cosmos-H-Dreams Cost Optimization Cron DFIR DSpark Date DeepSeek DeepSeek V4 Flash Diagrams.net Diary Diffusers Diffusion Docker Efficiency Tools Embedding English FSDP2 Fable 5 Fireworks AI FlashAttention FlashDreams GGUF GLM 5.2 GLM-5.2 GPT-4.1 GPT-5.6 GPT-Live GPT-Red GPU 加速 GPU 性能分析 Gateway Gemini Gemini 3.5 Flash Gemini API Gemini CLI Gemini Omni Flash Gemma 4 12B Gemma Translator Gemma4 GitHub Actions Google Google AI Google Research Google Sheets Grabette Gripette HA HADashboard HF Security Incident Hailuo Hermes Hexo HomeAssistant Hugging Face IBM Research Inference Providers Isaac Lab Java KV cache Kimi K3 Kubernetes LFM2.5 LFM2.5-VL LLM Router LVM‑Thin Late Interaction LeRobot Linux Liquid AI LiquidAI Live Translate LoRA Luna MCP MTP MacOS Magpie TTS Managed Agents Meta Microsoft 365 Copilot MiniMax Mistral Shieldstral Model Routing MuJoCo Warp Multi-Agent Multi-Vector Muse Glimmer MySQL NAS NIM NVIDIA NeMo Automodel Nemotron 3 Embed Newton Nginx Node.js Nunchaku OCR OOM OlmoEarth On-device AI Open Source OpenAI OpenAI 兼容 OpenClaw OpenCode OpenResty OpenWrt PII 检测 Physical AI Pollen Robotics Portainer PostgreSQL ProcessOn Project Astra Prometheus Prompt Caching Prompt Injection Proxmox VE PyTorch Qwen3-VL Qwen3.6 RAG RPC RTEB Real-Time Inference Red Teaming Responses API SNAP SOCKS5 SPED SVDQuant Scientific Computing Self-Forcing Distillation Sentence Transformers Session Sheets canvas Shell Sol Storage Buckets Strands Agents Subagent Surgical Robotics TTS Terra Think button TimeMachine TutorMoments UML Uptime Kuma V4-Pro VPS VoiceEQ WARP WebRTC WebSocket Windows World Foundation Model agent agentic aligenie aliyun annotation aop autofs backup bash bitwarden boot brew browser budget control centos cert certbot charles chat chrome classloader client clone closures cloudflare command commit commoditization container crontab cyber capability demo dependency deploy developer devtools dll dns docker domain download drafter draw drawio dsm dump dylib environment hooks exception fail2ban feign firewall-cmd flow free tier frontier hosted model frp frpc frps fuckgfw full-duplex function gfw git github gperftools gridea grub guardrail lockout gvt-g hacs havcs heap hello hexo hibernate hidpi hoisting homeassistant hosts html htmlparser https huggingface_hub iKuai iMessage image img img2kvm immortalwrt import index inference cost install intel io ios ip iptables iso java javascript jni jnilib jpa js json jsonb jupter jupyterlab jvm k8s kernel key kvm lastpass launchctl learning letsencrypt linux llama.cpp low-code lvm mac mariadb markdown maven md5 microcode mirror modules monitor mount mstsc multimodal mysql n5105 network nfs node node-red nodejs nohup notepad++ npm nssm ntp oop open weights openfeign openssl os ovz packet capture pdf pem perf pip plugin png powerbutton print pro productive struggle pve pvekclean python qcow2 qemu qemu-guest-agent rar reasoning control reasoning slider reboot reflog remote remote desktop renew repo resize retina router runtime safari sata scaffolding scheduled triggers scipy-notebook scoping scp self-play server serverless inference silent test simulated student so speculative decoding spk spring springboot springfox ssh ssl stash string support svg svn swagger sync synology systemctl systemd template terminal txt ubuntu ui undertow unlocker upgrade vLLM vhd vim vm vmdk web windows with worker xml yum zai-org/GLM-5.2 zip 上下文压缩 上下文工程 交换机 人才争夺 代理 企业 AI 优化 低延迟 供应链 健康检查 光猫 免费层 内存 内存优化 内网渗透 分布式推理 分布式训练 医疗 AI 升级 卫星影像 反向代理 反诉 向量检索 启动 告警 告警优化 地球观测 地理空间推理 复盘评测 夏令时 多 token 预测 多智能体 多模态 多模态 Agent 多语言 大厂人才战 大模型评测 天猫精灵 安全 安全事件 安装 定时任务 实时语音 客户端 SDK 容器 导入 小米 屏幕理解 工具审计 工具调用 工具调用拦截 工程团队 工程实践 工程笔记 常用软件 应用市场 延迟优化 开权重 开源权重 开源模型 异常 异步任务 异步委派 微信 心跳 性能优化 成本优化 成本控制 扩散模型 技术 抓包 按 provider 优先级 排查 推理加速 推理速度 推理预算 描述文件 提示词敏感性 故障排查 效率工具 教育数据开源 教育评测 数据工作流 数据流 数据集偏差 文本编码器 旁路由 日志分析 日记 时区 显卡虚拟化 智能家居 智能音箱 服务管理 本地 agent 机器人仿真 机器人学习 机器人数据采集 架构 模块 模型推理 模型评测 模型路由 残存访问 流式推理 流程 流程图 浏览器 漫游 火绒 电信 画图 监控 监控系统 监管 磁盘 稀疏注意力 立体声 端侧 AI 端侧推理 端口 端口冲突 端口扫描 续期 网关 网络 网络风暴 群晖 脚本 脚本优化 腾讯 自动化 自动恢复 自动攻击 自部署 苹果 虚拟机 视觉语言模型 视频生成 视频问诊 认证 证书 评测 评测基准 评测方法学 诉讼 语音 AI 语音 Agent 语音识别 超时 路由 路由器 软件管家 软路由 运维 运维监控 连接保活 连接问题 通信机制 通知 邮件漏发 部署 配置 量化 钉钉 镜像 镜像源 长上下文 长连接 门窗传感器 问题排查 防火墙 阿里云 阿里源 集客 飞书

Hitokoto

Archive

ProxmoxVE硬盘local-lvm监控、网线速率监控(Uptime Kuma)

ProxmoxVE硬盘local-lvm监控、网线速率监控(Uptime Kuma)

背景一

最近无论是公司系统,还是家庭服务器,均爆出多起因为硬盘满,导致服务不可用的状况

且并不是全部不可用,而是部份功能不可用,或者不稳定,开始排查问题的时候也并没考虑硬盘满。

于是防范于未然,一不做二不休,给 Uptime Kuma 添加硬盘使用率监控,避免出现同样问题

该需求过于小众,于是自定义并集成到已有监控系统,方便统一监控页面

背景二

最近也出现多起软路由/NAS出口变成百兆速率,导致内网文件传输只有10M/s的问题

同样也给 Uptime Kuma 添加千兆速率监控,避免出现同样问题

该需求过于小众,于是自定义并集成到已有监控系统,方便统一监控页面

local-lvm硬盘使用率监控

  • 监控规则:被动调用,Uptime Kuma 定时访问 PVE 服务器的 8080端口,若返回 ok 则正常

  • lvm_check.sh

    /root/TOOLS/lvm_http_server.py

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    #!/bin/bash

    # 设置使用量阈值
    THRESHOLD=90

    # 初始化JSON输出
    output='{"status": "ok", "volumes": []}'

    # 使用文件描述符重定向来避免子 Shell 问题
    while read -r lv vg usage lsize pool; do
    # 去除空格和百分号
    usage=$(echo $usage | tr -d ' ' | tr -d '%')

    # 只处理 pool 为 data 的逻辑卷
    if [ "$pool" != "data" ]; then
    continue
    fi

    # 如果usage为空,跳过此逻辑卷
    if [ -z "$usage" ]; then
    continue
    fi

    # 检查usage是否为数字
    if [[ "$usage" =~ ^[0-9]+(\.[0-9]+)?$ ]]; then
    # 使用bc进行比较,避免浮点数比较问题
    usage_value=$(echo "$usage > $THRESHOLD" | bc -l)
    if [ "$usage_value" -eq 1 ]; then
    # 如果超过阈值,改变状态并添加详细信息到JSON
    output=$(echo "$output" | jq '.status = "fail"')
    output=$(echo "$output" | jq --arg lv "$lv" --arg vg "$vg" --arg usage "$usage" --arg lsize "$lsize" '.volumes += [{"lv": $lv, "vg": $vg, "usage": $usage, "lsize": $lsize}]')
    fi
    else
    echo "Warning: Invalid usage value for LV $lv in VG $vg: $usage" >&2
    fi
    done < <(lvs --noheadings -o lv_name,vg_name,data_percent,lv_size,pool_lv --units g --nosuffix)

    # 输出结果
    echo "$output"
  • 搭建简易http服务器

    /root/TOOLS/lvm_http_server.py

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    from http.server import BaseHTTPRequestHandler, HTTPServer
    import subprocess

    class LVMCheckHandler(BaseHTTPRequestHandler):
    def do_GET(self):
    # 运行Shell脚本并获取输出
    result = subprocess.run(['/usr/local/bin/lvm_check.sh'], stdout=subprocess.PIPE)
    output = result.stdout.decode('utf-8')

    # 发送响应头
    self.send_response(200)
    self.send_header('Content-type', 'application/json')
    self.end_headers()

    # 发送脚本输出
    self.wfile.write(output.encode('utf-8'))

    # 启动HTTP服务器
    server_address = ('', 8080) # 监听端口8080
    httpd = HTTPServer(server_address, LVMCheckHandler)
    print('Running server...')
    httpd.serve_forever()
  • http服务器自动启动

    vim /etc/systemd/system/lvm_http.service

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    [Unit]
    Description=LVM Check HTTP Service
    After=network.target

    [Service]
    ExecStart=/usr/bin/python3 /root/TOOLS/lvm_http_server.py
    Restart=always
    User=root

    [Install]
    WantedBy=multi-user.target
  • 配置自动启动

    1
    2
    3
    systemctl daemon-reload
    systemctl start lvm_http
    systemctl enable lvm_http

网口速率是否为千兆速率(主动调用)

  • 监控规则:主动调用,PVE 服务器主动调用 Uptime Kuma 接口,Uptime Kuma在规定时间内必须接收到状态为up的接口调用

  • 检查网卡速率脚本

    /root/TOOLS/lan_speed_checker.sh

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    #!/bin/bash

    # 使用 ethtool 获取网卡速率信息
    INTERFACE="enp2s0"
    SPEED=$(ethtool $INTERFACE | grep "Speed:" | awk '{print $2}')

    # 判断当前速率是否符合期望值(例如1000Mb/s)
    if [[ "$SPEED" == "1000Mb/s" ]]; then
    # 如果速率正常,返回HTTP状态码 200
    curl -s -o /dev/null -w "%{http_code}" http://192.168.1.1:3001/api/push/Hj1InlrzWd?status=up
    else
    # 如果速率异常,返回HTTP状态码 500
    curl -s -o /dev/null -w "%{http_code}" http://192.168.1.1:3001/api/push/Hj1InlrzWd?status=down
    fi
  • 定时任务

    crontab -l

    1
    2
    3
    PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin

    * * * * * /root/TOOLS/lan_speed_checker.sh
本文阅读量 --
Author:Margrop
Link:https://blog.margrop.com/post/pve-add-monitor-for-lvm-usage-and-network-speed/
版权声明:本文采用 CC BY-NC-SA 3.0 CN 协议进行许可