fix(openldap): system-usage mode - illegal division by zero (#3036)
This commit is contained in:
parent
0b6302f4ac
commit
6e8f84c544
|
@ -27,6 +27,12 @@ use warnings;
|
|||
use Digest::MD5 qw(md5_hex);
|
||||
use centreon::common::protocols::ldap::lib::ldap;
|
||||
|
||||
sub prefix_operation_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return 'Operation completed ';
|
||||
}
|
||||
|
||||
sub set_counters {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
@ -42,36 +48,35 @@ sub set_counters {
|
|||
key_values => [ { name => 'operations_completed_' . $_, diff => 1 } ],
|
||||
output_template => $_ . ' %s',
|
||||
perfdatas => [
|
||||
{ label => 'operations_' . $_, template => '%.2f', min => 0 }
|
||||
{ template => '%.2f', min => 0 }
|
||||
]
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
$self->{maps_counters}->{global} = [
|
||||
{ label => 'con-current', nlabel => 'system.connections.current.count', set => {
|
||||
key_values => [ { name => 'connections_current' } ],
|
||||
output_template => 'Current connections %s',
|
||||
perfdatas => [
|
||||
{ label => 'connections_current', template => '%s', min => 0 },
|
||||
],
|
||||
{ template => '%s', min => 0 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'con-total', nlabel => 'system.connections.total.count', set => {
|
||||
key_values => [ { name => 'connections_total', diff => 1 } ],
|
||||
output_template => 'Total connections %s',
|
||||
perfdatas => [
|
||||
{ label => 'connections_total', template => '%s', min => 0 },
|
||||
],
|
||||
{ template => '%s', min => 0 }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'threads-active', nlabel => 'system.threads.active.percentage', set => {
|
||||
key_values => [ { name => 'threads_active_prct' } ],
|
||||
output_template => 'Current active threads %.2f %%',
|
||||
perfdatas => [
|
||||
{ label => 'threads_active', template => '%.2f', min => 0, max => 100, unit => '%' },
|
||||
],
|
||||
{ template => '%.2f', min => 0, max => 100, unit => '%' }
|
||||
]
|
||||
}
|
||||
},
|
||||
{ label => 'traffic', nlabel => 'system.traffic.bytespersecond', set => {
|
||||
|
@ -79,19 +84,13 @@ sub set_counters {
|
|||
output_template => 'traffic %s %s/s',
|
||||
output_change_bytes => 1,
|
||||
perfdatas => [
|
||||
{ label => 'traffic', template => '%s', min => 0, unit => 'B/s', cast_int => 1 },
|
||||
{ template => '%s', min => 0, unit => 'B/s', cast_int => 1 }
|
||||
]
|
||||
}
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
sub prefix_operation_output {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
return 'Operation completed ';
|
||||
}
|
||||
|
||||
sub new {
|
||||
my ($class, %options) = @_;
|
||||
my $self = $class->SUPER::new(package => __PACKAGE__, %options, statefile => 1, force_new_perfdata => 1);
|
||||
|
@ -106,7 +105,7 @@ sub new {
|
|||
'tls' => { name => 'use_tls' },
|
||||
'username:s' => { name => 'username' },
|
||||
'password:s' => { name => 'password' },
|
||||
'timeout:s' => { name => 'timeout', default => '30' },
|
||||
'timeout:s' => { name => 'timeout', default => '30' }
|
||||
});
|
||||
|
||||
return $self;
|
||||
|
@ -129,7 +128,7 @@ sub check_options {
|
|||
|
||||
sub ldap_error {
|
||||
my ($self, %options) = @_;
|
||||
|
||||
|
||||
if ($options{code} == 1) {
|
||||
$self->{output}->output_add(
|
||||
severity => 'unknown',
|
||||
|
@ -185,7 +184,8 @@ sub manage_selection {
|
|||
}
|
||||
}
|
||||
|
||||
$self->{global}->{threads_active_prct} = $self->{global}->{threads_active} * 100 / $self->{global}->{threads_max};
|
||||
$self->{global}->{threads_active_prct} = $self->{global}->{threads_active} * 100 / $self->{global}->{threads_max}
|
||||
if (defined($self->{global}->{threads_max}) && $self->{global}->{threads_max} > 0);
|
||||
|
||||
$self->{cache_name} = "openldap_" . $self->{mode} . '_' . $self->{option_results}->{hostname} . '_' .
|
||||
(defined($self->{option_results}->{filter_counters}) ? md5_hex($self->{option_results}->{filter_counters}) : md5_hex('all'));
|
||||
|
|
Loading…
Reference in New Issue