2021-09-16 00:01:28 +02:00
|
|
|
#!/bin/bash
|
|
|
|
#%# family=auto
|
|
|
|
#%# capabilities=autoconf
|
|
|
|
|
|
|
|
# Michael Grote
|
|
|
|
# michael.grote ät posteo.de
|
|
|
|
# Outputs the running, stopped and total counts of ProxMox VMs and LXCs.
|
|
|
|
# needs to be run as user: root AND group: root
|
2021-09-16 00:08:32 +02:00
|
|
|
# [proxmox_count]
|
2021-09-16 00:01:28 +02:00
|
|
|
# user root
|
|
|
|
# group root
|
|
|
|
|
2021-09-16 00:19:36 +02:00
|
|
|
# Pfade zu binaries
|
2021-09-16 00:01:28 +02:00
|
|
|
wqm=$(which qm)
|
|
|
|
wpct=$(which pct)
|
|
|
|
# Berechne VMs
|
|
|
|
total_vm=$($wqm list | sed 1d | wc -l)
|
|
|
|
running_vm=$($wqm list | sed 1d | grep running | wc -l)
|
|
|
|
stopped_vm=$($wqm list | sed 1d | grep stopped | wc -l)
|
|
|
|
# Berechne LXCs
|
|
|
|
total_lxc=$($wpct list | sed 1d | wc -l)
|
|
|
|
running_lxc=$($wpct list | sed 1d | grep running | wc -l)
|
|
|
|
stopped_lxc=$($wpct list | sed 1d | grep stopped | wc -l)
|
|
|
|
# Berechne Gesamtwert
|
2021-09-16 00:19:36 +02:00
|
|
|
total=$(($total_vm + $total_lxc))
|
2021-09-16 00:01:28 +02:00
|
|
|
|
|
|
|
# wenn parameter = ...
|
|
|
|
if [ "$1" = "autoconf" ]; then
|
|
|
|
echo yes
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$1" = "config" ]; then
|
|
|
|
# setze label
|
|
|
|
echo total_vm.label total Virtual Machines
|
2021-09-16 00:25:02 +02:00
|
|
|
echo total.label total VMs and LXCs
|
2021-09-16 00:15:28 +02:00
|
|
|
|
2021-09-16 00:01:28 +02:00
|
|
|
echo running_vm.label running Virtual Machines
|
|
|
|
echo running_lxc.label running LXCs
|
2021-09-16 00:15:28 +02:00
|
|
|
|
|
|
|
echo stopped_vm.label stopped Virtual Machines
|
2021-09-16 00:01:28 +02:00
|
|
|
echo stopped_lxc.label stopped LXCs
|
2021-09-16 00:15:28 +02:00
|
|
|
|
|
|
|
echo total_lxc.label total LXCs
|
|
|
|
|
2021-09-16 00:01:28 +02:00
|
|
|
# setze optionen
|
|
|
|
echo 'graph_title ProxMox - Number of VMs and LXCs'
|
|
|
|
echo 'graph_vlabel Count'
|
|
|
|
echo 'graph_category virtualization'
|
|
|
|
echo 'graph_args -l 0'
|
|
|
|
exit 0
|
|
|
|
fi
|
2021-09-16 00:28:01 +02:00
|
|
|
echo total.value $total
|
2021-09-16 00:01:28 +02:00
|
|
|
|
|
|
|
echo total_vm.value $total_vm
|
2021-09-16 00:13:34 +02:00
|
|
|
echo total_lxc.value $total_lxc
|
2021-09-16 00:28:01 +02:00
|
|
|
|
|
|
|
echo running_vm.value $running_vm
|
2021-09-16 00:13:34 +02:00
|
|
|
echo running_lxc.value $running_lxc
|
2021-09-16 00:28:01 +02:00
|
|
|
|
|
|
|
echo stopped_vm.value $stopped_vm
|
2021-09-16 00:13:34 +02:00
|
|
|
echo stopped_lxc.value $stopped_lxc
|
2021-09-16 00:01:28 +02:00
|
|
|
exit 0
|