diff --git a/apps/vmware/connector/mode/alarmdatacenter.pm b/apps/vmware/connector/mode/alarmdatacenter.pm index 900e04cdf..06c3011d9 100644 --- a/apps/vmware/connector/mode/alarmdatacenter.pm +++ b/apps/vmware/connector/mode/alarmdatacenter.pm @@ -86,15 +86,19 @@ sub custom_status_calc { sub custom_dcmetrics_perfdata { my ($self, %options) = @_; - my $extra_label = ''; + my $extra_label; # We do it manually. Because we have only 1 instance in group. - if (scalar(keys %{$self->{instance_mode}->{datacenter}}) > 1) { - $extra_label .= '_' . $self->{result_values}->{name}; + if (scalar(keys %{$self->{instance_mode}->{datacenter}}) > 1 || $self->{output}->use_new_perfdata()) { + $extra_label = $self->{result_values}->{name}; } - $self->{output}->perfdata_add(label => 'alarm_' . $self->{result_values}->{label_ref} . $extra_label, - value => $self->{result_values}->{alarm_value}, - min => 0); + $self->{output}->perfdata_add( + label => 'alarm_' . $self->{result_values}->{label_ref}, + 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 { @@ -120,7 +124,7 @@ sub set_counters { ]; $self->{maps_counters}->{global} = [ - { label => 'total-alarm-warning', set => { + { label => 'total-alarm-warning', nlabel => 'datacenter.alarms.warning.current.count', set => { key_values => [ { name => 'yellow' } ], output_template => '%s warning alarm(s) found(s)', 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' } ], output_template => '%s critical alarm(s) found(s)', perfdatas => [ diff --git a/apps/vmware/connector/mode/alarmhost.pm b/apps/vmware/connector/mode/alarmhost.pm index 7348a999a..6c0491fca 100644 --- a/apps/vmware/connector/mode/alarmhost.pm +++ b/apps/vmware/connector/mode/alarmhost.pm @@ -40,11 +40,11 @@ sub catalog_status_threshold { $label =~ s/-/_/g; 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}") { - $self->{instance_mode}->{dc_critical}++; + $self->{instance_mode}->{host_critical}++; $status = 'critical'; } 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}") { - $self->{instance_mode}->{dc_warning}++; + $self->{instance_mode}->{host_warning}++; $status = 'warning'; } }; @@ -86,21 +86,25 @@ sub custom_status_calc { sub custom_esxhost_perfdata { my ($self, %options) = @_; - my $extra_label = ''; + my $extra_label; # We do it manually. Because we have only 1 instance in group. - if (scalar(keys %{$self->{instance_mode}->{esxhost}}) > 1) { - $extra_label .= '_' . $self->{result_values}->{name}; + if (scalar(keys %{$self->{instance_mode}->{esxhost}}) > 1 || $self->{output}->use_new_perfdata()) { + $extra_label = $self->{result_values}->{name}; } - $self->{output}->perfdata_add(label => 'alarm_' . $self->{result_values}->{label_ref} . $extra_label, - value => $self->{result_values}->{alarm_value}, - min => 0); + $self->{output}->perfdata_add( + label => 'alarm_' . $self->{result_values}->{label_ref}, + 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 { my ($self, %options) = @_; $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'}; return 0; } @@ -119,7 +123,7 @@ sub set_counters { ]; $self->{maps_counters}->{global} = [ - { label => 'total-alarm-warning', set => { + { label => 'total-alarm-warning', nlabel => 'host.alarms.warning.current.count', set => { key_values => [ { name => 'yellow' } ], output_template => '%s warning alarm(s) found(s)', 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' } ], output_template => '%s critical alarm(s) found(s)', perfdatas => [ @@ -153,6 +157,7 @@ sub set_counters { { label => 'alarm-warning', threshold => 0, set => { key_values => [ { name => 'name' } ], 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_perfdata => $self->can('custom_esxhost_perfdata'), } @@ -160,6 +165,7 @@ sub set_counters { { label => 'alarm-critical', threshold => 0, set => { key_values => [ { name => 'name' } ], 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_perfdata => $self->can('custom_esxhost_perfdata'), } @@ -176,8 +182,8 @@ sub prefix_esxhost_output { sub alarm_reset { my ($self, %options) = @_; - $self->{dc_warning} = 0; - $self->{dc_critical} = 0; + $self->{host_warning} = 0; + $self->{host_critical} = 0; } sub esxhost_long_output { diff --git a/apps/vmware/connector/mode/countvmhost.pm b/apps/vmware/connector/mode/countvmhost.pm index 0d1c36b36..b396acab2 100644 --- a/apps/vmware/connector/mode/countvmhost.pm +++ b/apps/vmware/connector/mode/countvmhost.pm @@ -49,7 +49,7 @@ sub set_counters { ]; $self->{maps_counters}->{global} = [ - { label => 'total-on', set => { + { label => 'total-on', nlabel => 'host.vm.poweredon.current.count', set => { key_values => [ { name => 'poweredon' }, { name => 'total' } ], output_template => '%s VM(s) poweredon', 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' } ], output_template => '%s VM(s) poweredoff', 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' } ], output_template => '%s VM(s) suspended', perfdatas => [ @@ -87,7 +87,7 @@ sub set_counters { 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' } ], output_template => '%s VM(s) poweredon', 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' } ], output_template => '%s VM(s) poweredoff', 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' } ], output_template => '%s VM(s) suspended', perfdatas => [ diff --git a/apps/vmware/connector/mode/cpuhost.pm b/apps/vmware/connector/mode/cpuhost.pm index 86dda6516..8ba9a1834 100644 --- a/apps/vmware/connector/mode/cpuhost.pm +++ b/apps/vmware/connector/mode/cpuhost.pm @@ -65,7 +65,7 @@ sub set_counters { ]; $self->{maps_counters}->{global_cpu} = [ - { label => 'total-cpu', set => { + { label => 'total-cpu', nlabel => 'host.cpu.utilization.percentage', set => { key_values => [ { name => 'cpu_average' } ], output_template => '%s %%', 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' } ], output_template => '%s MHz', perfdatas => [ @@ -86,7 +86,7 @@ sub set_counters { ]; $self->{maps_counters}->{cpu} = [ - { label => 'cpu', set => { + { label => 'cpu', nlabel => 'host.core.cpu.utilization.percentage', set => { key_values => [ { name => 'cpu_usage' }, { name => 'display' } ], output_template => 'usage : %s', perfdatas => [ diff --git a/apps/vmware/connector/mode/cpuvm.pm b/apps/vmware/connector/mode/cpuvm.pm index d36795d56..112722537 100644 --- a/apps/vmware/connector/mode/cpuvm.pm +++ b/apps/vmware/connector/mode/cpuvm.pm @@ -49,7 +49,7 @@ sub set_counters { group => [ { 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 => '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} = [ - { label => 'total-cpu', set => { + { label => 'total-cpu', nlabel => 'vm.cpu.utilization.percentage', set => { key_values => [ { name => 'cpu_average' } ], output_template => '%s %%', 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' } ], output_template => '%s MHz', 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' } ], output_template => 'ready %s %%', perfdatas => [ @@ -96,7 +96,7 @@ sub set_counters { ]; $self->{maps_counters}->{cpu} = [ - { label => 'cpu', set => { + { label => 'cpu', nlabel => 'vm.core.cpu.utilization.percentage', set => { key_values => [ { name => 'cpu_usage' }, { name => 'display' } ], output_template => 'usage : %s MHz', perfdatas => [ diff --git a/apps/vmware/connector/mode/datastorecountvm.pm b/apps/vmware/connector/mode/datastorecountvm.pm index f1a650087..64f9fb60f 100644 --- a/apps/vmware/connector/mode/datastorecountvm.pm +++ b/apps/vmware/connector/mode/datastorecountvm.pm @@ -50,7 +50,7 @@ sub set_counters { ]; $self->{maps_counters}->{global} = [ - { label => 'total-on', set => { + { label => 'total-on', nlabel => 'datastore.vm.poweredon.current.count', set => { key_values => [ { name => 'poweredon' }, { name => 'total' } ], output_template => '%s VM(s) poweredon', 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' } ], output_template => '%s VM(s) poweredoff', 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' } ], output_template => '%s VM(s) suspended', perfdatas => [ @@ -88,7 +88,7 @@ sub set_counters { 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' } ], output_template => '%s VM(s) poweredon', 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' } ], output_template => '%s VM(s) poweredoff', 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' } ], output_template => '%s VM(s) suspended', perfdatas => [ diff --git a/apps/vmware/connector/mode/datastorehost.pm b/apps/vmware/connector/mode/datastorehost.pm index 35fc6dc91..7b681ee45 100644 --- a/apps/vmware/connector/mode/datastorehost.pm +++ b/apps/vmware/connector/mode/datastorehost.pm @@ -65,7 +65,7 @@ sub set_counters { ]; $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' } ], output_template => 'read : %s ms', 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' } ], output_template => 'write : %s ms', perfdatas => [ diff --git a/apps/vmware/connector/mode/datastoreio.pm b/apps/vmware/connector/mode/datastoreio.pm index b6b61555c..d0de14866 100644 --- a/apps/vmware/connector/mode/datastoreio.pm +++ b/apps/vmware/connector/mode/datastoreio.pm @@ -49,7 +49,7 @@ sub set_counters { ]; $self->{maps_counters}->{global} = [ - { label => 'total-read', set => { + { label => 'total-read', nlabel => 'datastore.read.usage.bytesperseconds', set => { key_values => [ { name => 'read' } ], output_template => 'Total rate of reading data: %s %s/s', 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' } ], output_template => 'Total rate of writing data: %s %s/s', output_change_bytes => 1, @@ -80,7 +80,7 @@ sub set_counters { closure_custom_threshold_check => \&catalog_status_threshold, } }, - { label => 'read', set => { + { label => 'read', nlabel => 'datastore.read.usage.bytesperseconds', set => { key_values => [ { name => 'read' } ], output_template => 'rate of reading data: %s %s/s', 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' } ], output_template => 'rate of writing data: %s %s/s', output_change_bytes => 1, diff --git a/apps/vmware/connector/mode/datastoreiops.pm b/apps/vmware/connector/mode/datastoreiops.pm index 8b8088540..189435553 100644 --- a/apps/vmware/connector/mode/datastoreiops.pm +++ b/apps/vmware/connector/mode/datastoreiops.pm @@ -66,7 +66,7 @@ sub set_counters { ]; $self->{maps_counters}->{global_iops} = [ - { label => 'read', set => { + { label => 'read', nlabel => 'datastore.read.usage.iops', set => { key_values => [ { name => 'read' } ], output_template => '%s read iops', perfdatas => [ @@ -75,7 +75,7 @@ sub set_counters { ], } }, - { label => 'write', set => { + { label => 'write', nlabel => 'datastore.write.usage.iops', set => { key_values => [ { name => 'write' } ], output_template => '%s write iops', perfdatas => [ @@ -87,7 +87,7 @@ sub set_counters { ]; $self->{maps_counters}->{vm} = [ - { label => 'read-vm', set => { + { label => 'read-vm', nlabel => 'datastore.vm.read.usage.iops', set => { key_values => [ { name => 'read' } ], output_template => '%s read iops', 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' } ], output_template => '%s write iops', perfdatas => [ diff --git a/apps/vmware/connector/mode/datastoresnapshot.pm b/apps/vmware/connector/mode/datastoresnapshot.pm index edf0c11d2..f9ffad0b4 100644 --- a/apps/vmware/connector/mode/datastoresnapshot.pm +++ b/apps/vmware/connector/mode/datastoresnapshot.pm @@ -66,7 +66,7 @@ sub set_counters { ]; $self->{maps_counters}->{global_snapshot} = [ - { label => 'total', set => { + { label => 'total', nlabel => 'datastore.snapshots.usage.bytes', set => { key_values => [ { name => 'total' } ], output_template => 'total snapshots [size = %s %s]', output_change_bytes => 1, @@ -79,7 +79,7 @@ sub set_counters { ]; $self->{maps_counters}->{files} = [ - { label => 'snapshot', set => { + { label => 'snapshot', nlabel => 'datastore.snapshot.usage.bytes', set => { key_values => [ { name => 'total' } ], output_template => '[size = %s %s]', output_change_bytes => 1, diff --git a/apps/vmware/connector/mode/datastoreusage.pm b/apps/vmware/connector/mode/datastoreusage.pm index 7f6312e45..9eb3961ee 100644 --- a/apps/vmware/connector/mode/datastoreusage.pm +++ b/apps/vmware/connector/mode/datastoreusage.pm @@ -43,25 +43,30 @@ sub custom_status_calc { sub custom_usage_perfdata { my ($self, %options) = @_; - my $label = 'used'; + my ($label, $nlabel) = ('used', $self->{label}); my $value_perf = $self->{result_values}->{used}; if (defined($self->{instance_mode}->{option_results}->{free})) { - $label = 'free'; + ($label, $nlabel) = ('free', 'datastore.space.free.bytes'); $value_perf = $self->{result_values}->{free}; } 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 = (); if ($self->{instance_mode}->{option_results}->{units} eq '%') { $total_options{total} = $self->{result_values}->{total}; $total_options{cast_int} = 1; } - $self->{output}->perfdata_add(label => $label . $extra_label, unit => 'B', - value => $value_perf, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, %total_options), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, %total_options), - min => 0, max => $self->{result_values}->{total}); + $self->{output}->perfdata_add( + label => $label, unit => 'B', + instances => $extra_label, + nlabel => $nlabel, + 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 { @@ -74,7 +79,7 @@ sub custom_usage_threshold { $threshold_value = $self->{result_values}->{prct_used}; $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; } @@ -153,7 +158,7 @@ sub set_counters { 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' } ], closure_custom_calc => $self->can('custom_usage_calc'), closure_custom_output => $self->can('custom_usage_output'), @@ -161,7 +166,7 @@ sub set_counters { 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' } ], closure_custom_calc => $self->can('custom_provisioned_calc'), closure_custom_output => $self->can('custom_provisioned_output'), diff --git a/apps/vmware/connector/mode/datastorevm.pm b/apps/vmware/connector/mode/datastorevm.pm index bfbdfb042..48f3e30bf 100644 --- a/apps/vmware/connector/mode/datastorevm.pm +++ b/apps/vmware/connector/mode/datastorevm.pm @@ -67,7 +67,7 @@ sub set_counters { ]; $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' } ], output_template => 'max total latency is %s ms', perfdatas => [ @@ -79,7 +79,7 @@ sub set_counters { ]; $self->{maps_counters}->{datastore} = [ - { label => 'read', set => { + { label => 'read', nlabel => 'vm.datastore.read.usage.iops', set => { key_values => [ { name => 'read' } ], output_template => '%s read iops', perfdatas => [ @@ -88,7 +88,7 @@ sub set_counters { ], } }, - { label => 'write', set => { + { label => 'write', nlabel => 'vm.datastore.write.usage.iops', set => { key_values => [ { name => 'write' } ], output_template => '%s write iops', perfdatas => [ diff --git a/apps/vmware/connector/mode/devicevm.pm b/apps/vmware/connector/mode/devicevm.pm index d8c122364..15f7ef15b 100644 --- a/apps/vmware/connector/mode/devicevm.pm +++ b/apps/vmware/connector/mode/devicevm.pm @@ -57,7 +57,7 @@ sub set_counters { ]; $self->{maps_counters}->{global} = [ - { label => 'total-device-connected', set => { + { label => 'total-device-connected', nlabel => 'vm.devices.connected.count', set => { key_values => [ { name => 'device_connected' } ], closure_custom_output => $self->can('custom_device_output'), perfdatas => [ @@ -77,7 +77,7 @@ sub set_counters { 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' } ], oclosure_custom_output => $self->can('custom_device_output'), perfdatas => [ diff --git a/apps/vmware/connector/mode/healthhost.pm b/apps/vmware/connector/mode/healthhost.pm index 86c74deab..3a1258136 100644 --- a/apps/vmware/connector/mode/healthhost.pm +++ b/apps/vmware/connector/mode/healthhost.pm @@ -67,7 +67,7 @@ sub set_counters { ]; $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' } ], output_template => '%s total health issue(s) found', perfdatas => [ @@ -96,7 +96,7 @@ sub set_counters { 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' } ], output_template => '%s total health issue(s) found', 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' } ], output_template => '%s yellow health issue(s) found', 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' } ], output_template => '%s red health issue(s) found', perfdatas => [ diff --git a/apps/vmware/connector/mode/limitvm.pm b/apps/vmware/connector/mode/limitvm.pm index 708795867..dce27d214 100644 --- a/apps/vmware/connector/mode/limitvm.pm +++ b/apps/vmware/connector/mode/limitvm.pm @@ -55,13 +55,13 @@ sub set_counters { my ($self, %options) = @_; $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 } } ] }, - { 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 } } ] }, - { 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 } } ] }, ]; diff --git a/apps/vmware/connector/mode/memoryhost.pm b/apps/vmware/connector/mode/memoryhost.pm index f554f53b5..ef3858c41 100644 --- a/apps/vmware/connector/mode/memoryhost.pm +++ b/apps/vmware/connector/mode/memoryhost.pm @@ -43,25 +43,30 @@ sub custom_status_calc { sub custom_usage_perfdata { my ($self, %options) = @_; - my $label = 'used'; + my ($label, $nlabel) = ('used', $self->{label}); my $value_perf = $self->{result_values}->{used}; if (defined($self->{instance_mode}->{option_results}->{free})) { - $label = 'free'; + ($label, $nlabel) = ('free', 'host.memory.free.bytes'); $value_perf = $self->{result_values}->{free}; } 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 = (); if ($self->{instance_mode}->{option_results}->{units} eq '%') { $total_options{total} = $self->{result_values}->{total}; $total_options{cast_int} = 1; } - $self->{output}->perfdata_add(label => $label . $extra_label, unit => 'B', - value => $value_perf, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, %total_options), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, %total_options), - min => 0, max => $self->{result_values}->{total}); + $self->{output}->perfdata_add( + label => $label, unit => 'B', + instances => $extra_label, + nlabel => $nlabel, + 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 { @@ -74,7 +79,7 @@ sub custom_usage_threshold { $threshold_value = $self->{result_values}->{prct_used}; $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; } @@ -142,7 +147,7 @@ sub set_counters { 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' } ], closure_custom_calc => $self->can('custom_usage_calc'), closure_custom_output => $self->can('custom_usage_output'), @@ -150,7 +155,7 @@ sub set_counters { 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' } ], closure_custom_output => $self->can('custom_overhead_output'), 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' } ], closure_custom_output => $self->can('custom_memstate_output'), perfdatas => [ diff --git a/apps/vmware/connector/mode/memoryvm.pm b/apps/vmware/connector/mode/memoryvm.pm index 15f559cb5..e5b6d8d53 100644 --- a/apps/vmware/connector/mode/memoryvm.pm +++ b/apps/vmware/connector/mode/memoryvm.pm @@ -44,25 +44,30 @@ sub custom_status_calc { sub custom_usage_perfdata { my ($self, %options) = @_; - my $label = $self->{label} . '_used'; + my ($label, $nlabel) = ('used', $self->{label}); my $value_perf = $self->{result_values}->{used}; 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}; } 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 = (); if ($self->{instance_mode}->{option_results}->{units} eq '%') { $total_options{total} = $self->{result_values}->{total}; $total_options{cast_int} = 1; } - $self->{output}->perfdata_add(label => $label . $extra_label, unit => 'B', - value => $value_perf, - warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, %total_options), - critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, %total_options), - min => 0, max => $self->{result_values}->{total}); + $self->{output}->perfdata_add( + label => $label, unit => 'B', + instances => $extra_label, + nlabel => $nlabel, + 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 { @@ -75,7 +80,7 @@ sub custom_usage_threshold { $threshold_value = $self->{result_values}->{prct_used}; $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; } @@ -165,7 +170,7 @@ sub set_counters { ]; $self->{maps_counters}->{global_consumed} = [ - { label => 'consumed', set => { + { label => 'consumed', nlabel => 'vm.memory.usage.bytes', set => { key_values => [ { name => 'consumed' }, { name => 'total' } ], closure_custom_calc => $self->can('custom_usage_calc'), closure_custom_calc_extra_options => { label_ref => 'consumed' }, closure_custom_output => $self->can('custom_usage_output'), @@ -175,7 +180,7 @@ sub set_counters { }, ]; $self->{maps_counters}->{global_active} = [ - { label => 'active', set => { + { label => 'active', nlabel => 'vm.memory.active.bytes', set => { key_values => [ { name => 'active' }, { name => 'total' } ], closure_custom_calc => $self->can('custom_usage_calc'), closure_custom_calc_extra_options => { label_ref => 'active' }, closure_custom_output => $self->can('custom_usage_output'), @@ -185,7 +190,7 @@ sub set_counters { }, ]; $self->{maps_counters}->{global_overhead} = [ - { label => 'overhead', set => { + { label => 'overhead', nlabel => 'vm.memory.overhead.bytes', set => { key_values => [ { name => 'overhead' } ], closure_custom_output => $self->can('custom_overhead_output'), perfdatas => [ @@ -196,7 +201,7 @@ sub set_counters { }, ]; $self->{maps_counters}->{global_vmmemctl} = [ - { label => 'ballooning', set => { + { label => 'ballooning', nlabel => 'vm.memory.ballooning.bytes', set => { key_values => [ { name => 'vmmemctl' } ], closure_custom_output => $self->can('custom_ballooning_output'), perfdatas => [ @@ -207,7 +212,7 @@ sub set_counters { }, ]; $self->{maps_counters}->{global_shared} = [ - { label => 'shared', set => { + { label => 'shared', nlabel => 'vm.memory.shared.bytes', set => { key_values => [ { name => 'shared' } ], closure_custom_output => $self->can('custom_shared_output'), perfdatas => [ diff --git a/apps/vmware/connector/mode/nethost.pm b/apps/vmware/connector/mode/nethost.pm index 451734f0b..d3ba0e983 100644 --- a/apps/vmware/connector/mode/nethost.pm +++ b/apps/vmware/connector/mode/nethost.pm @@ -126,7 +126,7 @@ sub set_counters { ]; $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' } ], output_template => 'host traffic in : %s %s/s', 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' } ], output_template => 'host traffic out : %s %s/s', output_change_bytes => 2, @@ -149,7 +149,7 @@ sub set_counters { ]; $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' } ], output_template => 'traffic in : %s %s/s', 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' } ], output_template => 'traffic out : %s %s/s', output_change_bytes => 2, @@ -180,7 +180,7 @@ sub set_counters { 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' } ], closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'in' }, 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' } ], closure_custom_calc => $self->can('custom_traffic_calc'), closure_custom_calc_extra_options => { label_ref => 'out' }, 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' } ], closure_custom_calc => $self->can('custom_dropped_calc'), closure_custom_calc_extra_options => { label_ref => 'in' }, 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' } ], closure_custom_calc => $self->can('custom_dropped_calc'), closure_custom_calc_extra_options => { label_ref => 'out' }, closure_custom_output => $self->can('custom_dropped_output'), diff --git a/apps/vmware/connector/mode/snapshotvm.pm b/apps/vmware/connector/mode/snapshotvm.pm index 79ff5efb6..460058990 100644 --- a/apps/vmware/connector/mode/snapshotvm.pm +++ b/apps/vmware/connector/mode/snapshotvm.pm @@ -138,12 +138,18 @@ sub run { } } - $self->{output}->perfdata_add(label => 'num_warning', - value => scalar(keys %{$vm_errors{warning}}), - min => 0); - $self->{output}->perfdata_add(label => 'num_critical', - value => scalar(keys %{$vm_errors{critical}}), - min => 0); + $self->{output}->perfdata_add( + label => 'num_warning', + nlabel => 'vm.snapshots.warning.current.count', + value => scalar(keys %{$vm_errors{warning}}), + 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) { $self->{output}->output_add(severity => 'WARNING', short_msg => sprintf('Snapshots for VM older than %d days: [%s]', ($self->{option_results}->{warning} / 86400), diff --git a/apps/vmware/connector/mode/statconnectors.pm b/apps/vmware/connector/mode/statconnectors.pm index 4646e8de0..dc3f57d7a 100644 --- a/apps/vmware/connector/mode/statconnectors.pm +++ b/apps/vmware/connector/mode/statconnectors.pm @@ -35,7 +35,7 @@ sub set_counters { ]; $self->{maps_counters}->{global} = [ - { label => 'total-requests', set => { + { label => 'total-requests', nlabel => 'connector.requests.total.count', set => { key_values => [ { name => 'requests', diff => 1 } ], output_template => 'Total %s requests', perfdatas => [ @@ -47,7 +47,7 @@ sub set_counters { ]; $self->{maps_counters}->{container} = [ - { label => 'requests', set => { + { label => 'requests', nlabel => 'connector.requests.total.count', set => { key_values => [ { name => 'requests', diff => 1 } ], output_template => '%s requests', perfdatas => [ @@ -71,9 +71,9 @@ sub new { bless $self, $class; $self->{version} = '1.0'; - $options{options}->add_options(arguments => - { - }); + $options{options}->add_options(arguments => { + }); + return $self; } diff --git a/apps/vmware/connector/mode/swaphost.pm b/apps/vmware/connector/mode/swaphost.pm index a66014e42..514b1ea59 100644 --- a/apps/vmware/connector/mode/swaphost.pm +++ b/apps/vmware/connector/mode/swaphost.pm @@ -56,7 +56,7 @@ sub set_counters { 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' } ], output_template => 'Swap In: %s %s/s', 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' } ], output_template => 'Swap Out: %s %s/s', output_change_bytes => 1, diff --git a/apps/vmware/connector/mode/swapvm.pm b/apps/vmware/connector/mode/swapvm.pm index ef2cac981..deb149b3d 100644 --- a/apps/vmware/connector/mode/swapvm.pm +++ b/apps/vmware/connector/mode/swapvm.pm @@ -57,7 +57,7 @@ sub set_counters { 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' } ], output_template => 'Swap In: %s %s/s', 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' } ], output_template => 'Swap Out: %s %s/s', output_change_bytes => 1, diff --git a/apps/vmware/connector/mode/timehost.pm b/apps/vmware/connector/mode/timehost.pm index 03337558b..4aa4852f5 100644 --- a/apps/vmware/connector/mode/timehost.pm +++ b/apps/vmware/connector/mode/timehost.pm @@ -65,7 +65,7 @@ sub set_counters { 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' } ], closure_custom_output => $self->can('custom_time_output'), perfdatas => [ diff --git a/apps/vmware/connector/mode/toolsvm.pm b/apps/vmware/connector/mode/toolsvm.pm index 217d13a7e..35293769a 100644 --- a/apps/vmware/connector/mode/toolsvm.pm +++ b/apps/vmware/connector/mode/toolsvm.pm @@ -156,15 +156,24 @@ sub run { if ($multiple == 1) { my $total = scalar(keys %not_up2date) + scalar(keys %not_running) + scalar(keys %not_installed); - $self->{output}->perfdata_add(label => 'not_updated', - value => scalar(keys %not_up2date), - min => 0, max => $total); - $self->{output}->perfdata_add(label => 'not_running', - value => scalar(keys %not_running), - min => 0, max => $total); - $self->{output}->perfdata_add(label => 'not_installed', - value => scalar(keys %not_installed), - min => 0, max => $total); + $self->{output}->perfdata_add( + label => 'not_updated', + nlabel => 'vm.tools.notupdated.current.count', + value => scalar(keys %not_up2date), + min => 0, max => $total + ); + $self->{output}->perfdata_add( + label => 'not_running', + 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(); diff --git a/apps/vmware/connector/mode/uptimehost.pm b/apps/vmware/connector/mode/uptimehost.pm index e0d38d82b..afaedfbf1 100644 --- a/apps/vmware/connector/mode/uptimehost.pm +++ b/apps/vmware/connector/mode/uptimehost.pm @@ -65,7 +65,7 @@ sub set_counters { 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' } ], closure_custom_output => $self->can('custom_time_output'), perfdatas => [ diff --git a/apps/vmware/connector/mode/vmoperationcluster.pm b/apps/vmware/connector/mode/vmoperationcluster.pm index 6e1c5c149..05e620968 100644 --- a/apps/vmware/connector/mode/vmoperationcluster.pm +++ b/apps/vmware/connector/mode/vmoperationcluster.pm @@ -34,7 +34,7 @@ sub set_counters { ]; $self->{maps_counters}->{cluster} = [ - { label => 'svmotion', set => { + { label => 'svmotion', nlabel => 'cluster.operations.svmotion.current.count', set => { key_values => [ { name => 'numSVMotion', diff => 1 }, { name => 'display' } ], output_template => 'SVMotion %s', 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' } ], output_template => 'VMotion %s', 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' } ], output_template => 'Clone %s', perfdatas => [ diff --git a/centreon/plugins/templates/counter.pm b/centreon/plugins/templates/counter.pm index a76c6b085..845cae685 100644 --- a/centreon/plugins/templates/counter.pm +++ b/centreon/plugins/templates/counter.pm @@ -79,6 +79,30 @@ sub call_object_callback { 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 { my ($class, %options) = @_; my $self = $class->SUPER::new(package => __PACKAGE__, %options); @@ -102,8 +126,11 @@ sub new { foreach my $key (keys %{$self->{maps_counters}}) { foreach (@{$self->{maps_counters}->{$key}}) { my $label = $_->{label}; - $label = $_->{nlabel} if ($self->{output}->use_new_perfdata() && defined($_->{nlabel})); my $thlabel = $label; + if ($self->{output}->use_new_perfdata() && defined($_->{nlabel})) { + $label = $_->{nlabel}; + $thlabel = $self->get_threshold_prefix(name => $key) . $label; + } $thlabel =~ s/\./-/g; if (!defined($_->{threshold}) || $_->{threshold} != 0) { @@ -125,7 +152,7 @@ sub new { $_->{obj}->set(%{$_->{set}}); } } - + return $self; } @@ -385,9 +412,13 @@ sub run_group { } 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}, - value => $total_problems, - min => $options{config}->{display_counter_problem}->{min}, max => $options{config}->{display_counter_problem}->{max}); + $self->{output}->perfdata_add( + label => $options{config}->{display_counter_problem}->{label}, + 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} + ); } }