Add global net and disk stats for the cluster in check_pve_sudo

tags/zabbix-agent-addons-0.2.38-1
Daniel Berteaud 7 years ago
parent 334a5f1a46
commit 8b457ecc69
  1. 17
      zabbix_scripts/check_pve_sudo

@ -31,6 +31,15 @@ if ($cluster){
name => 'default',
version => 1
};
# Set default global stats
$json->{network} = {
in => 0,
out => 0
};
$json->{disk} = {
read => 0,
write => 0
};
my @nodes = ();
foreach my $item (@{$cluster}){
if ($item->{type} eq 'cluster'){
@ -52,6 +61,14 @@ if ($cluster){
}
# We want average load avg of the cluster, not the sum of individual loads
$json->{loadavg}[$_] = sprintf "%.2f", $json->{loadavg}[$_] / $json->{status}->{nodes} foreach (0..2);
my $guests = from_json(qx($pvesh get /cluster/resources --type=vm 2>/dev/null));
foreach my $guest (@{$guests}){
$json->{network}->{in} += $guest->{netin};
$json->{network}->{out} += $guest->{netout};
$json->{disk}->{read} += $guest->{diskread};
$json->{disk}->{write} += $guest->{diskwrite};
}
} elsif ($node){
foreach my $item (qw(status version subscription)){
$json->{$item} = from_json(qx(pvesh get /nodes/$node/$item 2>/dev/null));

Loading…
Cancel
Save