fix(centreon/local): metaservice mode - set default value for metric name (#2783)
This commit is contained in:
parent
f6301dd88b
commit
af42d59713
|
@ -29,7 +29,7 @@ use centreon::common::logger;
|
||||||
|
|
||||||
use vars qw($centreon_config);
|
use vars qw($centreon_config);
|
||||||
|
|
||||||
my %DSTYPE = ( "0" => "g", "1" => "c", "2" => "d", "3" => "a");
|
my %DSTYPE = ( '0' => 'g', '1' => 'c', '2' => 'd', '3' => 'a');
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my ($class, %options) = @_;
|
my ($class, %options) = @_;
|
||||||
|
@ -38,7 +38,7 @@ sub new {
|
||||||
|
|
||||||
$options{options}->add_options(arguments => {
|
$options{options}->add_options(arguments => {
|
||||||
'centreon-config:s' => { name => 'centreon_config', default => '/etc/centreon/centreon-config.pm' },
|
'centreon-config:s' => { name => 'centreon_config', default => '/etc/centreon/centreon-config.pm' },
|
||||||
'meta-id:s' => { name => 'meta_id' },
|
'meta-id:s' => { name => 'meta_id' }
|
||||||
});
|
});
|
||||||
|
|
||||||
$self->{metric_selected} = {};
|
$self->{metric_selected} = {};
|
||||||
|
@ -181,8 +181,10 @@ sub run {
|
||||||
);
|
);
|
||||||
my $status = $self->{centreon_db_centreon}->connect();
|
my $status = $self->{centreon_db_centreon}->connect();
|
||||||
if ($status == -1) {
|
if ($status == -1) {
|
||||||
$self->{output}->output_add(severity => 'UNKNOWN',
|
$self->{output}->output_add(
|
||||||
short_msg => 'Cannot connect to Centreon Database.');
|
severity => 'UNKNOWN',
|
||||||
|
short_msg => 'Cannot connect to Centreon Database.'
|
||||||
|
);
|
||||||
$self->{output}->display();
|
$self->{output}->display();
|
||||||
$self->{output}->exit();
|
$self->{output}->exit();
|
||||||
}
|
}
|
||||||
|
@ -234,15 +236,19 @@ sub run {
|
||||||
|
|
||||||
my $result = $self->calculate(calculation => $row->{calcul_type});
|
my $result = $self->calculate(calculation => $row->{calcul_type});
|
||||||
|
|
||||||
my $exit = $self->{perfdata}->threshold_check(value => $result, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
my $exit = $self->{perfdata}->threshold_check(value => $result, threshold => [ { label => 'critical', exit_litteral => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
|
||||||
my $display = defined($row->{meta_display}) ? $row->{meta_display} : $row->{calcul_type} . ' - value : %f';
|
my $display = defined($row->{meta_display}) ? $row->{meta_display} : $row->{calcul_type} . ' - value : %f';
|
||||||
$self->{output}->output_add(
|
$self->{output}->output_add(
|
||||||
severity => $exit,
|
severity => $exit,
|
||||||
short_msg => sprintf($display, $result)
|
short_msg => sprintf($display, $result)
|
||||||
);
|
);
|
||||||
$self->{output}->perfdata_add(
|
$self->{output}->perfdata_add(
|
||||||
label => (defined($DSTYPE{$row->{data_source_type}}) ? $DSTYPE{$row->{data_source_type}} : 'g') . '[' . $row->{metric} . ']',
|
label => sprintf(
|
||||||
value => sprintf("%02.2f", $result),
|
'%s[%s]',
|
||||||
|
(defined($DSTYPE{$row->{data_source_type}}) ? $DSTYPE{$row->{data_source_type}} : 'g'),
|
||||||
|
defined($row->{metric}) && $row->{metric} ne '' ? $row->{metric} : 'value',
|
||||||
|
),
|
||||||
|
value => sprintf('%02.2f', $result),
|
||||||
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
warning => $self->{perfdata}->get_perfdata_for_output(label => 'warning'),
|
||||||
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical')
|
critical => $self->{perfdata}->get_perfdata_for_output(label => 'critical')
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue