enhance template counter (#1167)
* enh template counter, adapt modes not using the template * rollback problems for type 2
This commit is contained in:
parent
83050b55b9
commit
a10c543b8a
|
@ -41,7 +41,7 @@ my $thresholds = {
|
|||
my $instance_mode;
|
||||
|
||||
my $maps_counters = {
|
||||
runtime => {
|
||||
runtime => {
|
||||
'000_status' => { set => {
|
||||
key_values => [ { name => 'health_state' } ],
|
||||
closure_custom_calc => \&custom_status_calc,
|
||||
|
@ -51,7 +51,7 @@ my $maps_counters = {
|
|||
closure_custom_threshold_check => \&custom_threshold_output,
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
'001_request-completed' => { set => {
|
||||
key_values => [ { name => 'completed', diff => 1 }, { name => 'runtime' } ],
|
||||
output_template => 'Requests completed : %s',
|
||||
|
@ -78,19 +78,19 @@ my $maps_counters = {
|
|||
min => 0, label_extra_instance => 1, instance_use => 'runtime_absolute' },
|
||||
],
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
sub custom_threshold_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
||||
return $instance_mode->get_severity(section => 'health', value => $self->{result_values}->{health_state});
|
||||
}
|
||||
|
||||
sub custom_status_calc {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
||||
$self->{result_values}->{health_state} = $options{new_datas}->{$self->{instance} . '_health_state'};
|
||||
return 0;
|
||||
}
|
||||
|
@ -99,17 +99,17 @@ sub new {
|
|||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options);
|
||||
bless $self, $class;
|
||||
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
{
|
||||
"filter-application:s" => { name => 'filter_application' },
|
||||
"filter-name:s" => { name => 'filter_name' },
|
||||
"filter-runtime:s" => { name => 'filter_runtime' },
|
||||
"threshold-overload:s@" => { name => 'threshold_overload' },
|
||||
});
|
||||
$self->{statefile_value} = centreon::plugins::statefile->new(%options);
|
||||
|
||||
|
||||
foreach my $key (('runtime')) {
|
||||
foreach (keys %{$maps_counters->{$key}}) {
|
||||
my ($id, $name) = split /_/;
|
||||
|
@ -126,23 +126,23 @@ sub new {
|
|||
$maps_counters->{$key}->{$_}->{obj}->set(%{$maps_counters->{$key}->{$_}->{set}});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
sub check_options {
|
||||
my ($self, %options) = @_;
|
||||
$self->SUPER::init(%options);
|
||||
|
||||
|
||||
foreach my $key (('runtime')) {
|
||||
foreach (keys %{$maps_counters->{$key}}) {
|
||||
$maps_counters->{$key}->{$_}->{obj}->init(option_results => $self->{option_results});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$self->{statefile_value}->check_options(%options);
|
||||
$instance_mode = $self;
|
||||
|
||||
|
||||
$self->{overload_th} = {};
|
||||
foreach my $val (@{$self->{option_results}->{threshold_overload}}) {
|
||||
if ($val !~ /^(.*?),(.*?),(.*)$/) {
|
||||
|
@ -162,19 +162,19 @@ sub check_options {
|
|||
sub run {
|
||||
my ($self, %options) = @_;
|
||||
$self->{connector} = $options{custom};
|
||||
|
||||
|
||||
$self->manage_selection();
|
||||
|
||||
|
||||
my $multiple = 1;
|
||||
if (scalar(keys %{$self->{runtime}}) == 1) {
|
||||
$multiple = 0;
|
||||
}
|
||||
|
||||
|
||||
if ($multiple == 1) {
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => 'All WorkerManagers are ok');
|
||||
}
|
||||
|
||||
|
||||
my $matching = '';
|
||||
foreach (('filter_application', 'filter_name', 'filter_runtime')) {
|
||||
$matching .= defined($self->{option_results}->{$_}) ? $self->{option_results}->{$_} : 'all';
|
||||
|
@ -182,14 +182,14 @@ sub run {
|
|||
$self->{new_datas} = {};
|
||||
$self->{statefile_value}->read(statefile => "weblogic_" . $self->{mode} . '_' . md5_hex($self->{connector}->{url}) . '_' . md5_hex($matching));
|
||||
$self->{new_datas}->{last_timestamp} = time();
|
||||
|
||||
foreach my $id (sort keys %{$self->{runtime}}) {
|
||||
|
||||
foreach my $id (sort keys %{$self->{runtime}}) {
|
||||
my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', '');
|
||||
my @exits = ();
|
||||
foreach (sort keys %{$maps_counters->{runtime}}) {
|
||||
my $obj = $maps_counters->{runtime}->{$_}->{obj};
|
||||
$obj->set(instance => $id);
|
||||
|
||||
|
||||
my ($value_check) = $obj->execute(values => $self->{runtime}->{$id},
|
||||
new_datas => $self->{new_datas});
|
||||
|
||||
|
@ -204,13 +204,13 @@ sub run {
|
|||
my $output = $obj->output();
|
||||
$long_msg .= $long_msg_append . $output;
|
||||
$long_msg_append = ', ';
|
||||
|
||||
|
||||
if (!$self->{output}->is_status(litteral => 1, value => $exit2, compare => 'ok')) {
|
||||
$short_msg .= $short_msg_append . $output;
|
||||
$short_msg_append = ', ';
|
||||
}
|
||||
|
||||
$obj->perfdata(extra_instance => $multiple);
|
||||
|
||||
$obj->perfdata(level => 1, extra_instance => $multiple);
|
||||
}
|
||||
|
||||
$self->{output}->output_add(long_msg => "WorkerManager '$id' $long_msg");
|
||||
|
@ -220,7 +220,7 @@ sub run {
|
|||
short_msg => "WorkerManager '$id' $short_msg"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if ($multiple == 0) {
|
||||
$self->{output}->output_add(short_msg => "WorkerManager '$id' $long_msg");
|
||||
}
|
||||
|
@ -233,23 +233,23 @@ sub run {
|
|||
|
||||
sub get_severity {
|
||||
my ($self, %options) = @_;
|
||||
my $status = 'UNKNOWN'; # default
|
||||
|
||||
my $status = 'UNKNOWN'; # default
|
||||
|
||||
if (defined($self->{overload_th}->{$options{section}})) {
|
||||
foreach (@{$self->{overload_th}->{$options{section}}}) {
|
||||
foreach (@{$self->{overload_th}->{$options{section}}}) {
|
||||
if ($options{value} =~ /$_->{filter}/i) {
|
||||
$status = $_->{status};
|
||||
return $status;
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (@{$thresholds->{$options{section}}}) {
|
||||
foreach (@{$thresholds->{$options{section}}}) {
|
||||
if ($options{value} =~ /$$_[0]/i) {
|
||||
$status = $$_[1];
|
||||
return $status;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $status;
|
||||
}
|
||||
|
||||
|
@ -266,18 +266,18 @@ sub manage_selection {
|
|||
my ($self, %options) = @_;
|
||||
|
||||
$self->{request} = [
|
||||
{ mbean => 'com.bea:ApplicationRuntime=*,Name=*,ServerRuntime=*,Type=WorkManagerRuntime',
|
||||
{ mbean => 'com.bea:ApplicationRuntime=*,Name=*,ServerRuntime=*,Type=WorkManagerRuntime',
|
||||
attributes => [ { name => 'HealthState' }, { name => 'StuckThreadCount' }, { name => 'CompletedRequests' }, { name => 'PendingRequests' } ] }
|
||||
];
|
||||
my $result = $self->{connector}->get_attributes(request => $self->{request}, nothing_quit => 1);
|
||||
|
||||
|
||||
$self->{runtime} = {};
|
||||
foreach my $mbean (keys %{$result}) {
|
||||
foreach my $mbean (keys %{$result}) {
|
||||
next if ($mbean !~ /ApplicationRuntime=(.*?),Name=(.*?),ServerRuntime=(.*?),/);
|
||||
my ($app, $name, $runtime) = ($1, $2, $3);
|
||||
my $health_state = defined($map_state{$result->{$mbean}->{HealthState}->{state}}) ?
|
||||
my $health_state = defined($map_state{$result->{$mbean}->{HealthState}->{state}}) ?
|
||||
$map_state{$result->{$mbean}->{HealthState}->{state}} : 'unknown';
|
||||
|
||||
|
||||
if (defined($self->{option_results}->{filter_application}) && $self->{option_results}->{filter_application} ne '' &&
|
||||
$app !~ /$self->{option_results}->{filter_application}/) {
|
||||
$self->{output}->output_add(long_msg => "Skipping '" . $app . "': no matching filter application.");
|
||||
|
@ -293,11 +293,11 @@ sub manage_selection {
|
|||
$self->{output}->output_add(long_msg => "Skipping '" . $runtime . "': no matching filter runtime.");
|
||||
next;
|
||||
}
|
||||
|
||||
|
||||
$self->{runtime}->{$app . '/' . $name . '/' . $runtime} = { health_state => $health_state, runtime => $app . '/' . $name . '/' . $runtime,
|
||||
completed => $result->{$mbean}->{CompletedRequests}, pending => $result->{$mbean}->{PendingRequests}, stuck => $result->{$mbean}->{StuckThreadCount} };
|
||||
}
|
||||
|
||||
|
||||
if (scalar(keys %{$self->{runtime}}) <= 0) {
|
||||
$self->{output}->add_option_msg(short_msg => "No entry found.");
|
||||
$self->{output}->option_exit();
|
||||
|
@ -345,3 +345,4 @@ Example: --threshold-overload='health,CRITICAL,^(?!(HEALTH_OK)$)'
|
|||
=back
|
||||
|
||||
=cut
|
||||
|
||||
|
|
|
@ -210,7 +210,7 @@ sub run {
|
|||
$short_msg_append = ', ';
|
||||
}
|
||||
|
||||
$maps_counters->{ap}->{$_}->{obj}->perfdata(extra_instance => $multiple);
|
||||
$maps_counters->{ap}->{$_}->{obj}->perfdata(level => 1, extra_instance => $multiple);
|
||||
}
|
||||
|
||||
$self->{output}->output_add(long_msg => "AP [bssid: '$self->{ap}->{$id}->{bssid}', essid: $self->{ap}->{$id}->{apESSID}, ip: $self->{ap}->{$id}->{apIpAddress}] Usage $long_msg");
|
||||
|
|
|
@ -162,7 +162,7 @@ sub run {
|
|||
$short_msg_append = ', ';
|
||||
}
|
||||
|
||||
$obj->perfdata(extra_instance => $multiple);
|
||||
$obj->perfdata(level => 1, extra_instance => $multiple);
|
||||
}
|
||||
|
||||
$self->{output}->output_add(long_msg => "Partition '" . $self->{memory_selected}->{$id}->{display} . "' $long_msg");
|
||||
|
|
|
@ -142,7 +142,7 @@ sub run_instances {
|
|||
$short_msg_append = ', ';
|
||||
}
|
||||
|
||||
$obj->perfdata(extra_instance => $multiple);
|
||||
$obj->perfdata(level => 1, extra_instance => $multiple);
|
||||
}
|
||||
|
||||
my $prefix = "CPU Usage ";
|
||||
|
|
|
@ -122,7 +122,7 @@ sub run_instances {
|
|||
$short_msg_append = ', ';
|
||||
}
|
||||
|
||||
$obj->perfdata(extra_instance => $multiple);
|
||||
$obj->perfdata(level => 1, extra_instance => $multiple);
|
||||
}
|
||||
|
||||
my $prefix = "Memory Usage ";
|
||||
|
|
|
@ -200,7 +200,7 @@ sub run {
|
|||
$short_msg_append = ', ';
|
||||
}
|
||||
|
||||
$maps_counters->{$_}->{obj}->perfdata(extra_instance => $multiple);
|
||||
$maps_counters->{$_}->{obj}->perfdata(level => 1, extra_instance => $multiple);
|
||||
}
|
||||
|
||||
$self->{output}->output_add(long_msg => "Domain '" . $self->{domain_selected}->{$id}->{display} . "' $long_msg");
|
||||
|
|
|
@ -99,7 +99,7 @@ sub new {
|
|||
foreach (@{$self->{maps_counters}->{$key}}) {
|
||||
if (!defined($_->{threshold}) || $_->{threshold} != 0) {
|
||||
$options{options}->add_options(arguments => {
|
||||
'warning-' . $_->{label} . ':s' => { name => 'warning-' . $_->{label} },
|
||||
'warning-' . $_->{label} . ':s' => { name => 'warning-' . $_->{label} },
|
||||
'critical-' . $_->{label} . ':s' => { name => 'critical-' . $_->{label} },
|
||||
});
|
||||
}
|
||||
|
@ -144,57 +144,71 @@ sub run_global {
|
|||
|
||||
return undef if (defined($options{config}->{cb_init}) && $self->call_object_callback(method_name => $options{config}->{cb_init}) == 1);
|
||||
|
||||
my $message_separator = defined($options{config}->{message_separator}) ?
|
||||
$options{config}->{message_separator}: ', ';
|
||||
my $message_separator = defined($options{config}->{message_separator}) ? $options{config}->{message_separator} : ', ';
|
||||
my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', '');
|
||||
my @exits;
|
||||
|
||||
my $multiple = 0;
|
||||
|
||||
foreach (@{$self->{maps_counters}->{$options{config}->{name}}}) {
|
||||
my $obj = $_->{obj};
|
||||
|
||||
next if (defined($self->{option_results}->{filter_counters}) && $self->{option_results}->{filter_counters} ne '' &&
|
||||
$_->{label} !~ /$self->{option_results}->{filter_counters}/);
|
||||
|
||||
$obj->set(instance => $options{config}->{name});
|
||||
my $value_check;
|
||||
if (defined($options{instance}) && $options{instance} ne '') {
|
||||
$obj->set(instance => $options{instance});
|
||||
if (scalar(keys %{$self->{$options{counter_name}}}) > 1) {
|
||||
$multiple = 1;
|
||||
}
|
||||
$value_check = $obj->execute(new_datas => $self->{new_datas}, values => $self->{$options{counter_name}}->{$options{instance}}->{$options{config}->{name}});
|
||||
} else {
|
||||
$obj->set(instance => $options{config}->{name});
|
||||
$value_check = $obj->execute(new_datas => $self->{new_datas}, values => $self->{$options{config}->{name}});
|
||||
}
|
||||
|
||||
my ($value_check) = $obj->execute(new_datas => $self->{new_datas}, values => $self->{$options{config}->{name}});
|
||||
|
||||
next if (defined($options{config}->{skipped_code}) && defined($options{config}->{skipped_code}->{$value_check}));
|
||||
if ($value_check != 0) {
|
||||
$long_msg .= $long_msg_append . $obj->output_error();
|
||||
$long_msg_append = $message_separator;
|
||||
next;
|
||||
}
|
||||
my $exit2 = $obj->threshold_check();
|
||||
push @exits, $exit2;
|
||||
my $exit = $obj->threshold_check();
|
||||
push @exits, $exit;
|
||||
|
||||
my $output = $obj->output();
|
||||
$long_msg .= $long_msg_append . $output;
|
||||
$long_msg_append = $message_separator;
|
||||
|
||||
if (!$self->{output}->is_status(litteral => 1, value => $exit2, compare => 'ok')) {
|
||||
if (!$self->{output}->is_status(litteral => 1, value => $exit, compare => 'ok')) {
|
||||
$short_msg .= $short_msg_append . $output;
|
||||
$short_msg_append = $message_separator;
|
||||
}
|
||||
|
||||
$obj->perfdata();
|
||||
$obj->perfdata(level => 1, extra_instance => $multiple);
|
||||
}
|
||||
|
||||
my ($prefix_output, $suffix_output);
|
||||
$prefix_output = $self->call_object_callback(method_name => $options{config}->{cb_prefix_output})
|
||||
if (defined($options{config}->{cb_prefix_output}));
|
||||
$prefix_output = '' if (!defined($prefix_output));
|
||||
|
||||
$suffix_output = $self->call_object_callback(method_name => $options{config}->{cb_suffix_output})
|
||||
if (defined($options{config}->{cb_suffix_output}));
|
||||
my ($prefix_output, $suffix_output);
|
||||
if (defined($options{config}->{cb_prefix_output})) {
|
||||
if (defined($options{instance}) && $options{instance} ne '') {
|
||||
$prefix_output = $self->call_object_callback(method_name => $options{config}->{cb_prefix_output},
|
||||
instance_value => $self->{$options{counter_name}}->{$options{instance}});
|
||||
} else {
|
||||
$prefix_output = $self->call_object_callback(method_name => $options{config}->{cb_prefix_output}) if (defined($options{config}->{cb_prefix_output}));
|
||||
}
|
||||
}
|
||||
$prefix_output = '' if (!defined($prefix_output));
|
||||
$suffix_output = $self->call_object_callback(method_name => $options{config}->{cb_suffix_output}) if (defined($options{config}->{cb_suffix_output}));
|
||||
$suffix_output = '' if (!defined($suffix_output));
|
||||
|
||||
my $exit = $self->{output}->get_most_critical(status => [ @exits ]);
|
||||
if (!$self->{output}->is_status(litteral => 1, value => $exit, compare => 'ok')) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => "${prefix_output}${short_msg}${suffix_output}"
|
||||
short_msg => $prefix_output . $short_msg . $suffix_output
|
||||
);
|
||||
} else {
|
||||
$self->{output}->output_add(short_msg => "${prefix_output}${long_msg}${suffix_output}") if ($long_msg ne '');
|
||||
$self->{output}->output_add(short_msg => $prefix_output . $long_msg . $suffix_output) if ($long_msg ne '' && $multiple == 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -202,71 +216,89 @@ sub run_instances {
|
|||
my ($self, %options) = @_;
|
||||
|
||||
return undef if (defined($options{config}->{cb_init}) && $self->call_object_callback(method_name => $options{config}->{cb_init}) == 1);
|
||||
my $display_status_lo = defined($options{display_status_long_output}) && $options{display_status_long_output} == 1 ? 1 : 0;
|
||||
|
||||
my $message_separator = defined($options{config}->{message_separator}) ? $options{config}->{message_separator} : ', ';
|
||||
my $display_status_long_output = defined($options{display_status_long_output}) && $options{display_status_long_output} == 1 ? 1 : 0;
|
||||
my $resume = defined($options{resume}) && $options{resume} == 1 ? 1 : 0;
|
||||
|
||||
$self->{lproblems} = 0;
|
||||
$self->{multiple} = 1;
|
||||
if (scalar(keys %{$self->{$options{config}->{name}}}) == 1) {
|
||||
$self->{multiple} = 0;
|
||||
$self->{problems} = 0;
|
||||
my $level = 1;
|
||||
my $multiple_lvl2 = 0;
|
||||
my $instances = $self->{$options{config}->{name}};
|
||||
|
||||
if (defined($options{instance}) && $options{instance} ne '') {
|
||||
$level = 2;
|
||||
if (scalar(keys %{$self->{$options{counter_name}}->{$options{instance}}->{$options{config}->{name}}}) > 1) {
|
||||
$multiple_lvl2 = 1;
|
||||
}
|
||||
$instances = $self->{$options{counter_name}}->{$options{instance}}->{$options{config}->{name}};
|
||||
} else {
|
||||
$self->{multiple_lvl1} = 0;
|
||||
if (scalar(keys %{$self->{$options{config}->{name}}}) > 1) {
|
||||
$self->{multiple_lvl1} = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if ($self->{multiple} == 1 && $resume == 0) {
|
||||
if ($self->{multiple_lvl1} > 0 && $resume == 0) {
|
||||
$self->{output}->output_add(severity => 'OK',
|
||||
short_msg => $options{config}->{message_multiple});
|
||||
}
|
||||
|
||||
my $message_separator = defined($options{config}->{message_separator}) ?
|
||||
$options{config}->{message_separator}: ', ';
|
||||
foreach my $id (sort keys %{$self->{$options{config}->{name}}}) {
|
||||
|
||||
foreach my $instance (sort keys %{$instances}) {
|
||||
my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', '');
|
||||
my @exits = ();
|
||||
my @exits;
|
||||
foreach (@{$self->{maps_counters}->{$options{config}->{name}}}) {
|
||||
my $obj = $_->{obj};
|
||||
|
||||
next if (defined($self->{option_results}->{filter_counters}) && $self->{option_results}->{filter_counters} ne '' &&
|
||||
$_->{label} !~ /$self->{option_results}->{filter_counters}/);
|
||||
|
||||
$obj->set(instance => $id);
|
||||
$obj->set(instance => $instance);
|
||||
|
||||
if (defined($options{instance}) && $options{instance} ne '') {
|
||||
$obj->set(instance => $options{instance} . '_' . $instance);
|
||||
}
|
||||
|
||||
my ($value_check) = $obj->execute(new_datas => $self->{new_datas},
|
||||
values => $self->{$options{config}->{name}}->{$id});
|
||||
my $value_check = $obj->execute(new_datas => $self->{new_datas}, values => $instances->{$instance});
|
||||
next if (defined($options{config}->{skipped_code}) && defined($options{config}->{skipped_code}->{$value_check}));
|
||||
if ($value_check != 0) {
|
||||
$long_msg .= $long_msg_append . $obj->output_error();
|
||||
$long_msg_append = $message_separator;
|
||||
next;
|
||||
}
|
||||
my $exit2 = $obj->threshold_check();
|
||||
push @exits, $exit2;
|
||||
my $exit = $obj->threshold_check();
|
||||
push @exits, $exit;
|
||||
|
||||
my $output = $obj->output();
|
||||
$long_msg .= $long_msg_append . $output;
|
||||
$long_msg_append = $message_separator;
|
||||
|
||||
if (!$self->{output}->is_status(litteral => 1, value => $exit2, compare => 'ok')) {
|
||||
$self->{lproblems}++;
|
||||
if (!$self->{output}->is_status(litteral => 1, value => $exit, compare => 'ok')) {
|
||||
$self->{problems}++;
|
||||
$short_msg .= $short_msg_append . $output;
|
||||
$short_msg_append = $message_separator;
|
||||
}
|
||||
|
||||
$obj->perfdata(extra_instance => $self->{multiple});
|
||||
$obj->perfdata(level => $level, extra_instance => $self->{multiple_lvl1}, extra_instance_lvl2 => $multiple_lvl2);
|
||||
}
|
||||
|
||||
my ($prefix_output, $suffix_output);
|
||||
$prefix_output = $self->call_object_callback(method_name => $options{config}->{cb_prefix_output}, instance_value => $self->{$options{config}->{name}}->{$id})
|
||||
if (defined($options{config}->{cb_prefix_output}));
|
||||
$prefix_output = '' if (!defined($prefix_output));
|
||||
|
||||
$suffix_output = $self->call_object_callback(method_name => $options{config}->{cb_suffix_output})
|
||||
if (defined($options{config}->{cb_suffix_output}));
|
||||
if (defined($options{config}->{cb_prefix_output})) {
|
||||
if (defined($options{instance}) && $options{instance} ne '') {
|
||||
$prefix_output = $self->call_object_callback(method_name => $options{config}->{cb_prefix_output},
|
||||
instance_value => $self->{$options{counter_name}}->{$options{instance}}->{$options{config}->{name}}->{$instance});
|
||||
} else {
|
||||
$prefix_output = $self->call_object_callback(method_name => $options{config}->{cb_prefix_output}, instance_value => $self->{$options{config}->{name}}->{$instance}) if (defined($options{config}->{cb_prefix_output}));
|
||||
}
|
||||
}
|
||||
$prefix_output = '' if (!defined($prefix_output));
|
||||
$suffix_output = $self->call_object_callback(method_name => $options{config}->{cb_suffix_output}) if (defined($options{config}->{cb_suffix_output}));
|
||||
$suffix_output = '' if (!defined($suffix_output));
|
||||
|
||||
my $exit = $self->{output}->get_most_critical(status => [ @exits ]);
|
||||
# in mode grouped, we don't display 'ok'
|
||||
my $debug = 0;
|
||||
$debug = 1 if ($display_status_lo == 1 && $self->{output}->is_status(value => $exit, compare => 'OK', litteral => 1));
|
||||
$self->{output}->output_add(long_msg => ($display_status_lo == 1 ? lc($exit) . ': ' : '') . "${prefix_output}${long_msg}${suffix_output}", debug => $debug);
|
||||
$debug = 1 if ($display_status_long_output == 1 && $self->{output}->is_status(value => $exit, compare => 'OK', litteral => 1));
|
||||
$self->{output}->output_add(long_msg => ($display_status_long_output == 1 ? lc($exit) . ': ' : '') . $prefix_output . $long_msg . $suffix_output, debug => $debug);
|
||||
if ($resume == 1) {
|
||||
$self->{most_critical_instance} = $self->{output}->get_most_critical(status => [ $self->{most_critical_instance}, $exit ]);
|
||||
next;
|
||||
|
@ -274,12 +306,22 @@ sub run_instances {
|
|||
|
||||
if (!$self->{output}->is_status(litteral => 1, value => $exit, compare => 'ok')) {
|
||||
$self->{output}->output_add(severity => $exit,
|
||||
short_msg => "${prefix_output}${short_msg}${suffix_output}"
|
||||
short_msg => $prefix_output . $short_msg . $suffix_output
|
||||
);
|
||||
}
|
||||
|
||||
if ($self->{multiple} == 0) {
|
||||
$self->{output}->output_add(short_msg => "${prefix_output}${long_msg}${suffix_output}");
|
||||
if ($self->{multiple_lvl1} == 0 && $multiple_lvl2 == 0) {
|
||||
$self->{output}->output_add(short_msg => $prefix_output . $long_msg . $suffix_output);
|
||||
}
|
||||
|
||||
if ($options{multi}) {
|
||||
foreach my $counter (@{$options{config}->{counters}}) {
|
||||
if ($counter->{type} == 0) {
|
||||
$self->run_global(config => $counter, counter_name => $options{config}->{name}, instance => $instance);
|
||||
} elsif ($counter->{type} == 1) {
|
||||
$self->run_instances(config => $counter, counter_name => $options{config}->{name}, instance => $instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -298,30 +340,30 @@ sub run_group {
|
|||
}
|
||||
|
||||
my ($global_exit, $total_problems) = ([], 0);
|
||||
foreach my $id (sort keys %{$self->{$options{config}->{name}}}) {
|
||||
foreach my $instance (sort keys %{$self->{$options{config}->{name}}}) {
|
||||
$self->{most_critical_instance} = 'ok';
|
||||
if (defined($options{config}->{cb_long_output})) {
|
||||
$self->{output}->output_add(long_msg => $self->call_object_callback(method_name => $options{config}->{cb_long_output},
|
||||
instance_value => $self->{$options{config}->{name}}->{$id}));
|
||||
instance_value => $self->{$options{config}->{name}}->{$instance}));
|
||||
}
|
||||
|
||||
foreach my $group (@{$options{config}->{group}}) {
|
||||
$self->{$group->{name}} = $self->{$options{config}->{name}}->{$id}->{$group->{name}};
|
||||
$self->{$group->{name}} = $self->{$options{config}->{name}}->{$instance}->{$group->{name}};
|
||||
|
||||
# we resume datas
|
||||
$self->run_instances(config => $group, display_status_long_output => 1, resume => 1);
|
||||
|
||||
push @{$global_exit}, $self->{most_critical_instance};
|
||||
$total_problems += $self->{lproblems};
|
||||
$total_problems += $self->{problems};
|
||||
|
||||
my $prefix_output;
|
||||
$prefix_output = $self->call_object_callback(method_name => $options{config}->{cb_prefix_output}, instance_value => $self->{$options{config}->{name}}->{$id})
|
||||
$prefix_output = $self->call_object_callback(method_name => $options{config}->{cb_prefix_output}, instance_value => $self->{$options{config}->{name}}->{$instance})
|
||||
if (defined($options{config}->{cb_prefix_output}));
|
||||
$prefix_output = '' if (!defined($prefix_output));
|
||||
|
||||
if ($multiple == 0) {
|
||||
$self->{output}->output_add(severity => $self->{most_critical_instance},
|
||||
short_msg => "${prefix_output}$self->{lproblems} problem(s) detected");
|
||||
short_msg => $prefix_output . $self->{problems} . " problem(s) detected");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -360,6 +402,8 @@ sub run {
|
|||
$self->run_instances(config => $entry);
|
||||
} elsif ($entry->{type} == 2) {
|
||||
$self->run_group(config => $entry);
|
||||
} elsif ($entry->{type} == 3) {
|
||||
$self->run_instances(config => $entry, multi => 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -186,10 +186,15 @@ sub perfdata {
|
|||
if (defined($perf->{threshold_total})) {
|
||||
$th_total = ($perf->{threshold_total} =~ /[^0-9]/) ? $self->{result_values}->{$perf->{threshold_total}} : $perf->{threshold_total};
|
||||
}
|
||||
|
||||
if (defined($perf->{label_multi_instances}) && $perf->{label_multi_instances} == 1 && (defined($options{level}) && $options{level} == 2 && defined($options{extra_instance}) && $options{extra_instance} == 1)) {
|
||||
if (defined($perf->{multi_use})) {
|
||||
$extra_label .= '_' . $self->{result_values}->{$perf->{multi_use}};
|
||||
}
|
||||
}
|
||||
|
||||
if (defined($perf->{label_extra_instance}) && $perf->{label_extra_instance} == 1 &&
|
||||
(!defined($options{extra_instance}) || $options{extra_instance} != 0)) {
|
||||
|
||||
if (defined($perf->{label_extra_instance}) && $perf->{label_extra_instance} == 1 && (defined($options{level}) && $options{level} == 1 && defined($options{extra_instance}) && $options{extra_instance} == 1) ||
|
||||
(defined($options{level}) && $options{level} == 2 && defined($options{extra_instance_lvl2}) && $options{extra_instance_lvl2} == 1)) {
|
||||
if (defined($perf->{instance_use})) {
|
||||
$extra_label .= '_' . $self->{result_values}->{$perf->{instance_use}};
|
||||
} else {
|
||||
|
|
|
@ -337,7 +337,7 @@ sub run {
|
|||
$short_msg_append = ', ';
|
||||
}
|
||||
|
||||
$obj->perfdata(extra_instance => $multiple);
|
||||
$obj->perfdata(level => 1, extra_instance => $multiple);
|
||||
}
|
||||
|
||||
$self->{output}->output_add(long_msg => "Diskgroup '$self->{dg}->{$id}->{display}' $long_msg");
|
||||
|
|
|
@ -260,7 +260,7 @@ sub run {
|
|||
$short_msg_append = ', ';
|
||||
}
|
||||
|
||||
$maps_counters->{database}->{$_}->{obj}->perfdata(extra_instance => $multiple);
|
||||
$maps_counters->{database}->{$_}->{obj}->perfdata(level => 1, extra_instance => $multiple);
|
||||
}
|
||||
|
||||
$self->{output}->output_add(long_msg => "Database '" . $self->{db_selected}->{$id}->{name} . "' $long_msg");
|
||||
|
|
|
@ -143,7 +143,7 @@ sub manage_counters {
|
|||
$short_msg_append = ', ';
|
||||
}
|
||||
|
||||
$options{maps_counters}->{$_}->{obj}->perfdata(extra_instance => $self->{multiple});
|
||||
$options{maps_counters}->{$_}->{obj}->perfdata(level => 1, extra_instance => $self->{multiple});
|
||||
}
|
||||
|
||||
$self->{output}->output_add(long_msg => $options{label} . " " . $long_msg);
|
||||
|
|
|
@ -175,7 +175,7 @@ sub manage_counters {
|
|||
$short_msg_append = ', ';
|
||||
}
|
||||
|
||||
$options{maps_counters}->{$_}->{obj}->perfdata(extra_instance => $self->{multiple});
|
||||
$options{maps_counters}->{$_}->{obj}->perfdata(level => 1, extra_instance => $self->{multiple});
|
||||
}
|
||||
|
||||
$self->{output}->output_add(long_msg => $options{label} . " " . $long_msg);
|
||||
|
|
|
@ -163,7 +163,7 @@ sub manage_counters {
|
|||
$short_msg_append = ', ';
|
||||
}
|
||||
|
||||
$options{maps_counters}->{$_}->{obj}->perfdata(extra_instance => $self->{multiple});
|
||||
$options{maps_counters}->{$_}->{obj}->perfdata(level => 1, extra_instance => $self->{multiple});
|
||||
}
|
||||
|
||||
$self->{output}->output_add(long_msg => $options{label} . " " . $long_msg);
|
||||
|
|
|
@ -177,7 +177,7 @@ sub manage_counters {
|
|||
$short_msg_append = ', ';
|
||||
}
|
||||
|
||||
$options{maps_counters}->{$_}->{obj}->perfdata(extra_instance => $self->{multiple});
|
||||
$options{maps_counters}->{$_}->{obj}->perfdata(level => 1, extra_instance => $self->{multiple});
|
||||
}
|
||||
|
||||
$self->{output}->output_add(long_msg => $options{label} . " " . $long_msg);
|
||||
|
|
|
@ -211,7 +211,7 @@ sub run {
|
|||
$short_msg_append = ', ';
|
||||
}
|
||||
|
||||
$obj->perfdata(extra_instance => $multiple);
|
||||
$obj->perfdata(level => 1, extra_instance => $multiple);
|
||||
}
|
||||
|
||||
$self->{output}->output_add(long_msg => "Domain '$self->{domain}->{$id}->{display}' $long_msg");
|
||||
|
|
|
@ -134,7 +134,7 @@ sub run {
|
|||
$short_msg_append = ', ';
|
||||
}
|
||||
|
||||
$maps_counters->{cpu}->{$_}->{obj}->perfdata(extra_instance => $multiple);
|
||||
$maps_counters->{cpu}->{$_}->{obj}->perfdata(level => 1, extra_instance => $multiple);
|
||||
}
|
||||
|
||||
$self->{output}->output_add(long_msg => "CPU '" . $self->{cpu}->{$id}->{num} . "' Usage $long_msg [entity = '" . $self->{cpu}->{$id}->{name} . "']");
|
||||
|
|
|
@ -190,7 +190,7 @@ sub run {
|
|||
$short_msg_append = ', ';
|
||||
}
|
||||
|
||||
$maps_counters->{$_}->{obj}->perfdata(extra_instance => $multiple);
|
||||
$maps_counters->{$_}->{obj}->perfdata(level => 1, extra_instance => $multiple);
|
||||
}
|
||||
|
||||
$self->{output}->output_add(long_msg => "Memory '" . $self->{memory_selected}->{$id}->{display} . "' $long_msg [entity = '" . $self->{memory_selected}->{$id}->{name} . "']");
|
||||
|
|
|
@ -305,7 +305,7 @@ sub run {
|
|||
$short_msg_append = ', ';
|
||||
}
|
||||
|
||||
$maps_counters->{$_}->{obj}->perfdata(extra_instance => $multiple);
|
||||
$maps_counters->{$_}->{obj}->perfdata(level => 1, extra_instance => $multiple);
|
||||
}
|
||||
|
||||
$self->{output}->output_add(long_msg => "APN '" . $self->{apn_selected}->{$id}->{ggsnApnName} . "' $long_msg");
|
||||
|
|
|
@ -193,7 +193,7 @@ sub run {
|
|||
$short_msg_append = ', ';
|
||||
}
|
||||
|
||||
$maps_counters->{vpn}->{$_}->{obj}->perfdata(extra_instance => $multiple);
|
||||
$maps_counters->{vpn}->{$_}->{obj}->perfdata(level => 1, extra_instance => $multiple);
|
||||
}
|
||||
|
||||
$self->{output}->output_add(long_msg => "VPN '$self->{vpn}->{$id}->{num}/$self->{vpn}->{$id}->{ntqVPNIPSrc}/$self->{vpn}->{$id}->{ntqVPNIPDst}' $long_msg");
|
||||
|
|
|
@ -934,7 +934,7 @@ sub run {
|
|||
$short_msg_append = ', ';
|
||||
}
|
||||
|
||||
$obj->perfdata(extra_instance => $multiple);
|
||||
$obj->perfdata(level => 1, extra_instance => $multiple);
|
||||
}
|
||||
|
||||
$self->{output}->output_add(long_msg => "Interface '" . $self->{interface_selected}->{$id}->{display} . "'$self->{interface_selected}->{$id}->{extra_display} $long_msg");
|
||||
|
|
|
@ -244,7 +244,7 @@ sub run {
|
|||
$short_msg_append = ', ';
|
||||
}
|
||||
|
||||
$maps_counters->{$_}->{obj}->perfdata(extra_instance => $multiple);
|
||||
$maps_counters->{$_}->{obj}->perfdata(level => 1, extra_instance => $multiple);
|
||||
}
|
||||
|
||||
$self->{output}->output_add(long_msg => "'" . $self->{member_selected}->{$id}->{display} . "' $long_msg");
|
||||
|
|
|
@ -181,7 +181,7 @@ sub run {
|
|||
$short_msg_append = ', ';
|
||||
}
|
||||
|
||||
$maps_counters->{$_}->{obj}->perfdata(extra_instance => $multiple);
|
||||
$maps_counters->{$_}->{obj}->perfdata(level => 1, extra_instance => $multiple);
|
||||
}
|
||||
|
||||
$self->{output}->output_add(long_msg => "Disk '" . $self->{member_selected}->{$id}->{display} . "' $long_msg");
|
||||
|
|
|
@ -161,7 +161,7 @@ sub run {
|
|||
$short_msg_append = ', ';
|
||||
}
|
||||
|
||||
$maps_counters->{$_}->{obj}->perfdata(extra_instance => $multiple);
|
||||
$maps_counters->{$_}->{obj}->perfdata(level => 1, extra_instance => $multiple);
|
||||
}
|
||||
|
||||
$self->{output}->output_add(long_msg => "Pool '" . $self->{pool_selected}->{$id}->{display} . "' $long_msg");
|
||||
|
|
|
@ -140,7 +140,7 @@ sub run {
|
|||
$short_msg_append = ', ';
|
||||
}
|
||||
|
||||
$obj->perfdata(extra_instance => $multiple);
|
||||
$obj->perfdata(level => 1, extra_instance => $multiple);
|
||||
}
|
||||
|
||||
$self->{output}->output_add(long_msg => "SSD '" . $self->{ssd}->{$id}->{display} . "' Usage $long_msg");
|
||||
|
|
|
@ -144,7 +144,7 @@ sub run {
|
|||
$short_msg_append = ', ';
|
||||
}
|
||||
|
||||
$obj->perfdata(extra_instance => $multiple);
|
||||
$obj->perfdata(level => 1, extra_instance => $multiple);
|
||||
}
|
||||
|
||||
$self->{output}->output_add(long_msg => "CPU '$self->{cpu}->{$id}->{display}' $long_msg");
|
||||
|
|
|
@ -174,7 +174,7 @@ sub run {
|
|||
$short_msg_append = ', ';
|
||||
}
|
||||
|
||||
$obj->perfdata(extra_instance => $multiple);
|
||||
$obj->perfdata(level => 1, extra_instance => $multiple);
|
||||
}
|
||||
|
||||
$self->{output}->output_add(long_msg => "Port '$self->{port}->{$id}->{display}' $long_msg");
|
||||
|
|
|
@ -239,7 +239,7 @@ sub run {
|
|||
$short_msg_append = ', ';
|
||||
}
|
||||
|
||||
$obj->perfdata(extra_instance => $multiple);
|
||||
$obj->perfdata(level => 1, extra_instance => $multiple);
|
||||
}
|
||||
|
||||
$self->{output}->output_add(long_msg => "Raid Group '$self->{rg}->{$id}->{display}' $long_msg");
|
||||
|
|
|
@ -234,7 +234,7 @@ sub run {
|
|||
$short_msg_append = ', ';
|
||||
}
|
||||
|
||||
$obj->perfdata(extra_instance => $multiple);
|
||||
$obj->perfdata(level => 1, extra_instance => $multiple);
|
||||
}
|
||||
|
||||
$self->{output}->output_add(long_msg => "Volume '$self->{vol}->{$id}->{display}' $long_msg");
|
||||
|
|
|
@ -246,7 +246,7 @@ sub run {
|
|||
$short_msg_append = ', ';
|
||||
}
|
||||
|
||||
$maps_counters->{$_}->{obj}->perfdata(extra_instance => $multiple);
|
||||
$maps_counters->{$_}->{obj}->perfdata(level => 1, extra_instance => $multiple);
|
||||
}
|
||||
|
||||
$self->{output}->output_add(long_msg => "Volume '$name' $long_msg");
|
||||
|
@ -298,4 +298,4 @@ Allows to use regexp to filter volume name (with option --name).
|
|||
=back
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
|
|
|
@ -188,7 +188,7 @@ sub run {
|
|||
$short_msg_append = ', ';
|
||||
}
|
||||
|
||||
$maps_counters->{agg}->{$_}->{obj}->perfdata(extra_instance => $multiple);
|
||||
$maps_counters->{agg}->{$_}->{obj}->perfdata(level => 1, extra_instance => $multiple);
|
||||
}
|
||||
|
||||
$self->{output}->output_add(long_msg => "Aggregate '$self->{agg}->{$id}->{aggrName}' $long_msg");
|
||||
|
|
|
@ -169,7 +169,7 @@ sub run_instances {
|
|||
$short_msg_append = ', ';
|
||||
}
|
||||
|
||||
$obj->perfdata(extra_instance => $multiple);
|
||||
$obj->perfdata(level => 1, extra_instance => $multiple);
|
||||
}
|
||||
|
||||
$self->{output}->output_add(long_msg => "Volume '$self->{vol}->{$id}->{display}' $long_msg");
|
||||
|
|
|
@ -185,7 +185,7 @@ sub run {
|
|||
$short_msg_append = ', ';
|
||||
}
|
||||
|
||||
$maps_counters->{$_}->{obj}->perfdata(extra_instance => $multiple);
|
||||
$maps_counters->{$_}->{obj}->perfdata(level => 1, extra_instance => $multiple);
|
||||
}
|
||||
|
||||
$self->{output}->output_add(long_msg => "Volume '" . $self->{volumes_selected}->{$id}->{display} . "' $long_msg");
|
||||
|
|
Loading…
Reference in New Issue