From c9b47b1d48795bb7886351b8484d86e98f26596d Mon Sep 17 00:00:00 2001 From: qgarnier Date: Thu, 3 Jun 2021 09:04:15 +0200 Subject: [PATCH] fix(athonet/epc): mode license - illegal division by zero (#2844) --- .../network/athonet/epc/snmp/mode/license.pm | 36 +++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/centreon-plugins/network/athonet/epc/snmp/mode/license.pm b/centreon-plugins/network/athonet/epc/snmp/mode/license.pm index 7ff8272fe..2d13649bf 100644 --- a/centreon-plugins/network/athonet/epc/snmp/mode/license.pm +++ b/centreon-plugins/network/athonet/epc/snmp/mode/license.pm @@ -307,23 +307,29 @@ sub manage_selection { ); } - $self->{license}->{global}->{users}->{used} = $result->{users_connected}; - $self->{license}->{global}->{users}->{total} = $result->{max_active_users}; - $self->{license}->{global}->{users}->{free} = $result->{max_active_users} - $result->{users_connected}; - $self->{license}->{global}->{users}->{prct_used} = $result->{users_connected} * 100 / $result->{max_active_users}; - $self->{license}->{global}->{users}->{prct_free} = 100 - $self->{license}->{global}->{users}->{prct_used}; + if ($result->{max_active_users} > 0) { + $self->{license}->{global}->{users}->{used} = $result->{users_connected}; + $self->{license}->{global}->{users}->{total} = $result->{max_active_users}; + $self->{license}->{global}->{users}->{free} = $result->{max_active_users} - $result->{users_connected}; + $self->{license}->{global}->{users}->{prct_used} = $result->{users_connected} * 100 / $result->{max_active_users}; + $self->{license}->{global}->{users}->{prct_free} = 100 - $self->{license}->{global}->{users}->{prct_used}; + } - $self->{license}->{global}->{sessions}->{used} = $result->{active_connections}; - $self->{license}->{global}->{sessions}->{total} = $result->{max_active_sessions}; - $self->{license}->{global}->{sessions}->{free} = $result->{max_active_sessions} - $result->{active_connections}; - $self->{license}->{global}->{sessions}->{prct_used} = $result->{active_connections} * 100 / $result->{max_active_sessions}; - $self->{license}->{global}->{sessions}->{prct_free} = 100 - $self->{license}->{global}->{sessions}->{prct_used}; + if ($result->{max_active_sessions} > 0) { + $self->{license}->{global}->{sessions}->{used} = $result->{active_connections}; + $self->{license}->{global}->{sessions}->{total} = $result->{max_active_sessions}; + $self->{license}->{global}->{sessions}->{free} = $result->{max_active_sessions} - $result->{active_connections}; + $self->{license}->{global}->{sessions}->{prct_used} = $result->{active_connections} * 100 / $result->{max_active_sessions}; + $self->{license}->{global}->{sessions}->{prct_free} = 100 - $self->{license}->{global}->{sessions}->{prct_used}; + } - $self->{license}->{global}->{usim}->{used} = $result->{hss_provisioned_users}; - $self->{license}->{global}->{usim}->{total} = $result->{max_provisioned_usim}; - $self->{license}->{global}->{usim}->{free} = $result->{max_provisioned_usim} - $result->{hss_provisioned_users}; - $self->{license}->{global}->{usim}->{prct_used} = $result->{hss_provisioned_users} * 100 / $result->{max_provisioned_usim}; - $self->{license}->{global}->{usim}->{prct_free} = 100 - $self->{license}->{global}->{users}->{prct_used}; + if ($result->{max_provisioned_usim} > 0) { + $self->{license}->{global}->{usim}->{used} = $result->{hss_provisioned_users}; + $self->{license}->{global}->{usim}->{total} = $result->{max_provisioned_usim}; + $self->{license}->{global}->{usim}->{free} = $result->{max_provisioned_usim} - $result->{hss_provisioned_users}; + $self->{license}->{global}->{usim}->{prct_used} = $result->{hss_provisioned_users} * 100 / $result->{max_provisioned_usim}; + $self->{license}->{global}->{usim}->{prct_free} = 100 - $self->{license}->{global}->{users}->{prct_used}; + } } 1;