顯示具有 pvesh 標籤的文章。 顯示所有文章
顯示具有 pvesh 標籤的文章。 顯示所有文章

2026/07/02

最近發現monitor pve guest 並重啟的程式沒作用

看文件才發現pvesh的指令有變

原來是

pvesh create /nodes/pve195/147/status/stop

改為

pvesh create /nodes/pve195/lxc/147/status/stop


現在要把guest type 加上去

所以程式要進行修正

2026/06/10

之前不久才改的檢查程式
欄位又變了
想說一直改很煩
這次改成取json的資料

pvesh get /cluster/resources --type vm --output-format json|jq -r '.[] | " \(.node) \(.vm
id) \(.name) \((.cpu * 100 | floor))"' > /tmp/all_guest_cpu

應該不會再變了吧

2025/11/21

升到pve9後

pvesh get /cluster/resources 的欄位有變

修正如下

pvesh get /cluster/resources|awk '{print $46" "$2" "$36" "$8}'|grep -E "lxc|qemu"|sed 's/....$//' > /tmp/all_guest_cpu


原來是

pvesh get /cluster/resources|awk '{print $41" "$2" "$33" "$8}'|grep -E "lxc|qemu"|sed 's/....$//' > /tmp/all_guest_cpu


主要是要拿 host name,guest id,guest name,guest cpu

2025/01/10

在PVE中撈出所有guest的 cpu使用率並在超過上限值時發出告警


#!/bin/bash

pvesh get /cluster/resources|awk '{print $2" "$33" "$8}'|grep -E "lxc|qemu"|sed 's/....$//' > /tmp/all_guest_cpu

cat /tmp/all_guest_cpu | awk  '$3 > 80 {print $0}' > /tmp/guest_cpu_high

if [ -s /tmp/guest_cpu_high ]; then

        sed -i '1i network guest cpu high' /tmp/guest_cpu_high
        sed -i '2i ==========' /tmp/guest_cpu_high
        cp /tmp/guest_cpu_high /tmp/guest_cpu_high_network
        /usr/bin/lftp ftp://user:pwd@10.0.0.1 -e "put /tmp/guest_cpu_high_network; bye"
        mutt -s guest_cpu_high user@abc.com < /tmp/guest_cpu_high

fi

2023/12/08

自從pmg升到8版後
偶爾就會出現cpu跟ram過高的問題
然後机器就會卡住無法運作




之前本來已經有寫了一支檢查程式跑在mg裡
如果收不到外面連線的log
就重啟
可是今天的狀況更嚴重
當几後mg沒法執行任何程式了
只能從 host著手
定時檢查 mg的cpu狀態
如果有問題
就從host下指令重開了
163是lxc id


#!/bin/bash

k=`/usr/bin/pvesh get /cluster/resources|grep 163|cut -d '%' -f 1|awk '{print $NF}'|cut -d '.' -f 1`

#echo $k
if [ $k -gt 96 ]; then

        echo "cpu $k mg reboot"|/usr/bin/mail -s mg_cpu_high_reboot a@bc.de
        /usr/sbin/pct stop 163
        sleep 5
        /usr/sbin/pct start 163

fi

2022/07/29

pvesh

跨 proxmox node 下指令的好用工具

如果要把其他節點的guest開几 指令如下

pvesh create /nodes/<nodeid>/qemu/<vmid>/status/start


https://pve.proxmox.com/pve-docs/pvesh.1.html

http://blog.jason.tools/2019/02/pve-cli-api.html