D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
lib64
/
nagios
/
plugins
/
Filename :
check_vm_status.sh
back
Copy
#!/bin/bash OK=0 WARNING=1 CRITICAL=2 UNKNOWN=3 VMS=$(pvesh get nodes/$(hostname -s)/qemu --output-format json |jq -r '.[]|select(.uptime != 0)|select(.template != 1)|select(.tags | contains("suspended") or contains("cancelled") or contains("delete") or contains("fraud")) | .name' | paste -sd ',' 2>/dev/null) if [ $? -ne 0 ]; then echo "Failed to execute pvesh command" exit $UNKNOWN fi if [ -n "$VMS" ]; then echo "Found running VMs with suspended/cancelled/delete/fraud tags: $VMS" #exit $CRITICAL exit $WARNING else echo "No running VMs found with suspended/cancelled/delete/fraud tags" exit $OK fi