mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-21 18:41:03 +00:00
add proxmox_vm_count plugin (#1251)
Count the number of running virtual machines in a proxmox environment.
This commit is contained in:
parent
a68ed9a1de
commit
c1854c05aa
1 changed files with 91 additions and 0 deletions
91
plugins/proxmox/proxmox_vm_count
Normal file
91
plugins/proxmox/proxmox_vm_count
Normal file
|
@ -0,0 +1,91 @@
|
|||
#!/bin/bash
|
||||
#%# family=auto
|
||||
|
||||
: << EOF
|
||||
=head1 NAME
|
||||
proxmox_vm_count - Outputs the running, stopped and total counts of ProxMox VMs and LXCs.
|
||||
|
||||
=head1 CONFIGURATION
|
||||
This plugin needs to run as the root user in order to have permission to run lvs and vgs
|
||||
[proxmox_vm_count]
|
||||
[proxmox_count]
|
||||
user root
|
||||
group root
|
||||
|
||||
=head1 AUTHOR
|
||||
=over 4
|
||||
=item * Michael Grote
|
||||
=back
|
||||
|
||||
=head1 LICENSE
|
||||
Unknown license
|
||||
|
||||
=head1 MAGIC MARKERS
|
||||
=begin comment
|
||||
These magic markers are used by munin-node-configure when installing
|
||||
munin-node.
|
||||
=end comment
|
||||
#%# family=auto
|
||||
#%# capabilities=autoconf suggest
|
||||
=cut
|
||||
|
||||
EOF
|
||||
|
||||
|
||||
if [ "$1" = "autoconf" ]; then
|
||||
if ! command -v qm &> /dev/null; then
|
||||
echo "[ERROR] qm could not be found!"
|
||||
elif ! command -v pct &> /dev/null; then
|
||||
echo "[ERROR] pct could not be found!"
|
||||
else
|
||||
echo "yes"
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# hole Variablen nur einmal
|
||||
wqmlist=$(qm list)
|
||||
wpctlist=$(pct list)
|
||||
|
||||
# Berechne VMs
|
||||
total_vm=$(echo "$wqmlist" | sed 1d | wc -l)
|
||||
running_vm=$(echo "$wqmlist" | sed 1d | grep -c running)
|
||||
stopped_vm=$(echo "$wqmlist" | sed 1d | grep -c stopped)
|
||||
total_lxc=$(echo "$wpctlist" | sed 1d | wc -l)
|
||||
running_lxc=$(echo "$wpctlist" | sed 1d | grep -c running)
|
||||
stopped_lxc=$(echo "$wpctlist" | sed 1d | grep -c stopped)
|
||||
|
||||
# Berechne Gesamtwert
|
||||
total=$((total_vm + total_lxc))
|
||||
|
||||
if [ "$1" = "config" ]; then
|
||||
# setze label
|
||||
echo total_vm.label total Virtual Machines
|
||||
echo total.label total VMs and LXCs
|
||||
|
||||
echo running_vm.label running Virtual Machines
|
||||
echo running_lxc.label running LXCs
|
||||
|
||||
echo stopped_vm.label stopped Virtual Machines
|
||||
echo stopped_lxc.label stopped LXCs
|
||||
|
||||
echo total_lxc.label total 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.value "$total"
|
||||
|
||||
echo total_vm.value "$total_vm"
|
||||
echo total_lxc.value "$total_lxc"
|
||||
|
||||
echo running_vm.value "$running_vm"
|
||||
echo running_lxc.value "$running_lxc"
|
||||
|
||||
echo stopped_vm.value "$stopped_vm"
|
||||
echo stopped_lxc.value "$stopped_lxc"
|
||||
exit 0
|
Loading…
Add table
Add a link
Reference in a new issue