Enhance PVE scripts and conf

tags/zabbix-agent-addons-0.2.35-1
Daniel Berteaud 7 years ago
parent 29fe3a445d
commit a9bc0f7f54
  1. 4
      zabbix_conf/pve.conf
  2. 17
      zabbix_scripts/check_pve_sudo

@ -1,10 +1,10 @@
# Discover PVE items # Discover PVE items
# $1 can be nodes, guests, storage or pools # $1 can be nodes, guests, storage or pools
UserParameter=pve.discovery[*],/usr/bin/sudo /var/lib/zabbix/bin/disco_pve_sudo --what=$1 UserParameter=pve.discovery[*],/usr/bin/sudo /var/lib/zabbix/bin/disco_pve_sudo --what $1
# Type: Agent or Agent (active) # Type: Agent or Agent (active)
# pve.check.all[type,id] # pve.check.all[type,id]
# Where type is what to monitor (pool, storage, node, cluster, guest) # Where type is what to monitor (pool, storage, node, cluster, guest)
# id is the id of the item to monitor. For a guest, it's his numerical ID, for a storage # id is the id of the item to monitor. For a guest, it's his numerical ID, for a storage
# a node or a pool, its name. For the cluster, there's no ID # a node or a pool, its name. For the cluster, there's no ID
UserParameter=pve.check.all[*],/usr/bin/sudo /var/lib/zabbix/bin/check_pve_sudo --$1=$2 UserParameter=pve.check.all[*],/usr/bin/sudo /var/lib/zabbix/bin/check_pve_sudo --$1 $2

@ -37,7 +37,7 @@ if ($cluster){
my $guests = from_json(qx($pvesh get /cluster/resources --type=vm 2>/dev/null)); my $guests = from_json(qx($pvesh get /cluster/resources --type=vm 2>/dev/null));
foreach my $g (@{$guests}){ foreach my $g (@{$guests}){
if ($g->{vmid} eq $guest){ if ($g->{vmid} eq $guest){
$json = from_json(qx($pvesh get /nodes/$g->{node}/$g->{type}/$guest/status/current 2>/dev/null)); $json = $g;
last; last;
} }
} }
@ -57,6 +57,21 @@ if ($cluster){
$json->{templates}->{$item->{type}}++; $json->{templates}->{$item->{type}}++;
} }
} }
$json->{guests}->{$_} //= 0 foreach (qw(cpu maxcpu diskread diskwrite maxdisk mem maxmem netin netout));
$json->{templates}->{$_} //= 0 foreach (qw(maxdisk));
} elsif ($storage){
$json = from_json(qx($pvesh get /storage/$storage 2>/dev/null));
my $stores = from_json(qx($pvesh get /cluster/resources --type=storage 2>/dev/null));
foreach my $s (@{$stores}){
if ($s->{storage} eq $storage){
$json->{maxdisk} = $s->{maxdisk};
$json->{disk} = $s->{disk};
last;
}
}
} else{
print 'ZBX_UNSUPORTED';
exit 0;
} }
print to_json($json, { pretty => $pretty }) . "\n"; print to_json($json, { pretty => $pretty }) . "\n";

Loading…
Cancel
Save