add new perfdata for vmware connector

This commit is contained in:
garnier-quentin 2019-04-16 14:19:35 +02:00
parent 9b36cd1aaf
commit 7413ce93b2
27 changed files with 215 additions and 144 deletions

View File

@ -86,15 +86,19 @@ sub custom_status_calc {
sub custom_dcmetrics_perfdata { sub custom_dcmetrics_perfdata {
my ($self, %options) = @_; my ($self, %options) = @_;
my $extra_label = ''; my $extra_label;
# We do it manually. Because we have only 1 instance in group. # We do it manually. Because we have only 1 instance in group.
if (scalar(keys %{$self->{instance_mode}->{datacenter}}) > 1) { if (scalar(keys %{$self->{instance_mode}->{datacenter}}) > 1 || $self->{output}->use_new_perfdata()) {
$extra_label .= '_' . $self->{result_values}->{name}; $extra_label = $self->{result_values}->{name};
} }
$self->{output}->perfdata_add(label => 'alarm_' . $self->{result_values}->{label_ref} . $extra_label, $self->{output}->perfdata_add(
value => $self->{result_values}->{alarm_value}, label => 'alarm_' . $self->{result_values}->{label_ref},
min => 0); nlabel => 'datacenter.alarms.' . $self->{result_values}->{label_ref} . '.current.count',
instances => $extra_label,
value => $self->{result_values}->{alarm_value},
min => 0
);
} }
sub custom_dcmetrics_calc { sub custom_dcmetrics_calc {
@ -120,7 +124,7 @@ sub set_counters {
]; ];
$self->{maps_counters}->{global} = [ $self->{maps_counters}->{global} = [
{ label => 'total-alarm-warning', set => { { label => 'total-alarm-warning', nlabel => 'datacenter.alarms.warning.current.count', set => {
key_values => [ { name => 'yellow' } ], key_values => [ { name => 'yellow' } ],
output_template => '%s warning alarm(s) found(s)', output_template => '%s warning alarm(s) found(s)',
perfdatas => [ perfdatas => [
@ -128,7 +132,7 @@ sub set_counters {
], ],
} }
}, },
{ label => 'total-alarm-critical', set => { { label => 'total-alarm-critical', nlabel => 'datacenter.alarms.critical.current.count', set => {
key_values => [ { name => 'red' } ], key_values => [ { name => 'red' } ],
output_template => '%s critical alarm(s) found(s)', output_template => '%s critical alarm(s) found(s)',
perfdatas => [ perfdatas => [

View File

@ -40,11 +40,11 @@ sub catalog_status_threshold {
$label =~ s/-/_/g; $label =~ s/-/_/g;
if (defined($self->{instance_mode}->{option_results}->{'critical_' . $label}) && $self->{instance_mode}->{option_results}->{'critical_' . $label} ne '' && if (defined($self->{instance_mode}->{option_results}->{'critical_' . $label}) && $self->{instance_mode}->{option_results}->{'critical_' . $label} ne '' &&
eval "$self->{instance_mode}->{option_results}->{'critical_' . $label}") { eval "$self->{instance_mode}->{option_results}->{'critical_' . $label}") {
$self->{instance_mode}->{dc_critical}++; $self->{instance_mode}->{host_critical}++;
$status = 'critical'; $status = 'critical';
} elsif (defined($self->{instance_mode}->{option_results}->{'warning_' . $label}) && $self->{instance_mode}->{option_results}->{'warning_' . $label} ne '' && } elsif (defined($self->{instance_mode}->{option_results}->{'warning_' . $label}) && $self->{instance_mode}->{option_results}->{'warning_' . $label} ne '' &&
eval "$self->{instance_mode}->{option_results}->{'warning_' . $label}") { eval "$self->{instance_mode}->{option_results}->{'warning_' . $label}") {
$self->{instance_mode}->{dc_warning}++; $self->{instance_mode}->{host_warning}++;
$status = 'warning'; $status = 'warning';
} }
}; };
@ -86,21 +86,25 @@ sub custom_status_calc {
sub custom_esxhost_perfdata { sub custom_esxhost_perfdata {
my ($self, %options) = @_; my ($self, %options) = @_;
my $extra_label = ''; my $extra_label;
# We do it manually. Because we have only 1 instance in group. # We do it manually. Because we have only 1 instance in group.
if (scalar(keys %{$self->{instance_mode}->{esxhost}}) > 1) { if (scalar(keys %{$self->{instance_mode}->{esxhost}}) > 1 || $self->{output}->use_new_perfdata()) {
$extra_label .= '_' . $self->{result_values}->{name}; $extra_label = $self->{result_values}->{name};
} }
$self->{output}->perfdata_add(label => 'alarm_' . $self->{result_values}->{label_ref} . $extra_label, $self->{output}->perfdata_add(
value => $self->{result_values}->{alarm_value}, label => 'alarm_' . $self->{result_values}->{label_ref},
min => 0); nlabel => 'host.alarms.' . $self->{result_values}->{label_ref} . '.current.count',
instances => $extra_label,
value => $self->{result_values}->{alarm_value},
min => 0
);
} }
sub custom_esxhost_calc { sub custom_esxhost_calc {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->{result_values}->{label_ref} = $options{extra_options}->{label_ref}; $self->{result_values}->{label_ref} = $options{extra_options}->{label_ref};
$self->{result_values}->{alarm_value} = $self->{instance_mode}->{'dc_' . $options{extra_options}->{label_ref}}; $self->{result_values}->{alarm_value} = $self->{instance_mode}->{'host_' . $options{extra_options}->{label_ref}};
$self->{result_values}->{name} = $options{new_datas}->{$self->{instance} . '_name'}; $self->{result_values}->{name} = $options{new_datas}->{$self->{instance} . '_name'};
return 0; return 0;
} }
@ -119,7 +123,7 @@ sub set_counters {
]; ];
$self->{maps_counters}->{global} = [ $self->{maps_counters}->{global} = [
{ label => 'total-alarm-warning', set => { { label => 'total-alarm-warning', nlabel => 'host.alarms.warning.current.count', set => {
key_values => [ { name => 'yellow' } ], key_values => [ { name => 'yellow' } ],
output_template => '%s warning alarm(s) found(s)', output_template => '%s warning alarm(s) found(s)',
perfdatas => [ perfdatas => [
@ -127,7 +131,7 @@ sub set_counters {
], ],
} }
}, },
{ label => 'total-alarm-critical', set => { { label => 'total-alarm-critical', nlabel => 'host.alarms.critical.current.count', set => {
key_values => [ { name => 'red' } ], key_values => [ { name => 'red' } ],
output_template => '%s critical alarm(s) found(s)', output_template => '%s critical alarm(s) found(s)',
perfdatas => [ perfdatas => [
@ -153,6 +157,7 @@ sub set_counters {
{ label => 'alarm-warning', threshold => 0, set => { { label => 'alarm-warning', threshold => 0, set => {
key_values => [ { name => 'name' } ], key_values => [ { name => 'name' } ],
output_template => '', output_template => '',
closure_custom_threshold_check => sub { return 'ok' },
closure_custom_calc => $self->can('custom_esxhost_calc'), closure_custom_calc_extra_options => { label_ref => 'warning' }, closure_custom_calc => $self->can('custom_esxhost_calc'), closure_custom_calc_extra_options => { label_ref => 'warning' },
closure_custom_perfdata => $self->can('custom_esxhost_perfdata'), closure_custom_perfdata => $self->can('custom_esxhost_perfdata'),
} }
@ -160,6 +165,7 @@ sub set_counters {
{ label => 'alarm-critical', threshold => 0, set => { { label => 'alarm-critical', threshold => 0, set => {
key_values => [ { name => 'name' } ], key_values => [ { name => 'name' } ],
output_template => '', output_template => '',
closure_custom_threshold_check => sub { return 'ok' },
closure_custom_calc => $self->can('custom_esxhost_calc'), closure_custom_calc_extra_options => { label_ref => 'critical' }, closure_custom_calc => $self->can('custom_esxhost_calc'), closure_custom_calc_extra_options => { label_ref => 'critical' },
closure_custom_perfdata => $self->can('custom_esxhost_perfdata'), closure_custom_perfdata => $self->can('custom_esxhost_perfdata'),
} }
@ -176,8 +182,8 @@ sub prefix_esxhost_output {
sub alarm_reset { sub alarm_reset {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->{dc_warning} = 0; $self->{host_warning} = 0;
$self->{dc_critical} = 0; $self->{host_critical} = 0;
} }
sub esxhost_long_output { sub esxhost_long_output {

View File

@ -49,7 +49,7 @@ sub set_counters {
]; ];
$self->{maps_counters}->{global} = [ $self->{maps_counters}->{global} = [
{ label => 'total-on', set => { { label => 'total-on', nlabel => 'host.vm.poweredon.current.count', set => {
key_values => [ { name => 'poweredon' }, { name => 'total' } ], key_values => [ { name => 'poweredon' }, { name => 'total' } ],
output_template => '%s VM(s) poweredon', output_template => '%s VM(s) poweredon',
perfdatas => [ perfdatas => [
@ -58,7 +58,7 @@ sub set_counters {
], ],
} }
}, },
{ label => 'total-off', set => { { label => 'total-off', nlabel => 'host.vm.poweredoff.current.count', set => {
key_values => [ { name => 'poweredoff' }, { name => 'total' } ], key_values => [ { name => 'poweredoff' }, { name => 'total' } ],
output_template => '%s VM(s) poweredoff', output_template => '%s VM(s) poweredoff',
perfdatas => [ perfdatas => [
@ -67,7 +67,7 @@ sub set_counters {
], ],
} }
}, },
{ label => 'total-suspended', set => { { label => 'total-suspended', nlabel => 'host.vm.suspended.current.count', set => {
key_values => [ { name => 'suspended' }, { name => 'total' } ], key_values => [ { name => 'suspended' }, { name => 'total' } ],
output_template => '%s VM(s) suspended', output_template => '%s VM(s) suspended',
perfdatas => [ perfdatas => [
@ -87,7 +87,7 @@ sub set_counters {
closure_custom_threshold_check => \&catalog_status_threshold, closure_custom_threshold_check => \&catalog_status_threshold,
} }
}, },
{ label => 'on', set => { { label => 'on', nlabel => 'host.vm.poweredon.current.count', set => {
key_values => [ { name => 'poweredon' }, { name => 'total' } ], key_values => [ { name => 'poweredon' }, { name => 'total' } ],
output_template => '%s VM(s) poweredon', output_template => '%s VM(s) poweredon',
perfdatas => [ perfdatas => [
@ -96,7 +96,7 @@ sub set_counters {
], ],
} }
}, },
{ label => 'off', set => { { label => 'off', nlabel => 'host.vm.poweredoff.current.count', set => {
key_values => [ { name => 'poweredoff' }, { name => 'total' } ], key_values => [ { name => 'poweredoff' }, { name => 'total' } ],
output_template => '%s VM(s) poweredoff', output_template => '%s VM(s) poweredoff',
perfdatas => [ perfdatas => [
@ -105,7 +105,7 @@ sub set_counters {
], ],
} }
}, },
{ label => 'suspended', set => { { label => 'suspended', nlabel => 'host.vm.suspended.current.count', set => {
key_values => [ { name => 'suspended' }, { name => 'total' } ], key_values => [ { name => 'suspended' }, { name => 'total' } ],
output_template => '%s VM(s) suspended', output_template => '%s VM(s) suspended',
perfdatas => [ perfdatas => [

View File

@ -65,7 +65,7 @@ sub set_counters {
]; ];
$self->{maps_counters}->{global_cpu} = [ $self->{maps_counters}->{global_cpu} = [
{ label => 'total-cpu', set => { { label => 'total-cpu', nlabel => 'host.cpu.utilization.percentage', set => {
key_values => [ { name => 'cpu_average' } ], key_values => [ { name => 'cpu_average' } ],
output_template => '%s %%', output_template => '%s %%',
perfdatas => [ perfdatas => [
@ -74,7 +74,7 @@ sub set_counters {
], ],
} }
}, },
{ label => 'total-cpu-mhz', set => { { label => 'total-cpu-mhz', nlabel => 'host.cpu.utilization.mhz', set => {
key_values => [ { name => 'cpu_average_mhz' }, { name => 'cpu_average_mhz_max' } ], key_values => [ { name => 'cpu_average_mhz' }, { name => 'cpu_average_mhz_max' } ],
output_template => '%s MHz', output_template => '%s MHz',
perfdatas => [ perfdatas => [
@ -86,7 +86,7 @@ sub set_counters {
]; ];
$self->{maps_counters}->{cpu} = [ $self->{maps_counters}->{cpu} = [
{ label => 'cpu', set => { { label => 'cpu', nlabel => 'host.core.cpu.utilization.percentage', set => {
key_values => [ { name => 'cpu_usage' }, { name => 'display' } ], key_values => [ { name => 'cpu_usage' }, { name => 'display' } ],
output_template => 'usage : %s', output_template => 'usage : %s',
perfdatas => [ perfdatas => [

View File

@ -49,7 +49,7 @@ sub set_counters {
group => [ group => [
{ name => 'global', type => 0, skipped_code => { -10 => 1 } }, { name => 'global', type => 0, skipped_code => { -10 => 1 } },
{ name => 'global_cpu', cb_prefix_output => 'prefix_global_cpu_output', type => 0, skipped_code => { -10 => 1 } }, { name => 'global_cpu', cb_prefix_output => 'prefix_global_cpu_output', type => 0, skipped_code => { -10 => 1 } },
{ name => 'cpu', display_long => 0, cb_prefix_output => 'prefix_cpu_output', message_multiple => 'All CPUs are ok', type => 1, skipped_code => { -10 => 1 } }, { name => 'cpu', display_long => 0, cb_prefix_output => 'prefix_cpu_output', message_multiple => 'All CPUs are ok', type => 1, skipped_code => { -10 => 1 } },
] ]
} }
]; ];
@ -66,7 +66,7 @@ sub set_counters {
]; ];
$self->{maps_counters}->{global_cpu} = [ $self->{maps_counters}->{global_cpu} = [
{ label => 'total-cpu', set => { { label => 'total-cpu', nlabel => 'vm.cpu.utilization.percentage', set => {
key_values => [ { name => 'cpu_average' } ], key_values => [ { name => 'cpu_average' } ],
output_template => '%s %%', output_template => '%s %%',
perfdatas => [ perfdatas => [
@ -75,7 +75,7 @@ sub set_counters {
], ],
} }
}, },
{ label => 'total-cpu-mhz', set => { { label => 'total-cpu-mhz', nlabel => 'vm.cpu.utilization.mhz', set => {
key_values => [ { name => 'cpu_average_mhz' } ], key_values => [ { name => 'cpu_average_mhz' } ],
output_template => '%s MHz', output_template => '%s MHz',
perfdatas => [ perfdatas => [
@ -84,7 +84,7 @@ sub set_counters {
], ],
} }
}, },
{ label => 'cpu-ready', set => { { label => 'cpu-ready', nlabel => 'vm.cpu.ready.percentage', set => {
key_values => [ { name => 'cpu_ready' } ], key_values => [ { name => 'cpu_ready' } ],
output_template => 'ready %s %%', output_template => 'ready %s %%',
perfdatas => [ perfdatas => [
@ -96,7 +96,7 @@ sub set_counters {
]; ];
$self->{maps_counters}->{cpu} = [ $self->{maps_counters}->{cpu} = [
{ label => 'cpu', set => { { label => 'cpu', nlabel => 'vm.core.cpu.utilization.percentage', set => {
key_values => [ { name => 'cpu_usage' }, { name => 'display' } ], key_values => [ { name => 'cpu_usage' }, { name => 'display' } ],
output_template => 'usage : %s MHz', output_template => 'usage : %s MHz',
perfdatas => [ perfdatas => [

View File

@ -50,7 +50,7 @@ sub set_counters {
]; ];
$self->{maps_counters}->{global} = [ $self->{maps_counters}->{global} = [
{ label => 'total-on', set => { { label => 'total-on', nlabel => 'datastore.vm.poweredon.current.count', set => {
key_values => [ { name => 'poweredon' }, { name => 'total' } ], key_values => [ { name => 'poweredon' }, { name => 'total' } ],
output_template => '%s VM(s) poweredon', output_template => '%s VM(s) poweredon',
perfdatas => [ perfdatas => [
@ -59,7 +59,7 @@ sub set_counters {
], ],
} }
}, },
{ label => 'total-off', set => { { label => 'total-off', nlabel => 'datastore.vm.poweredoff.current.count', set => {
key_values => [ { name => 'poweredoff' }, { name => 'total' } ], key_values => [ { name => 'poweredoff' }, { name => 'total' } ],
output_template => '%s VM(s) poweredoff', output_template => '%s VM(s) poweredoff',
perfdatas => [ perfdatas => [
@ -68,7 +68,7 @@ sub set_counters {
], ],
} }
}, },
{ label => 'total-suspended', set => { { label => 'total-suspended', nlabel => 'datastore.vm.suspended.current.count', set => {
key_values => [ { name => 'suspended' }, { name => 'total' } ], key_values => [ { name => 'suspended' }, { name => 'total' } ],
output_template => '%s VM(s) suspended', output_template => '%s VM(s) suspended',
perfdatas => [ perfdatas => [
@ -88,7 +88,7 @@ sub set_counters {
closure_custom_threshold_check => \&catalog_status_threshold, closure_custom_threshold_check => \&catalog_status_threshold,
} }
}, },
{ label => 'on', set => { { label => 'on', nlabel => 'datastore.vm.poweredon.current.count', set => {
key_values => [ { name => 'poweredon' }, { name => 'total' } ], key_values => [ { name => 'poweredon' }, { name => 'total' } ],
output_template => '%s VM(s) poweredon', output_template => '%s VM(s) poweredon',
perfdatas => [ perfdatas => [
@ -97,7 +97,7 @@ sub set_counters {
], ],
} }
}, },
{ label => 'off', set => { { label => 'off', nlabel => 'datastore.vm.poweredoff.current.count', set => {
key_values => [ { name => 'poweredoff' }, { name => 'total' } ], key_values => [ { name => 'poweredoff' }, { name => 'total' } ],
output_template => '%s VM(s) poweredoff', output_template => '%s VM(s) poweredoff',
perfdatas => [ perfdatas => [
@ -106,7 +106,7 @@ sub set_counters {
], ],
} }
}, },
{ label => 'suspended', set => { { label => 'suspended', nlabel => 'datastore.vm.suspended.current.count', set => {
key_values => [ { name => 'suspended' }, { name => 'total' } ], key_values => [ { name => 'suspended' }, { name => 'total' } ],
output_template => '%s VM(s) suspended', output_template => '%s VM(s) suspended',
perfdatas => [ perfdatas => [

View File

@ -65,7 +65,7 @@ sub set_counters {
]; ];
$self->{maps_counters}->{datastore} = [ $self->{maps_counters}->{datastore} = [
{ label => 'read-latency', set => { { label => 'read-latency', nlabel => 'host.datastore.latency.read.milliseconds', set => {
key_values => [ { name => 'read_latency' }, { name => 'display' } ], key_values => [ { name => 'read_latency' }, { name => 'display' } ],
output_template => 'read : %s ms', output_template => 'read : %s ms',
perfdatas => [ perfdatas => [
@ -74,7 +74,7 @@ sub set_counters {
], ],
} }
}, },
{ label => 'write-latency', set => { { label => 'write-latency', nlabel => 'host.datastore.latency.write.milliseconds', set => {
key_values => [ { name => 'write_latency' }, { name => 'display' } ], key_values => [ { name => 'write_latency' }, { name => 'display' } ],
output_template => 'write : %s ms', output_template => 'write : %s ms',
perfdatas => [ perfdatas => [

View File

@ -49,7 +49,7 @@ sub set_counters {
]; ];
$self->{maps_counters}->{global} = [ $self->{maps_counters}->{global} = [
{ label => 'total-read', set => { { label => 'total-read', nlabel => 'datastore.read.usage.bytesperseconds', set => {
key_values => [ { name => 'read' } ], key_values => [ { name => 'read' } ],
output_template => 'Total rate of reading data: %s %s/s', output_template => 'Total rate of reading data: %s %s/s',
output_change_bytes => 1, output_change_bytes => 1,
@ -59,7 +59,7 @@ sub set_counters {
], ],
} }
}, },
{ label => 'total-write', set => { { label => 'total-write', nlabel => 'datastore.write.usage.bytesperseconds', set => {
key_values => [ { name => 'write' } ], key_values => [ { name => 'write' } ],
output_template => 'Total rate of writing data: %s %s/s', output_template => 'Total rate of writing data: %s %s/s',
output_change_bytes => 1, output_change_bytes => 1,
@ -80,7 +80,7 @@ sub set_counters {
closure_custom_threshold_check => \&catalog_status_threshold, closure_custom_threshold_check => \&catalog_status_threshold,
} }
}, },
{ label => 'read', set => { { label => 'read', nlabel => 'datastore.read.usage.bytesperseconds', set => {
key_values => [ { name => 'read' } ], key_values => [ { name => 'read' } ],
output_template => 'rate of reading data: %s %s/s', output_template => 'rate of reading data: %s %s/s',
output_change_bytes => 1, output_change_bytes => 1,
@ -90,7 +90,7 @@ sub set_counters {
], ],
} }
}, },
{ label => 'write', set => { { label => 'write', nlabel => 'datastore.write.usage.bytesperseconds', set => {
key_values => [ { name => 'write' } ], key_values => [ { name => 'write' } ],
output_template => 'rate of writing data: %s %s/s', output_template => 'rate of writing data: %s %s/s',
output_change_bytes => 1, output_change_bytes => 1,

View File

@ -66,7 +66,7 @@ sub set_counters {
]; ];
$self->{maps_counters}->{global_iops} = [ $self->{maps_counters}->{global_iops} = [
{ label => 'read', set => { { label => 'read', nlabel => 'datastore.read.usage.iops', set => {
key_values => [ { name => 'read' } ], key_values => [ { name => 'read' } ],
output_template => '%s read iops', output_template => '%s read iops',
perfdatas => [ perfdatas => [
@ -75,7 +75,7 @@ sub set_counters {
], ],
} }
}, },
{ label => 'write', set => { { label => 'write', nlabel => 'datastore.write.usage.iops', set => {
key_values => [ { name => 'write' } ], key_values => [ { name => 'write' } ],
output_template => '%s write iops', output_template => '%s write iops',
perfdatas => [ perfdatas => [
@ -87,7 +87,7 @@ sub set_counters {
]; ];
$self->{maps_counters}->{vm} = [ $self->{maps_counters}->{vm} = [
{ label => 'read-vm', set => { { label => 'read-vm', nlabel => 'datastore.vm.read.usage.iops', set => {
key_values => [ { name => 'read' } ], key_values => [ { name => 'read' } ],
output_template => '%s read iops', output_template => '%s read iops',
perfdatas => [ perfdatas => [
@ -96,7 +96,7 @@ sub set_counters {
], ],
} }
}, },
{ label => 'write-vm', set => { { label => 'write-vm', nlabel => 'datastore.vm.write.usage.iops', set => {
key_values => [ { name => 'write' } ], key_values => [ { name => 'write' } ],
output_template => '%s write iops', output_template => '%s write iops',
perfdatas => [ perfdatas => [

View File

@ -66,7 +66,7 @@ sub set_counters {
]; ];
$self->{maps_counters}->{global_snapshot} = [ $self->{maps_counters}->{global_snapshot} = [
{ label => 'total', set => { { label => 'total', nlabel => 'datastore.snapshots.usage.bytes', set => {
key_values => [ { name => 'total' } ], key_values => [ { name => 'total' } ],
output_template => 'total snapshots [size = %s %s]', output_template => 'total snapshots [size = %s %s]',
output_change_bytes => 1, output_change_bytes => 1,
@ -79,7 +79,7 @@ sub set_counters {
]; ];
$self->{maps_counters}->{files} = [ $self->{maps_counters}->{files} = [
{ label => 'snapshot', set => { { label => 'snapshot', nlabel => 'datastore.snapshot.usage.bytes', set => {
key_values => [ { name => 'total' } ], key_values => [ { name => 'total' } ],
output_template => '[size = %s %s]', output_template => '[size = %s %s]',
output_change_bytes => 1, output_change_bytes => 1,

View File

@ -43,25 +43,30 @@ sub custom_status_calc {
sub custom_usage_perfdata { sub custom_usage_perfdata {
my ($self, %options) = @_; my ($self, %options) = @_;
my $label = 'used'; my ($label, $nlabel) = ('used', $self->{label});
my $value_perf = $self->{result_values}->{used}; my $value_perf = $self->{result_values}->{used};
if (defined($self->{instance_mode}->{option_results}->{free})) { if (defined($self->{instance_mode}->{option_results}->{free})) {
$label = 'free'; ($label, $nlabel) = ('free', 'datastore.space.free.bytes');
$value_perf = $self->{result_values}->{free}; $value_perf = $self->{result_values}->{free};
} }
my $extra_label = ''; my $extra_label = '';
$extra_label = '_' . $self->{result_values}->{display} if (!defined($options{extra_instance}) || $options{extra_instance} != 0); $extra_label = $self->{result_values}->{display}
if (!defined($options{extra_instance}) || $options{extra_instance} != 0 || $self->{output}->use_new_perfdata());
my %total_options = (); my %total_options = ();
if ($self->{instance_mode}->{option_results}->{units} eq '%') { if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$total_options{total} = $self->{result_values}->{total}; $total_options{total} = $self->{result_values}->{total};
$total_options{cast_int} = 1; $total_options{cast_int} = 1;
} }
$self->{output}->perfdata_add(label => $label . $extra_label, unit => 'B', $self->{output}->perfdata_add(
value => $value_perf, label => $label, unit => 'B',
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, %total_options), instances => $extra_label,
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, %total_options), nlabel => $nlabel,
min => 0, max => $self->{result_values}->{total}); value => $value_perf,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}, %total_options),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}, %total_options),
min => 0, max => $self->{result_values}->{total}
);
} }
sub custom_usage_threshold { sub custom_usage_threshold {
@ -74,7 +79,7 @@ sub custom_usage_threshold {
$threshold_value = $self->{result_values}->{prct_used}; $threshold_value = $self->{result_values}->{prct_used};
$threshold_value = $self->{result_values}->{prct_free} if (defined($self->{instance_mode}->{option_results}->{free})); $threshold_value = $self->{result_values}->{prct_free} if (defined($self->{instance_mode}->{option_results}->{free}));
} }
$exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-'. $self->{label}, exit_litteral => 'warning' } ]); $exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' }, { label => 'warning-'. $self->{thlabel}, exit_litteral => 'warning' } ]);
return $exit; return $exit;
} }
@ -153,7 +158,7 @@ sub set_counters {
closure_custom_threshold_check => \&catalog_status_threshold, closure_custom_threshold_check => \&catalog_status_threshold,
} }
}, },
{ label => 'usage', set => { { label => 'usage', nlabel => 'datastore.space.usage.bytes', set => {
key_values => [ { name => 'display' }, { name => 'free' }, { name => 'total' } ], key_values => [ { name => 'display' }, { name => 'free' }, { name => 'total' } ],
closure_custom_calc => $self->can('custom_usage_calc'), closure_custom_calc => $self->can('custom_usage_calc'),
closure_custom_output => $self->can('custom_usage_output'), closure_custom_output => $self->can('custom_usage_output'),
@ -161,7 +166,7 @@ sub set_counters {
closure_custom_threshold_check => $self->can('custom_usage_threshold'), closure_custom_threshold_check => $self->can('custom_usage_threshold'),
} }
}, },
{ label => 'provisioned', set => { { label => 'provisioned', nlabel => 'datastore.space.provisioned.bytes', set => {
key_values => [ { name => 'display' }, { name => 'uncommitted' }, { name => 'total' }, { name => 'free' } ], key_values => [ { name => 'display' }, { name => 'uncommitted' }, { name => 'total' }, { name => 'free' } ],
closure_custom_calc => $self->can('custom_provisioned_calc'), closure_custom_calc => $self->can('custom_provisioned_calc'),
closure_custom_output => $self->can('custom_provisioned_output'), closure_custom_output => $self->can('custom_provisioned_output'),

View File

@ -67,7 +67,7 @@ sub set_counters {
]; ];
$self->{maps_counters}->{global_vm} = [ $self->{maps_counters}->{global_vm} = [
{ label => 'max-total-latency', set => { { label => 'max-total-latency', nlabel => 'vm.datastore.latency.max.milliseconds', set => {
key_values => [ { name => 'total_latency' } ], key_values => [ { name => 'total_latency' } ],
output_template => 'max total latency is %s ms', output_template => 'max total latency is %s ms',
perfdatas => [ perfdatas => [
@ -79,7 +79,7 @@ sub set_counters {
]; ];
$self->{maps_counters}->{datastore} = [ $self->{maps_counters}->{datastore} = [
{ label => 'read', set => { { label => 'read', nlabel => 'vm.datastore.read.usage.iops', set => {
key_values => [ { name => 'read' } ], key_values => [ { name => 'read' } ],
output_template => '%s read iops', output_template => '%s read iops',
perfdatas => [ perfdatas => [
@ -88,7 +88,7 @@ sub set_counters {
], ],
} }
}, },
{ label => 'write', set => { { label => 'write', nlabel => 'vm.datastore.write.usage.iops', set => {
key_values => [ { name => 'write' } ], key_values => [ { name => 'write' } ],
output_template => '%s write iops', output_template => '%s write iops',
perfdatas => [ perfdatas => [

View File

@ -57,7 +57,7 @@ sub set_counters {
]; ];
$self->{maps_counters}->{global} = [ $self->{maps_counters}->{global} = [
{ label => 'total-device-connected', set => { { label => 'total-device-connected', nlabel => 'vm.devices.connected.count', set => {
key_values => [ { name => 'device_connected' } ], key_values => [ { name => 'device_connected' } ],
closure_custom_output => $self->can('custom_device_output'), closure_custom_output => $self->can('custom_device_output'),
perfdatas => [ perfdatas => [
@ -77,7 +77,7 @@ sub set_counters {
closure_custom_threshold_check => \&catalog_status_threshold, closure_custom_threshold_check => \&catalog_status_threshold,
} }
}, },
{ label => 'device-connected', set => { { label => 'device-connected', nlabel => 'vm.devices.connected.count', set => {
key_values => [ { name => 'device_connected' }, { name => 'display' } ], key_values => [ { name => 'device_connected' }, { name => 'display' } ],
oclosure_custom_output => $self->can('custom_device_output'), oclosure_custom_output => $self->can('custom_device_output'),
perfdatas => [ perfdatas => [

View File

@ -67,7 +67,7 @@ sub set_counters {
]; ];
$self->{maps_counters}->{global} = [ $self->{maps_counters}->{global} = [
{ label => 'total-problems', set => { { label => 'total-problems', nlabel => 'host.health.problems.current.count', set => {
key_values => [ { name => 'total_problems' }, { name => 'total' } ], key_values => [ { name => 'total_problems' }, { name => 'total' } ],
output_template => '%s total health issue(s) found', output_template => '%s total health issue(s) found',
perfdatas => [ perfdatas => [
@ -96,7 +96,7 @@ sub set_counters {
closure_custom_perfdata => sub { return 0; }, closure_custom_perfdata => sub { return 0; },
} }
}, },
{ label => 'problems', set => { { label => 'problems', nlabel => 'host.health.problems.current.count', set => {
key_values => [ { name => 'total_problems' }, { name => 'total' } ], key_values => [ { name => 'total_problems' }, { name => 'total' } ],
output_template => '%s total health issue(s) found', output_template => '%s total health issue(s) found',
perfdatas => [ perfdatas => [
@ -105,7 +105,7 @@ sub set_counters {
], ],
} }
}, },
{ label => 'problems-yellow', set => { { label => 'problems-yellow', nlabel => 'host.health.yellow.current.count', set => {
key_values => [ { name => 'yellow' }, { name => 'total' } ], key_values => [ { name => 'yellow' }, { name => 'total' } ],
output_template => '%s yellow health issue(s) found', output_template => '%s yellow health issue(s) found',
perfdatas => [ perfdatas => [
@ -114,7 +114,7 @@ sub set_counters {
], ],
} }
}, },
{ label => 'problems-red', set => { { label => 'problems-red', nlabel => 'host.health.red.current.count', set => {
key_values => [ { name => 'red' }, { name => 'total' } ], key_values => [ { name => 'red' }, { name => 'total' } ],
output_template => '%s red health issue(s) found', output_template => '%s red health issue(s) found',
perfdatas => [ perfdatas => [

View File

@ -55,13 +55,13 @@ sub set_counters {
my ($self, %options) = @_; my ($self, %options) = @_;
$self->{maps_counters_type} = [ $self->{maps_counters_type} = [
{ name => 'cpu_alarms', type => 2, cb_long_output => 'cpu_long_output', message_multiple => '0 cpu limit problem(s) detected', format_output => '%s cpu limit problem(s) detected', display_counter_problem => { label => 'cpu_alerts', min => 0 }, { name => 'cpu_alarms', type => 2, cb_long_output => 'cpu_long_output', message_multiple => '0 cpu limit problem(s) detected', format_output => '%s cpu limit problem(s) detected', display_counter_problem => { label => 'cpu_alerts', nlabel => 'vm.limit.cpu.alerts.count', min => 0 },
group => [ { name => 'cpu_alarm', cb_prefix_output => 'prefix_vm_output', skipped_code => { -11 => 1 } } ] group => [ { name => 'cpu_alarm', cb_prefix_output => 'prefix_vm_output', skipped_code => { -11 => 1 } } ]
}, },
{ name => 'memory_alarms', type => 2,cb_long_output => 'memory_long_output', message_multiple => '0 memory limit problem(s) detected', format_output => '%s memory limit problem(s) detected', display_counter_problem => { label => 'memory_alerts', min => 0 }, { name => 'memory_alarms', type => 2,cb_long_output => 'memory_long_output', message_multiple => '0 memory limit problem(s) detected', format_output => '%s memory limit problem(s) detected', display_counter_problem => { label => 'memory_alerts', nlabel => 'vm.limit.memory.alerts.count', min => 0 },
group => [ { name => 'memory_alarm', cb_prefix_output => 'prefix_vm_output', skipped_code => { -11 => 1 } } ] group => [ { name => 'memory_alarm', cb_prefix_output => 'prefix_vm_output', skipped_code => { -11 => 1 } } ]
}, },
{ name => 'disk_alarms', type => 2, cb_long_output => 'disk_long_output', message_multiple => '0 disk limit problem(s) detected', format_output => '%s disk limit problem(s) detected', display_counter_problem => { label => 'disk_alerts', min => 0 }, { name => 'disk_alarms', type => 2, cb_long_output => 'disk_long_output', message_multiple => '0 disk limit problem(s) detected', format_output => '%s disk limit problem(s) detected', display_counter_problem => { label => 'disk_alerts', nlabel => 'vm.limit.disk.alerts.count', min => 0 },
group => [ { name => 'disk_alarm', cb_prefix_output => 'prefix_vm_output', skipped_code => { -11 => 1 } } ] group => [ { name => 'disk_alarm', cb_prefix_output => 'prefix_vm_output', skipped_code => { -11 => 1 } } ]
}, },
]; ];

View File

@ -43,25 +43,30 @@ sub custom_status_calc {
sub custom_usage_perfdata { sub custom_usage_perfdata {
my ($self, %options) = @_; my ($self, %options) = @_;
my $label = 'used'; my ($label, $nlabel) = ('used', $self->{label});
my $value_perf = $self->{result_values}->{used}; my $value_perf = $self->{result_values}->{used};
if (defined($self->{instance_mode}->{option_results}->{free})) { if (defined($self->{instance_mode}->{option_results}->{free})) {
$label = 'free'; ($label, $nlabel) = ('free', 'host.memory.free.bytes');
$value_perf = $self->{result_values}->{free}; $value_perf = $self->{result_values}->{free};
} }
my $extra_label = ''; my $extra_label = '';
$extra_label = '_' . $self->{result_values}->{display} if (!defined($options{extra_instance}) || $options{extra_instance} != 0); $extra_label = $self->{result_values}->{display}
if (!defined($options{extra_instance}) || $options{extra_instance} != 0 || $self->{output}->use_new_perfdata());
my %total_options = (); my %total_options = ();
if ($self->{instance_mode}->{option_results}->{units} eq '%') { if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$total_options{total} = $self->{result_values}->{total}; $total_options{total} = $self->{result_values}->{total};
$total_options{cast_int} = 1; $total_options{cast_int} = 1;
} }
$self->{output}->perfdata_add(label => $label . $extra_label, unit => 'B', $self->{output}->perfdata_add(
value => $value_perf, label => $label, unit => 'B',
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, %total_options), instances => $extra_label,
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, %total_options), nlabel => $nlabel,
min => 0, max => $self->{result_values}->{total}); value => $value_perf,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}, %total_options),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}, %total_options),
min => 0, max => $self->{result_values}->{total}
);
} }
sub custom_usage_threshold { sub custom_usage_threshold {
@ -74,7 +79,7 @@ sub custom_usage_threshold {
$threshold_value = $self->{result_values}->{prct_used}; $threshold_value = $self->{result_values}->{prct_used};
$threshold_value = $self->{result_values}->{prct_free} if (defined($self->{instance_mode}->{option_results}->{free})); $threshold_value = $self->{result_values}->{prct_free} if (defined($self->{instance_mode}->{option_results}->{free}));
} }
$exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-'. $self->{label}, exit_litteral => 'warning' } ]); $exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' }, { label => 'warning-'. $self->{thlabel}, exit_litteral => 'warning' } ]);
return $exit; return $exit;
} }
@ -142,7 +147,7 @@ sub set_counters {
closure_custom_threshold_check => \&catalog_status_threshold, closure_custom_threshold_check => \&catalog_status_threshold,
} }
}, },
{ label => 'consumed-memory', set => { { label => 'consumed-memory', nlabel => 'host.memory.usage.bytes', set => {
key_values => [ { name => 'display' }, { name => 'consumed' }, { name => 'total' } ], key_values => [ { name => 'display' }, { name => 'consumed' }, { name => 'total' } ],
closure_custom_calc => $self->can('custom_usage_calc'), closure_custom_calc => $self->can('custom_usage_calc'),
closure_custom_output => $self->can('custom_usage_output'), closure_custom_output => $self->can('custom_usage_output'),
@ -150,7 +155,7 @@ sub set_counters {
closure_custom_threshold_check => $self->can('custom_usage_threshold'), closure_custom_threshold_check => $self->can('custom_usage_threshold'),
} }
}, },
{ label => 'overhead-memory', set => { { label => 'overhead-memory', nlabel => 'host.memory.overhead.bytes', set => {
key_values => [ { name => 'overhead' }, { name => 'display' } ], key_values => [ { name => 'overhead' }, { name => 'display' } ],
closure_custom_output => $self->can('custom_overhead_output'), closure_custom_output => $self->can('custom_overhead_output'),
perfdatas => [ perfdatas => [
@ -159,7 +164,7 @@ sub set_counters {
], ],
} }
}, },
{ label => 'state-memory', set => { { label => 'state-memory', nlabel => 'host.memory.state.count', set => {
key_values => [ { name => 'mem_state' }, { name => 'mem_state_str' }, { name => 'display' } ], key_values => [ { name => 'mem_state' }, { name => 'mem_state_str' }, { name => 'display' } ],
closure_custom_output => $self->can('custom_memstate_output'), closure_custom_output => $self->can('custom_memstate_output'),
perfdatas => [ perfdatas => [

View File

@ -44,25 +44,30 @@ sub custom_status_calc {
sub custom_usage_perfdata { sub custom_usage_perfdata {
my ($self, %options) = @_; my ($self, %options) = @_;
my $label = $self->{label} . '_used'; my ($label, $nlabel) = ('used', $self->{label});
my $value_perf = $self->{result_values}->{used}; my $value_perf = $self->{result_values}->{used};
if (defined($self->{instance_mode}->{option_results}->{free})) { if (defined($self->{instance_mode}->{option_results}->{free})) {
$label = $self->{label} . '_free'; ($label, $nlabel) = ('free', 'vm.memory.free.bytes');
$value_perf = $self->{result_values}->{free}; $value_perf = $self->{result_values}->{free};
} }
my $extra_label = ''; my $extra_label = '';
$extra_label = '_' . $self->{instance} if (!defined($options{extra_instance}) || $options{extra_instance} != 0); $extra_label = $self->{result_values}->{display}
if (!defined($options{extra_instance}) || $options{extra_instance} != 0 || $self->{output}->use_new_perfdata());
my %total_options = (); my %total_options = ();
if ($self->{instance_mode}->{option_results}->{units} eq '%') { if ($self->{instance_mode}->{option_results}->{units} eq '%') {
$total_options{total} = $self->{result_values}->{total}; $total_options{total} = $self->{result_values}->{total};
$total_options{cast_int} = 1; $total_options{cast_int} = 1;
} }
$self->{output}->perfdata_add(label => $label . $extra_label, unit => 'B', $self->{output}->perfdata_add(
value => $value_perf, label => $label, unit => 'B',
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, %total_options), instances => $extra_label,
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, %total_options), nlabel => $nlabel,
min => 0, max => $self->{result_values}->{total}); value => $value_perf,
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}, %total_options),
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}, %total_options),
min => 0, max => $self->{result_values}->{total}
);
} }
sub custom_usage_threshold { sub custom_usage_threshold {
@ -75,7 +80,7 @@ sub custom_usage_threshold {
$threshold_value = $self->{result_values}->{prct_used}; $threshold_value = $self->{result_values}->{prct_used};
$threshold_value = $self->{result_values}->{prct_free} if (defined($self->{instance_mode}->{option_results}->{free})); $threshold_value = $self->{result_values}->{prct_free} if (defined($self->{instance_mode}->{option_results}->{free}));
} }
$exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-'. $self->{label}, exit_litteral => 'warning' } ]); $exit = $self->{perfdata}->threshold_check(value => $threshold_value, threshold => [ { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' }, { label => 'warning-'. $self->{thlabel}, exit_litteral => 'warning' } ]);
return $exit; return $exit;
} }
@ -165,7 +170,7 @@ sub set_counters {
]; ];
$self->{maps_counters}->{global_consumed} = [ $self->{maps_counters}->{global_consumed} = [
{ label => 'consumed', set => { { label => 'consumed', nlabel => 'vm.memory.usage.bytes', set => {
key_values => [ { name => 'consumed' }, { name => 'total' } ], key_values => [ { name => 'consumed' }, { name => 'total' } ],
closure_custom_calc => $self->can('custom_usage_calc'), closure_custom_calc_extra_options => { label_ref => 'consumed' }, closure_custom_calc => $self->can('custom_usage_calc'), closure_custom_calc_extra_options => { label_ref => 'consumed' },
closure_custom_output => $self->can('custom_usage_output'), closure_custom_output => $self->can('custom_usage_output'),
@ -175,7 +180,7 @@ sub set_counters {
}, },
]; ];
$self->{maps_counters}->{global_active} = [ $self->{maps_counters}->{global_active} = [
{ label => 'active', set => { { label => 'active', nlabel => 'vm.memory.active.bytes', set => {
key_values => [ { name => 'active' }, { name => 'total' } ], key_values => [ { name => 'active' }, { name => 'total' } ],
closure_custom_calc => $self->can('custom_usage_calc'), closure_custom_calc_extra_options => { label_ref => 'active' }, closure_custom_calc => $self->can('custom_usage_calc'), closure_custom_calc_extra_options => { label_ref => 'active' },
closure_custom_output => $self->can('custom_usage_output'), closure_custom_output => $self->can('custom_usage_output'),
@ -185,7 +190,7 @@ sub set_counters {
}, },
]; ];
$self->{maps_counters}->{global_overhead} = [ $self->{maps_counters}->{global_overhead} = [
{ label => 'overhead', set => { { label => 'overhead', nlabel => 'vm.memory.overhead.bytes', set => {
key_values => [ { name => 'overhead' } ], key_values => [ { name => 'overhead' } ],
closure_custom_output => $self->can('custom_overhead_output'), closure_custom_output => $self->can('custom_overhead_output'),
perfdatas => [ perfdatas => [
@ -196,7 +201,7 @@ sub set_counters {
}, },
]; ];
$self->{maps_counters}->{global_vmmemctl} = [ $self->{maps_counters}->{global_vmmemctl} = [
{ label => 'ballooning', set => { { label => 'ballooning', nlabel => 'vm.memory.ballooning.bytes', set => {
key_values => [ { name => 'vmmemctl' } ], key_values => [ { name => 'vmmemctl' } ],
closure_custom_output => $self->can('custom_ballooning_output'), closure_custom_output => $self->can('custom_ballooning_output'),
perfdatas => [ perfdatas => [
@ -207,7 +212,7 @@ sub set_counters {
}, },
]; ];
$self->{maps_counters}->{global_shared} = [ $self->{maps_counters}->{global_shared} = [
{ label => 'shared', set => { { label => 'shared', nlabel => 'vm.memory.shared.bytes', set => {
key_values => [ { name => 'shared' } ], key_values => [ { name => 'shared' } ],
closure_custom_output => $self->can('custom_shared_output'), closure_custom_output => $self->can('custom_shared_output'),
perfdatas => [ perfdatas => [

View File

@ -126,7 +126,7 @@ sub set_counters {
]; ];
$self->{maps_counters}->{global_host} = [ $self->{maps_counters}->{global_host} = [
{ label => 'host-traffic-in', set => { { label => 'host-traffic-in', nlabel => 'host.traffic.in.bitsperseconds', set => {
key_values => [ { name => 'traffic_in' } ], key_values => [ { name => 'traffic_in' } ],
output_template => 'host traffic in : %s %s/s', output_template => 'host traffic in : %s %s/s',
output_change_bytes => 2, output_change_bytes => 2,
@ -136,7 +136,7 @@ sub set_counters {
], ],
} }
}, },
{ label => 'host-traffic-out', set => { { label => 'host-traffic-out', nlabel => 'host.traffic.out.bitsperseconds', set => {
key_values => [ { name => 'traffic_out' } ], key_values => [ { name => 'traffic_out' } ],
output_template => 'host traffic out : %s %s/s', output_template => 'host traffic out : %s %s/s',
output_change_bytes => 2, output_change_bytes => 2,
@ -149,7 +149,7 @@ sub set_counters {
]; ];
$self->{maps_counters}->{vswitch} = [ $self->{maps_counters}->{vswitch} = [
{ label => 'vswitch-traffic-in', set => { { label => 'vswitch-traffic-in', nlabel => 'host.vswitch.traffic.in.bitsperseconds', set => {
key_values => [ { name => 'traffic_in' } ], key_values => [ { name => 'traffic_in' } ],
output_template => 'traffic in : %s %s/s', output_template => 'traffic in : %s %s/s',
output_change_bytes => 2, output_change_bytes => 2,
@ -159,7 +159,7 @@ sub set_counters {
], ],
} }
}, },
{ label => 'vswitch-traffic-out', set => { { label => 'vswitch-traffic-out', nlabel => 'host.vswitch.traffic.out.bitsperseconds', set => {
key_values => [ { name => 'traffic_out' } ], key_values => [ { name => 'traffic_out' } ],
output_template => 'traffic out : %s %s/s', output_template => 'traffic out : %s %s/s',
output_change_bytes => 2, output_change_bytes => 2,
@ -180,7 +180,7 @@ sub set_counters {
closure_custom_threshold_check => \&catalog_status_threshold, closure_custom_threshold_check => \&catalog_status_threshold,
} }
}, },
{ label => 'link-traffic-in', set => { { label => 'link-traffic-in', nlabel => 'host.traffic.in.bitsperseconds', set => {
key_values => [ { name => 'display' }, { name => 'traffic_in' }, { name => 'speed' } ], key_values => [ { name => 'display' }, { name => 'traffic_in' }, { name => 'speed' } ],
closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'in' }, closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'in' },
closure_custom_output => $self->can('custom_traffic_output'), closure_custom_output => $self->can('custom_traffic_output'),
@ -191,7 +191,7 @@ sub set_counters {
], ],
} }
}, },
{ label => 'link-traffic-out', set => { { label => 'link-traffic-out', nlabel => 'host.traffic.out.bitsperseconds', set => {
key_values => [ { name => 'display' }, { name => 'traffic_out' }, { name => 'speed' } ], key_values => [ { name => 'display' }, { name => 'traffic_out' }, { name => 'speed' } ],
closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'out' }, closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'out' },
closure_custom_output => $self->can('custom_traffic_output'), closure_custom_output => $self->can('custom_traffic_output'),
@ -202,7 +202,7 @@ sub set_counters {
], ],
} }
}, },
{ label => 'link-dropped-in', set => { { label => 'link-dropped-in', nlabel => 'host.packets.in.dropped.percentage', set => {
key_values => [ { name => 'display' }, { name => 'packets_in' }, { name => 'dropped_in' } ], key_values => [ { name => 'display' }, { name => 'packets_in' }, { name => 'dropped_in' } ],
closure_custom_calc => $self->can('custom_dropped_calc'), closure_custom_calc_extra_options => { label_ref => 'in' }, closure_custom_calc => $self->can('custom_dropped_calc'), closure_custom_calc_extra_options => { label_ref => 'in' },
closure_custom_output => $self->can('custom_dropped_output'), closure_custom_output => $self->can('custom_dropped_output'),
@ -213,7 +213,7 @@ sub set_counters {
], ],
} }
}, },
{ label => 'link-dropped-out', set => { { label => 'link-dropped-out', nlabel => 'host.packets.out.dropped.percentage', set => {
key_values => [ { name => 'display' }, { name => 'packets_out' }, { name => 'dropped_out' } ], key_values => [ { name => 'display' }, { name => 'packets_out' }, { name => 'dropped_out' } ],
closure_custom_calc => $self->can('custom_dropped_calc'), closure_custom_calc_extra_options => { label_ref => 'out' }, closure_custom_calc => $self->can('custom_dropped_calc'), closure_custom_calc_extra_options => { label_ref => 'out' },
closure_custom_output => $self->can('custom_dropped_output'), closure_custom_output => $self->can('custom_dropped_output'),

View File

@ -138,12 +138,18 @@ sub run {
} }
} }
$self->{output}->perfdata_add(label => 'num_warning', $self->{output}->perfdata_add(
value => scalar(keys %{$vm_errors{warning}}), label => 'num_warning',
min => 0); nlabel => 'vm.snapshots.warning.current.count',
$self->{output}->perfdata_add(label => 'num_critical', value => scalar(keys %{$vm_errors{warning}}),
value => scalar(keys %{$vm_errors{critical}}), min => 0
min => 0); );
$self->{output}->perfdata_add(
label => 'num_critical',
nlabel => 'vm.snapshots.critical.current.count',
value => scalar(keys %{$vm_errors{critical}}),
min => 0
);
if (scalar(keys %{$vm_errors{warning}}) > 0) { if (scalar(keys %{$vm_errors{warning}}) > 0) {
$self->{output}->output_add(severity => 'WARNING', $self->{output}->output_add(severity => 'WARNING',
short_msg => sprintf('Snapshots for VM older than %d days: [%s]', ($self->{option_results}->{warning} / 86400), short_msg => sprintf('Snapshots for VM older than %d days: [%s]', ($self->{option_results}->{warning} / 86400),

View File

@ -35,7 +35,7 @@ sub set_counters {
]; ];
$self->{maps_counters}->{global} = [ $self->{maps_counters}->{global} = [
{ label => 'total-requests', set => { { label => 'total-requests', nlabel => 'connector.requests.total.count', set => {
key_values => [ { name => 'requests', diff => 1 } ], key_values => [ { name => 'requests', diff => 1 } ],
output_template => 'Total %s requests', output_template => 'Total %s requests',
perfdatas => [ perfdatas => [
@ -47,7 +47,7 @@ sub set_counters {
]; ];
$self->{maps_counters}->{container} = [ $self->{maps_counters}->{container} = [
{ label => 'requests', set => { { label => 'requests', nlabel => 'connector.requests.total.count', set => {
key_values => [ { name => 'requests', diff => 1 } ], key_values => [ { name => 'requests', diff => 1 } ],
output_template => '%s requests', output_template => '%s requests',
perfdatas => [ perfdatas => [
@ -71,9 +71,9 @@ sub new {
bless $self, $class; bless $self, $class;
$self->{version} = '1.0'; $self->{version} = '1.0';
$options{options}->add_options(arguments => $options{options}->add_options(arguments => {
{ });
});
return $self; return $self;
} }

View File

@ -56,7 +56,7 @@ sub set_counters {
closure_custom_threshold_check => \&catalog_status_threshold, closure_custom_threshold_check => \&catalog_status_threshold,
} }
}, },
{ label => 'swap-in', set => { { label => 'swap-in', nlabel => 'host.swap.in.usage.bytesperseconds', set => {
key_values => [ { name => 'swap_in' }, { name => 'display' } ], key_values => [ { name => 'swap_in' }, { name => 'display' } ],
output_template => 'Swap In: %s %s/s', output_template => 'Swap In: %s %s/s',
output_change_bytes => 1, output_change_bytes => 1,
@ -66,7 +66,7 @@ sub set_counters {
], ],
} }
}, },
{ label => 'swap-out', set => { { label => 'swap-out', nlabel => 'host.swap.out.usage.bytesperseconds', set => {
key_values => [ { name => 'swap_out' }, { name => 'display' } ], key_values => [ { name => 'swap_out' }, { name => 'display' } ],
output_template => 'Swap Out: %s %s/s', output_template => 'Swap Out: %s %s/s',
output_change_bytes => 1, output_change_bytes => 1,

View File

@ -57,7 +57,7 @@ sub set_counters {
closure_custom_threshold_check => \&catalog_status_threshold, closure_custom_threshold_check => \&catalog_status_threshold,
} }
}, },
{ label => 'swap-in', set => { { label => 'swap-in', nlabel => 'vm.swap.in.usage.bytesperseconds', set => {
key_values => [ { name => 'swap_in' }, { name => 'display' } ], key_values => [ { name => 'swap_in' }, { name => 'display' } ],
output_template => 'Swap In: %s %s/s', output_template => 'Swap In: %s %s/s',
output_change_bytes => 1, output_change_bytes => 1,
@ -67,7 +67,7 @@ sub set_counters {
], ],
} }
}, },
{ label => 'swap-out', set => { { label => 'swap-out', nlabel => 'vm.swap.out.usage.bytesperseconds', set => {
key_values => [ { name => 'swap_out' }, { name => 'display' } ], key_values => [ { name => 'swap_out' }, { name => 'display' } ],
output_template => 'Swap Out: %s %s/s', output_template => 'Swap Out: %s %s/s',
output_change_bytes => 1, output_change_bytes => 1,

View File

@ -65,7 +65,7 @@ sub set_counters {
closure_custom_threshold_check => \&catalog_status_threshold, closure_custom_threshold_check => \&catalog_status_threshold,
} }
}, },
{ label => 'time', set => { { label => 'time', nlabel => 'host.time.offset.seconds', set => {
key_values => [ { name => 'offset' }, { name => 'date' }, { name => 'display' } ], key_values => [ { name => 'offset' }, { name => 'date' }, { name => 'display' } ],
closure_custom_output => $self->can('custom_time_output'), closure_custom_output => $self->can('custom_time_output'),
perfdatas => [ perfdatas => [

View File

@ -156,15 +156,24 @@ sub run {
if ($multiple == 1) { if ($multiple == 1) {
my $total = scalar(keys %not_up2date) + scalar(keys %not_running) + scalar(keys %not_installed); my $total = scalar(keys %not_up2date) + scalar(keys %not_running) + scalar(keys %not_installed);
$self->{output}->perfdata_add(label => 'not_updated', $self->{output}->perfdata_add(
value => scalar(keys %not_up2date), label => 'not_updated',
min => 0, max => $total); nlabel => 'vm.tools.notupdated.current.count',
$self->{output}->perfdata_add(label => 'not_running', value => scalar(keys %not_up2date),
value => scalar(keys %not_running), min => 0, max => $total
min => 0, max => $total); );
$self->{output}->perfdata_add(label => 'not_installed', $self->{output}->perfdata_add(
value => scalar(keys %not_installed), label => 'not_running',
min => 0, max => $total); nlabel => 'vm.tools.notrunning.current.count',
value => scalar(keys %not_running),
min => 0, max => $total
);
$self->{output}->perfdata_add(
label => 'not_installed',
nlabel => 'vm.tools.notinstalled.current.count',
value => scalar(keys %not_installed),
min => 0, max => $total
);
} }
$self->{output}->display(); $self->{output}->display();

View File

@ -65,7 +65,7 @@ sub set_counters {
closure_custom_threshold_check => \&catalog_status_threshold, closure_custom_threshold_check => \&catalog_status_threshold,
} }
}, },
{ label => 'time', set => { { label => 'time', nlabel => 'host.uptime.offset.seconds', set => {
key_values => [ { name => 'offset' }, { name => 'date' }, { name => 'display' } ], key_values => [ { name => 'offset' }, { name => 'date' }, { name => 'display' } ],
closure_custom_output => $self->can('custom_time_output'), closure_custom_output => $self->can('custom_time_output'),
perfdatas => [ perfdatas => [

View File

@ -34,7 +34,7 @@ sub set_counters {
]; ];
$self->{maps_counters}->{cluster} = [ $self->{maps_counters}->{cluster} = [
{ label => 'svmotion', set => { { label => 'svmotion', nlabel => 'cluster.operations.svmotion.current.count', set => {
key_values => [ { name => 'numSVMotion', diff => 1 }, { name => 'display' } ], key_values => [ { name => 'numSVMotion', diff => 1 }, { name => 'display' } ],
output_template => 'SVMotion %s', output_template => 'SVMotion %s',
perfdatas => [ perfdatas => [
@ -43,7 +43,7 @@ sub set_counters {
], ],
} }
}, },
{ label => 'vmotion', set => { { label => 'vmotion', nlabel => 'cluster.operations.vmotion.current.count', set => {
key_values => [ { name => 'numVMotion', diff => 1 }, { name => 'display' } ], key_values => [ { name => 'numVMotion', diff => 1 }, { name => 'display' } ],
output_template => 'VMotion %s', output_template => 'VMotion %s',
perfdatas => [ perfdatas => [
@ -52,7 +52,7 @@ sub set_counters {
], ],
} }
}, },
{ label => 'clone', set => { { label => 'clone', nlabel => 'cluster.operations.clone.current.count', set => {
key_values => [ { name => 'numClone', diff => 1 }, { name => 'display' } ], key_values => [ { name => 'numClone', diff => 1 }, { name => 'display' } ],
output_template => 'Clone %s', output_template => 'Clone %s',
perfdatas => [ perfdatas => [

View File

@ -79,6 +79,30 @@ sub call_object_callback {
return undef; return undef;
} }
sub get_threshold_prefix {
my ($self, %options) = @_;
my $prefix = '';
END_LOOP: foreach (@{$self->{maps_counters_type}}) {
if ($_->{name} eq $options{name}) {
$prefix = 'instance-' if ($_->{type} == 1);
last;
}
if ($_->{type} == 3) {
foreach (@{$_->{group}}) {
if ($_->{name} eq $options{name}) {
$prefix = 'instance-' if ($_->{type} == 0);
$prefix = 'subinstance-' if ($_->{type} == 1);
last END_LOOP;
}
}
}
}
return $prefix;
}
sub new { sub new {
my ($class, %options) = @_; my ($class, %options) = @_;
my $self = $class->SUPER::new(package => __PACKAGE__, %options); my $self = $class->SUPER::new(package => __PACKAGE__, %options);
@ -102,8 +126,11 @@ sub new {
foreach my $key (keys %{$self->{maps_counters}}) { foreach my $key (keys %{$self->{maps_counters}}) {
foreach (@{$self->{maps_counters}->{$key}}) { foreach (@{$self->{maps_counters}->{$key}}) {
my $label = $_->{label}; my $label = $_->{label};
$label = $_->{nlabel} if ($self->{output}->use_new_perfdata() && defined($_->{nlabel}));
my $thlabel = $label; my $thlabel = $label;
if ($self->{output}->use_new_perfdata() && defined($_->{nlabel})) {
$label = $_->{nlabel};
$thlabel = $self->get_threshold_prefix(name => $key) . $label;
}
$thlabel =~ s/\./-/g; $thlabel =~ s/\./-/g;
if (!defined($_->{threshold}) || $_->{threshold} != 0) { if (!defined($_->{threshold}) || $_->{threshold} != 0) {
@ -125,7 +152,7 @@ sub new {
$_->{obj}->set(%{$_->{set}}); $_->{obj}->set(%{$_->{set}});
} }
} }
return $self; return $self;
} }
@ -385,9 +412,13 @@ sub run_group {
} }
if (defined($options{config}->{display_counter_problem})) { if (defined($options{config}->{display_counter_problem})) {
$self->{output}->perfdata_add(label => $options{config}->{display_counter_problem}->{label}, unit => $options{config}->{display_counter_problem}->{unit}, $self->{output}->perfdata_add(
value => $total_problems, label => $options{config}->{display_counter_problem}->{label},
min => $options{config}->{display_counter_problem}->{min}, max => $options{config}->{display_counter_problem}->{max}); nlabel => $options{config}->{display_counter_problem}->{nlabel},
unit => $options{config}->{display_counter_problem}->{unit},
value => $total_problems,
min => $options{config}->{display_counter_problem}->{min}, max => $options{config}->{display_counter_problem}->{max}
);
} }
} }