usr/lib/observium_agent/scripts-available/proxmox-qemu aktualisiert
Ergänzung um OS aus den vm-Konfigfiles zu lesen und diese Info ins JSON einzubringen
This commit is contained in:
@@ -11,8 +11,28 @@ then
|
|||||||
VERSION=$(pveversion | awk -F/ '{print $2}' | sed 's/\..*//')
|
VERSION=$(pveversion | awk -F/ '{print $2}' | sed 's/\..*//')
|
||||||
if [[ ${VERSION} -ge 5 ]]
|
if [[ ${VERSION} -ge 5 ]]
|
||||||
then
|
then
|
||||||
pvesh get /nodes/$(hostname)/qemu --output-format=json-pretty 2>/dev/null
|
JSON=`pvesh get /nodes/$(hostname)/qemu --output-format=json-pretty 2>/dev/null`
|
||||||
else
|
else
|
||||||
pvesh get /nodes/$(hostname)/qemu 2>/dev/null
|
pvesh get /nodes/$(hostname)/qemu 2>/dev/null
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
count=`echo $JSON | jq '. | length' `
|
||||||
|
|
||||||
|
for ((i=0; i<$count; i++)); do
|
||||||
|
name=`echo $JSON | jq -r '.['$i'].name'`
|
||||||
|
vmid=`echo $JSON | jq -r '.['$i'].vmid'`
|
||||||
|
ostype=`cat /etc/pve/qemu-server/${vmid}.conf | grep ostype | awk '{print $2}'`
|
||||||
|
if [ "$i" == "0" ]
|
||||||
|
then
|
||||||
|
CMD=".[$i] += {\"os\":\"$ostype\"}"
|
||||||
|
else
|
||||||
|
CMD=$CMD" | .[$i] += {\"os\":\"$ostype\"}"
|
||||||
|
fi
|
||||||
|
#echo "$name is $vmid"
|
||||||
|
done
|
||||||
|
|
||||||
|
jqcmd=(jq "$CMD")
|
||||||
|
|
||||||
|
#echo run it now
|
||||||
|
echo "$JSON" | "${jqcmd[@]}"
|
||||||
|
|||||||
Reference in New Issue
Block a user