WIP: new perfdata system
This commit is contained in:
parent
c225f2052e
commit
11b44af509
|
@ -51,19 +51,21 @@ sub custom_usage_perfdata {
|
|||
$label = 'free';
|
||||
$value_perf = $self->{result_values}->{free};
|
||||
}
|
||||
my $extra_label = '';
|
||||
$extra_label = '_' . $self->{result_values}->{display} if (!defined($options{extra_instance}) || $options{extra_instance} != 0);
|
||||
|
||||
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 => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef,
|
||||
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 {
|
||||
|
@ -76,7 +78,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;
|
||||
}
|
||||
|
||||
|
|
|
@ -51,19 +51,21 @@ sub custom_usage_perfdata {
|
|||
$label = 'free';
|
||||
$value_perf = $self->{result_values}->{free};
|
||||
}
|
||||
my $extra_label = '';
|
||||
$extra_label = '_' . $self->{result_values}->{display} if (!defined($options{extra_instance}) || $options{extra_instance} != 0);
|
||||
|
||||
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 => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef,
|
||||
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 {
|
||||
|
@ -76,7 +78,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;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,17 +32,16 @@ sub new {
|
|||
bless $self, $class;
|
||||
|
||||
$self->{version} = '1.0';
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
"port:s" => { name => 'port', default => '7634' },
|
||||
"timeout:s" => { name => 'timeout', default => '10' },
|
||||
"name:s" => { name => 'name' },
|
||||
"warning:s" => { name => 'warning' },
|
||||
"critical:s" => { name => 'critical' },
|
||||
"regexp" => { name => 'use_regexp' },
|
||||
"regexp-isensitive" => { name => 'use_regexpi' },
|
||||
});
|
||||
$options{options}->add_options(arguments => {
|
||||
"hostname:s" => { name => 'hostname' },
|
||||
"port:s" => { name => 'port', default => '7634' },
|
||||
"timeout:s" => { name => 'timeout', default => '10' },
|
||||
"name:s" => { name => 'name' },
|
||||
"warning:s" => { name => 'warning' },
|
||||
"critical:s" => { name => 'critical' },
|
||||
"regexp" => { name => 'use_regexp' },
|
||||
"regexp-isensitive" => { name => 'use_regexpi' },
|
||||
});
|
||||
|
||||
$self->{result} = {};
|
||||
$self->{hostname} = undef;
|
||||
|
@ -71,11 +70,12 @@ sub check_options {
|
|||
sub manage_selection {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $oSocketConn = new IO::Socket::INET ( Proto => 'tcp',
|
||||
PeerAddr => $self->{option_results}->{hostname},
|
||||
PeerPort => $self->{option_results}->{port},
|
||||
Timeout => $self->{option_results}->{timeout},
|
||||
);
|
||||
my $oSocketConn = new IO::Socket::INET (
|
||||
Proto => 'tcp',
|
||||
PeerAddr => $self->{option_results}->{hostname},
|
||||
PeerPort => $self->{option_results}->{port},
|
||||
Timeout => $self->{option_results}->{timeout},
|
||||
);
|
||||
|
||||
if (!defined($oSocketConn)) {
|
||||
$self->{output}->add_option_msg(short_msg => "Could not connect.");
|
||||
|
@ -147,14 +147,17 @@ sub run {
|
|||
$self->{result}->{$name}->{unit}));
|
||||
}
|
||||
|
||||
my $extra_label = '';
|
||||
my $extra_label;
|
||||
$extra_label = '_' . $name if (!defined($self->{option_results}->{name}) || defined($self->{option_results}->{use_regexp}));
|
||||
$self->{output}->perfdata_add(label => 'temp' . $extra_label,
|
||||
unit => $self->{result}->{$name}->{unit},
|
||||
value => sprintf("%.2f", $self->{result}->{$name}->{temperature}),
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'),
|
||||
min => 0);
|
||||
$self->{output}->perfdata_add(
|
||||
label => 'temp',
|
||||
intances => $extra_label,
|
||||
unit => $self->{result}->{$name}->{unit},
|
||||
value => sprintf("%.2f", $self->{result}->{$name}->{temperature}),
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'),
|
||||
min => 0
|
||||
);
|
||||
};
|
||||
|
||||
$self->{output}->display();
|
||||
|
|
|
@ -185,13 +185,16 @@ sub check {
|
|||
$str_display .= $str_display_append . sprintf("%s %s /sec", $name, $value_display);
|
||||
$str_display_append = ', ';
|
||||
|
||||
my $extra_label = '';
|
||||
my $extra_label;
|
||||
$extra_label = '_' . $site_name if (!defined($self->{option_results}->{name}) || defined($self->{option_results}->{use_regexp}));
|
||||
$self->{output}->perfdata_add(label => $name . $extra_label, unit => $counters->{$name}->{unit},
|
||||
value => sprintf("%.2f", $value_per_seconds),
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning_' . $name),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical_' . $name),
|
||||
min => 0);
|
||||
$self->{output}->perfdata_add(
|
||||
label => $name, unit => $counters->{$name}->{unit},
|
||||
instances => $extra_label,
|
||||
value => sprintf("%.2f", $value_per_seconds),
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning_' . $name),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical_' . $name),
|
||||
min => 0
|
||||
);
|
||||
}
|
||||
|
||||
# No values computing.
|
||||
|
@ -259,4 +262,4 @@ Counters are separated by comas.
|
|||
|
||||
=back
|
||||
|
||||
=cut
|
||||
=cut
|
||||
|
|
|
@ -51,19 +51,21 @@ sub custom_usage_perfdata {
|
|||
$label = 'free';
|
||||
$value_perf = $self->{result_values}->{free};
|
||||
}
|
||||
my $extra_label = '';
|
||||
$extra_label = '_' . $self->{result_values}->{display} if (!defined($options{extra_instance}) || $options{extra_instance} != 0);
|
||||
|
||||
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 => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef,
|
||||
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 {
|
||||
|
@ -76,7 +78,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;
|
||||
}
|
||||
|
||||
|
|
|
@ -91,9 +91,6 @@ sub custom_usage_perfdata {
|
|||
my $use_th = 1;
|
||||
$use_th = 0 if ($self->{instance_mode}->{option_results}->{units} eq '%' && $self->{result_values}->{max} <= 0);
|
||||
|
||||
my $extra_label = '';
|
||||
$extra_label = '_' . $self->{result_values}->{display} if (!defined($options{extra_instance}) || $options{extra_instance} != 0);
|
||||
|
||||
my $value_perf = $self->{result_values}->{used};
|
||||
my %total_options = ();
|
||||
if ($self->{instance_mode}->{option_results}->{units} eq '%' && $self->{result_values}->{max} > 0) {
|
||||
|
@ -103,11 +100,14 @@ sub custom_usage_perfdata {
|
|||
|
||||
my $label = $self->{label};
|
||||
$label =~ s/-/_/g;
|
||||
$self->{output}->perfdata_add(label => $label . $extra_label,
|
||||
value => $value_perf,
|
||||
warning => $use_th == 1 ? $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, %total_options) : undef,
|
||||
critical => $use_th == 1 ? $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, %total_options) : undef,
|
||||
min => 0, max => $self->{result_values}->{max} > 0 ? $self->{result_values}->{max} : undef);
|
||||
$self->{output}->perfdata_add(
|
||||
label => $label,
|
||||
instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef,
|
||||
value => $value_perf,
|
||||
warning => $use_th == 1 ? $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}, %total_options) : undef,
|
||||
critical => $use_th == 1 ? $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}, %total_options) : undef,
|
||||
min => 0, max => $self->{result_values}->{max} > 0 ? $self->{result_values}->{max} : undef
|
||||
);
|
||||
}
|
||||
|
||||
sub custom_usage_threshold {
|
||||
|
@ -120,7 +120,7 @@ sub custom_usage_threshold {
|
|||
if ($self->{instance_mode}->{option_results}->{units} eq '%') {
|
||||
$threshold_value = $self->{result_values}->{prct_used};
|
||||
}
|
||||
$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;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,9 +61,6 @@ sub custom_usage_perfdata {
|
|||
my $use_th = 1;
|
||||
$use_th = 0 if ($self->{instance_mode}->{option_results}->{units} eq '%' && $self->{result_values}->{max} <= 0);
|
||||
|
||||
my $extra_label = '';
|
||||
$extra_label = '_' . $self->{result_values}->{display} if (!defined($options{extra_instance}) || $options{extra_instance} != 0);
|
||||
|
||||
my $value_perf = $self->{result_values}->{used};
|
||||
my %total_options = ();
|
||||
if ($self->{instance_mode}->{option_results}->{units} eq '%' && $self->{result_values}->{max} > 0) {
|
||||
|
@ -73,11 +70,14 @@ sub custom_usage_perfdata {
|
|||
|
||||
my $label = $self->{label};
|
||||
$label =~ s/-/_/g;
|
||||
$self->{output}->perfdata_add(label => $label . $extra_label,
|
||||
value => $value_perf,
|
||||
warning => $use_th == 1 ? $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, %total_options) : undef,
|
||||
critical => $use_th == 1 ? $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, %total_options) : undef,
|
||||
min => 0, max => $self->{result_values}->{max} > 0 ? $self->{result_values}->{max} : undef);
|
||||
$self->{output}->perfdata_add(
|
||||
label => $label,
|
||||
instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef,
|
||||
value => $value_perf,
|
||||
warning => $use_th == 1 ? $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}, %total_options) : undef,
|
||||
critical => $use_th == 1 ? $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}, %total_options) : undef,
|
||||
min => 0, max => $self->{result_values}->{max} > 0 ? $self->{result_values}->{max} : undef
|
||||
);
|
||||
}
|
||||
|
||||
sub custom_usage_threshold {
|
||||
|
@ -90,7 +90,7 @@ sub custom_usage_threshold {
|
|||
if ($self->{instance_mode}->{option_results}->{units} eq '%') {
|
||||
$threshold_value = $self->{result_values}->{prct_used};
|
||||
}
|
||||
$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;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,9 +61,6 @@ sub custom_usage_perfdata {
|
|||
my $use_th = 1;
|
||||
$use_th = 0 if ($self->{instance_mode}->{option_results}->{units} eq '%' && $self->{result_values}->{max} <= 0);
|
||||
|
||||
my $extra_label = '';
|
||||
$extra_label = '_' . $self->{result_values}->{display} if (!defined($options{extra_instance}) || $options{extra_instance} != 0);
|
||||
|
||||
my $value_perf = $self->{result_values}->{used};
|
||||
my %total_options = ();
|
||||
if ($self->{instance_mode}->{option_results}->{units} eq '%' && $self->{result_values}->{max} > 0) {
|
||||
|
@ -73,11 +70,14 @@ sub custom_usage_perfdata {
|
|||
|
||||
my $label = $self->{label};
|
||||
$label =~ s/-/_/g;
|
||||
$self->{output}->perfdata_add(label => $label . $extra_label,
|
||||
value => $value_perf,
|
||||
warning => $use_th == 1 ? $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, %total_options) : undef,
|
||||
critical => $use_th == 1 ? $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, %total_options) : undef,
|
||||
min => 0, max => $self->{result_values}->{max} > 0 ? $self->{result_values}->{max} : undef);
|
||||
$self->{output}->perfdata_add(
|
||||
label => $label,
|
||||
instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef,
|
||||
value => $value_perf,
|
||||
warning => $use_th == 1 ? $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}, %total_options) : undef,
|
||||
critical => $use_th == 1 ? $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}, %total_options) : undef,
|
||||
min => 0, max => $self->{result_values}->{max} > 0 ? $self->{result_values}->{max} : undef
|
||||
);
|
||||
}
|
||||
|
||||
sub custom_usage_threshold {
|
||||
|
@ -90,7 +90,7 @@ sub custom_usage_threshold {
|
|||
if ($self->{instance_mode}->{option_results}->{units} eq '%') {
|
||||
$threshold_value = $self->{result_values}->{prct_used};
|
||||
}
|
||||
$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;
|
||||
}
|
||||
|
||||
|
|
|
@ -123,11 +123,14 @@ sub run {
|
|||
$self->{result}->{$name}->{state}));
|
||||
}
|
||||
|
||||
my $extra_label = '';
|
||||
my $extra_label;
|
||||
$extra_label = '_' . $name if (!defined($self->{option_results}->{name}) || defined($self->{option_results}->{use_regexp}));
|
||||
$self->{output}->perfdata_add(label => 'status' . $extra_label,
|
||||
value => sprintf("%.1f", $staterc),
|
||||
min => 0);
|
||||
$self->{output}->perfdata_add(
|
||||
label => 'status',
|
||||
instances => $extra_label,
|
||||
value => sprintf("%.1f", $staterc),
|
||||
min => 0
|
||||
);
|
||||
};
|
||||
|
||||
$self->{output}->display();
|
||||
|
|
|
@ -275,30 +275,41 @@ sub run {
|
|||
$requestInfo_errorCount_absolute_per_sec));
|
||||
}
|
||||
|
||||
my $extra_label = '';
|
||||
my $extra_label;
|
||||
$extra_label = '_' . $name if (!defined($self->{option_results}->{name}) || defined($self->{option_results}->{use_regexp}));
|
||||
$self->{output}->perfdata_add(label => 'maxTime' . $extra_label,
|
||||
value => sprintf("%.2f", $self->{result}->{$name}->{requestInfo_maxTime}),
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'),
|
||||
min => 0);
|
||||
$self->{output}->perfdata_add(
|
||||
label => 'maxTime',
|
||||
instances => $extra_label,
|
||||
value => sprintf("%.2f", $self->{result}->{$name}->{requestInfo_maxTime}),
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'),
|
||||
min => 0
|
||||
);
|
||||
|
||||
$self->{output}->perfdata_add(label => 'processingTime' . $extra_label,
|
||||
value => sprintf("%.3f", $requestInfo_processingTime_absolute_per_sec),
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'),
|
||||
min => 0);
|
||||
|
||||
$self->{output}->perfdata_add(label => 'requestCount' . $extra_label,
|
||||
value => sprintf("%.2f", $requestInfo_requestCount_absolute_per_sec),
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'),
|
||||
min => 0);
|
||||
$self->{output}->perfdata_add(label => 'errorCount' . $extra_label,
|
||||
value => sprintf("%.2f", $requestInfo_errorCount_absolute_per_sec),
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'),
|
||||
min => 0);
|
||||
$self->{output}->perfdata_add(
|
||||
label => 'processingTime',
|
||||
instances => $extra_label,
|
||||
value => sprintf("%.3f", $requestInfo_processingTime_absolute_per_sec),
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'),
|
||||
min => 0
|
||||
);
|
||||
$self->{output}->perfdata_add(
|
||||
label => 'requestCount',
|
||||
instances => $extra_label,
|
||||
value => sprintf("%.2f", $requestInfo_requestCount_absolute_per_sec),
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'),
|
||||
min => 0
|
||||
);
|
||||
$self->{output}->perfdata_add(
|
||||
label => 'errorCount',
|
||||
instances => $extra_label,
|
||||
value => sprintf("%.2f", $requestInfo_errorCount_absolute_per_sec),
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'),
|
||||
min => 0
|
||||
);
|
||||
};
|
||||
|
||||
$self->{statefile_value}->write(data => $new_datas);
|
||||
|
|
|
@ -124,13 +124,16 @@ sub run {
|
|||
$self->{result}->{$name}->{sessions}));
|
||||
}
|
||||
|
||||
my $extra_label = '';
|
||||
my $extra_label;
|
||||
$extra_label = '_' . $name if (!defined($self->{option_results}->{name}) || defined($self->{option_results}->{use_regexp}));
|
||||
$self->{output}->perfdata_add(label => 'sessions' . $extra_label,
|
||||
value => sprintf("%.2f", $self->{result}->{$name}->{sessions}),
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'),
|
||||
min => 0);
|
||||
$self->{output}->perfdata_add(
|
||||
label => 'sessions',
|
||||
instances => $extra_label,
|
||||
value => sprintf("%.2f", $self->{result}->{$name}->{sessions}),
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'),
|
||||
min => 0
|
||||
);
|
||||
};
|
||||
|
||||
$self->{output}->display();
|
||||
|
|
|
@ -184,21 +184,27 @@ sub run {
|
|||
$self->{result}->{$name}->{currentThreadsBusy}));
|
||||
}
|
||||
|
||||
my $extra_label = '';
|
||||
my $extra_label;
|
||||
$extra_label = '_' . $name if (!defined($self->{option_results}->{name}) || defined($self->{option_results}->{use_regexp}));
|
||||
$self->{output}->perfdata_add(label => 'currentThreadsBusy' . $extra_label,
|
||||
value => $self->{result}->{$name}->{currentThreadsBusy},
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'),
|
||||
min => 0,
|
||||
max => $self->{result}->{$name}->{maxThreads});
|
||||
$self->{output}->perfdata_add(
|
||||
label => 'currentThreadsBusy',
|
||||
instances => $extra_label,
|
||||
value => $self->{result}->{$name}->{currentThreadsBusy},
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'),
|
||||
min => 0,
|
||||
max => $self->{result}->{$name}->{maxThreads}
|
||||
);
|
||||
|
||||
$self->{output}->perfdata_add(label => 'currentThreadCount' . $extra_label,
|
||||
value => $self->{result}->{$name}->{currentThreadCount},
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'),
|
||||
min => 0,
|
||||
max => $self->{result}->{$name}->{maxThreads});
|
||||
$self->{output}->perfdata_add(
|
||||
label => 'currentThreadCount',
|
||||
instances => $extra_label,
|
||||
value => $self->{result}->{$name}->{currentThreadCount},
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical'),
|
||||
min => 0,
|
||||
max => $self->{result}->{$name}->{maxThreads}
|
||||
);
|
||||
};
|
||||
|
||||
$self->{output}->display();
|
||||
|
|
|
@ -61,25 +61,23 @@ sub set_counters {
|
|||
sub custom_traffic_perfdata {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
my $extra_label = '';
|
||||
if (!defined($options{extra_instance}) || $options{extra_instance} != 0) {
|
||||
$extra_label .= '_' . $self->{result_values}->{display};
|
||||
}
|
||||
|
||||
my ($warning, $critical);
|
||||
if ($self->{instance_mode}->{option_results}->{units_traffic} eq '%' && defined($self->{result_values}->{speed})) {
|
||||
$warning = $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label}, total => $self->{result_values}->{speed}, cast_int => 1);
|
||||
$critical = $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label}, total => $self->{result_values}->{speed}, cast_int => 1);
|
||||
$warning = $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}, total => $self->{result_values}->{speed}, cast_int => 1);
|
||||
$critical = $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel}, total => $self->{result_values}->{speed}, cast_int => 1);
|
||||
} elsif ($self->{instance_mode}->{option_results}->{units_traffic} eq 'b/s') {
|
||||
$warning = $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{label});
|
||||
$critical = $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{label});
|
||||
$warning = $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel});
|
||||
$critical = $self->{perfdata}->get_perfdata_for_output(label => 'critical-' . $self->{thlabel});
|
||||
}
|
||||
|
||||
$self->{output}->perfdata_add(label => 'traffic_' . $self->{result_values}->{label} . $extra_label, unit => 'b/s',
|
||||
value => sprintf("%.2f", $self->{result_values}->{traffic}),
|
||||
warning => $warning,
|
||||
critical => $critical,
|
||||
min => 0, max => $self->{result_values}->{speed});
|
||||
$self->{output}->perfdata_add(
|
||||
label => 'traffic_' . $self->{result_values}->{label}, unit => 'b/s',
|
||||
instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef,
|
||||
value => sprintf("%.2f", $self->{result_values}->{traffic}),
|
||||
warning => $warning,
|
||||
critical => $critical,
|
||||
min => 0, max => $self->{result_values}->{speed}
|
||||
);
|
||||
}
|
||||
|
||||
sub custom_traffic_threshold {
|
||||
|
@ -87,9 +85,9 @@ sub custom_traffic_threshold {
|
|||
|
||||
my $exit = 'ok';
|
||||
if ($self->{instance_mode}->{option_results}->{units_traffic} eq '%' && defined($self->{result_values}->{speed})) {
|
||||
$exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{traffic_prct}, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]);
|
||||
$exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{traffic_prct}, threshold => [ { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{thlabel}, exit_litteral => 'warning' } ]);
|
||||
} elsif ($self->{instance_mode}->{option_results}->{units_traffic} eq 'b/s') {
|
||||
$exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{traffic}, threshold => [ { label => 'critical-' . $self->{label}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{label}, exit_litteral => 'warning' } ]);
|
||||
$exit = $self->{perfdata}->threshold_check(value => $self->{result_values}->{traffic}, threshold => [ { label => 'critical-' . $self->{thlabel}, exit_litteral => 'critical' }, { label => 'warning-' . $self->{thlabel}, exit_litteral => 'warning' } ]);
|
||||
}
|
||||
return $exit;
|
||||
}
|
||||
|
|
|
@ -54,19 +54,21 @@ sub custom_usage_perfdata {
|
|||
$label = 'free';
|
||||
$value_perf = $self->{result_values}->{free};
|
||||
}
|
||||
my $extra_label = '';
|
||||
$extra_label = '_' . $self->{result_values}->{display} if (!defined($options{extra_instance}) || $options{extra_instance} != 0);
|
||||
|
||||
my %total_options = ();
|
||||
if ($self->{result_values}->{total} =~ /[0-9]/ && $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,
|
||||
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} =~ /[0-9]/ ? $self->{result_values}->{total} : undef);
|
||||
$self->{output}->perfdata_add(
|
||||
label => $label,
|
||||
instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef,
|
||||
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} =~ /[0-9]/ ? $self->{result_values}->{total} : undef
|
||||
);
|
||||
}
|
||||
|
||||
sub custom_usage_threshold {
|
||||
|
@ -79,7 +81,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;
|
||||
}
|
||||
|
||||
|
|
|
@ -49,9 +49,7 @@ sub custom_usage_perfdata {
|
|||
($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 || $self->{output}->use_new_perfdata());
|
||||
|
||||
my %total_options = ();
|
||||
if ($self->{instance_mode}->{option_results}->{units} eq '%') {
|
||||
$total_options{total} = $self->{result_values}->{total};
|
||||
|
@ -60,7 +58,7 @@ sub custom_usage_perfdata {
|
|||
|
||||
$self->{output}->perfdata_add(
|
||||
label => $label, unit => 'B',
|
||||
instances => $extra_label,
|
||||
instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef,
|
||||
nlabel => $nlabel,
|
||||
value => $value_perf,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}, %total_options),
|
||||
|
|
|
@ -49,9 +49,7 @@ sub custom_usage_perfdata {
|
|||
($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 || $self->{output}->use_new_perfdata());
|
||||
|
||||
my %total_options = ();
|
||||
if ($self->{instance_mode}->{option_results}->{units} eq '%') {
|
||||
$total_options{total} = $self->{result_values}->{total};
|
||||
|
@ -60,7 +58,7 @@ sub custom_usage_perfdata {
|
|||
|
||||
$self->{output}->perfdata_add(
|
||||
label => $label, unit => 'B',
|
||||
instances => $extra_label,
|
||||
instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef,
|
||||
nlabel => $nlabel,
|
||||
value => $value_perf,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}, %total_options),
|
||||
|
|
|
@ -50,9 +50,7 @@ sub custom_usage_perfdata {
|
|||
($label, $nlabel) = ('free', 'vm.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 || $self->{output}->use_new_perfdata());
|
||||
|
||||
my %total_options = ();
|
||||
if ($self->{instance_mode}->{option_results}->{units} eq '%') {
|
||||
$total_options{total} = $self->{result_values}->{total};
|
||||
|
@ -61,7 +59,7 @@ sub custom_usage_perfdata {
|
|||
|
||||
$self->{output}->perfdata_add(
|
||||
label => $label, unit => 'B',
|
||||
instances => $extra_label,
|
||||
instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef,
|
||||
nlabel => $nlabel,
|
||||
value => $value_perf,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}, %total_options),
|
||||
|
|
|
@ -39,14 +39,10 @@ sub custom_usage_perfdata {
|
|||
$total_options{cast_int} = 1;
|
||||
$value_perf = $self->{result_values}->{used};
|
||||
}
|
||||
|
||||
my $extra_label;
|
||||
$extra_label = $self->{result_values}->{display}
|
||||
if (!defined($options{extra_instance}) || $options{extra_instance} != 0 || $self->{output}->use_new_perfdata());
|
||||
|
||||
$self->{output}->perfdata_add(
|
||||
label => $label, unit => $unit,
|
||||
instances => $extra_label,
|
||||
instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef,
|
||||
nlabel => $nlabel,
|
||||
value => $value_perf,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}, %total_options),
|
||||
|
|
|
@ -161,6 +161,16 @@ sub output {
|
|||
return sprintf($self->{output_template}, $value, $unit);
|
||||
}
|
||||
|
||||
sub use_instances {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
if (!defined($options{extra_instance}) || $options{extra_instance} != 0 || $self->{output}->use_new_perfdata()) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub perfdata {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
|
|
@ -742,20 +742,16 @@ sub new {
|
|||
$options{options}->add_options(arguments => { "add-volume" => { name => 'add_volume' }, });
|
||||
}
|
||||
if ($self->{no_oid_options} == 0) {
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"oid-filter:s" => { name => 'oid_filter', default => $self->default_oid_filter_name() },
|
||||
"oid-display:s" => { name => 'oid_display', default => $self->default_oid_display_name() },
|
||||
"oid-extra-display:s" => { name => 'oid_extra_display' },
|
||||
}
|
||||
);
|
||||
$options{options}->add_options(arguments => {
|
||||
"oid-filter:s" => { name => 'oid_filter', default => $self->default_oid_filter_name() },
|
||||
"oid-display:s" => { name => 'oid_display', default => $self->default_oid_display_name() },
|
||||
"oid-extra-display:s" => { name => 'oid_extra_display' },
|
||||
});
|
||||
}
|
||||
if ($self->{no_interfaceid_options} == 0) {
|
||||
$options{options}->add_options(arguments =>
|
||||
{
|
||||
"name" => { name => 'use_name' },
|
||||
}
|
||||
);
|
||||
$options{options}->add_options(arguments => {
|
||||
"name" => { name => 'use_name' },
|
||||
});
|
||||
}
|
||||
|
||||
$self->{statefile_value} = centreon::plugins::statefile->new(%options);
|
||||
|
@ -767,9 +763,9 @@ sub new {
|
|||
my ($id, $name) = split /_/;
|
||||
if (!defined($self->{maps_counters}->{$key}->{$_}->{threshold}) || $self->{maps_counters}->{$key}->{$_}->{threshold} != 0) {
|
||||
$options{options}->add_options(arguments => {
|
||||
'warning-' . $name . ':s' => { name => 'warning-' . $name },
|
||||
'critical-' . $name . ':s' => { name => 'critical-' . $name },
|
||||
});
|
||||
'warning-' . $name . ':s' => { name => 'warning-' . $name },
|
||||
'critical-' . $name . ':s' => { name => 'critical-' . $name },
|
||||
});
|
||||
}
|
||||
$self->{maps_counters}->{$key}->{$_}->{obj} = centreon::plugins::values->new(statefile => $self->{statefile_value},
|
||||
output => $self->{output}, perfdata => $self->{perfdata},
|
||||
|
|
|
@ -34,9 +34,7 @@ sub custom_usage_perfdata {
|
|||
($label, $nlabel) = ('free', '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 || $self->{output}->use_new_perfdata());
|
||||
|
||||
my %total_options = ();
|
||||
if ($self->{instance_mode}->{option_results}->{units} eq '%') {
|
||||
$total_options{total} = $self->{result_values}->{total};
|
||||
|
@ -45,7 +43,7 @@ sub custom_usage_perfdata {
|
|||
|
||||
$self->{output}->perfdata_add(
|
||||
label => $label, unit => 'B',
|
||||
instances => $extra_label,
|
||||
instances => $self->use_instances(extra_instance => $options{extra_instance}) ? $self->{result_values}->{display} : undef,
|
||||
nlabel => $nlabel,
|
||||
value => $value_perf,
|
||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning-' . $self->{thlabel}, %total_options),
|
||||
|
|
Loading…
Reference in New Issue