proxmox scripte zusammengefasst

This commit is contained in:
Michael Grote 2021-09-16 00:01:28 +02:00
parent f35527494a
commit c39b24153b
3 changed files with 56 additions and 80 deletions

56
proxmox_count Normal file
View file

@ -0,0 +1,56 @@
#!/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
# [kvm_vm_count]
# user root
# group root
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
total=$((total_vm + total_lxc))
# wenn parameter = ...
if [ "$1" = "autoconf" ]; then
echo yes
exit 0
fi
if [ "$1" = "config" ]; then
# setze label
echo total_vm.label total Virtual Machines
echo running_vm.label running Virtual Machines
echo stopped_vm.label stopped Virtual Machines
echo total_lxc.label total LXCs
echo running_lxc.label running LXCs
echo stopped_lxc.label stopped LXCs
echo total_total.label total VMs and LXCs
# 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
echo total_vm.value $total_vm
echo running_vm.value $running_vm
echo stopped_vm.value $stopped_vm
echo total_lxc.value $total_lxcs
echo running_lxc.value $running_lxcs
echo stopped_lxc.value $stopped_lxcs
echo total.value $total
exit 0

View file

@ -1,40 +0,0 @@
#!/bin/bash
#%# family=auto
#%# capabilities=autoconf
# Michael Grote
# michael.grote ät posteo.de
# Outputs the running, stopped and total counts of ProxMox LXCs.
# needs to be run as user: root AND group: root
# [kvm_vm_count]
# user root
# group root
wpct=$(which pct)
total=$($wpct list | sed 1d | wc -l)
running=$($wpct list | sed 1d | grep running | wc -l)
stopped=$($wpct list | sed 1d | grep stopped | wc -l)
# wenn parameter = ...
if [ "$1" = "autoconf" ]; then
echo yes
exit 0
fi
if [ "$1" = "config" ]; then
# setze label
echo total.label total
echo running.label running
echo stopped.label stopped
# setze optionen
echo 'graph_title Number of LXCs'
echo 'graph_vlabel Count'
echo 'graph_category virtualization'
echo 'graph_args -l 0'
exit 0
fi
echo total.value $total
echo running.value $running
echo stopped.value $stopped
exit 0

View file

@ -1,40 +0,0 @@
#!/bin/bash
#%# family=auto
#%# capabilities=autoconf
# Michael Grote
# michael.grote ät posteo.de
# Outputs the running, stopped and total counts of ProxMox VMs.
# needs to be run as user: root AND group: root
# [kvm_vm_count]
# user root
# group root
wqm=$(which qm)
total=$($wqm list | sed 1d | wc -l)
running=$($wqm list | sed 1d | grep running | wc -l)
stopped=$($wqm list | sed 1d | grep stopped | wc -l)
# wenn parameter = ...
if [ "$1" = "autoconf" ]; then
echo yes
exit 0
fi
if [ "$1" = "config" ]; then
# setze label
echo total.label total
echo running.label running
echo stopped.label stopped
# setze optionen
echo 'graph_title Number of VMs'
echo 'graph_vlabel Count'
echo 'graph_category virtualization'
echo 'graph_args -l 0'
exit 0
fi
echo total.value $total
echo running.value $running
echo stopped.value $stopped
exit 0