mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Cisco QFP polling fixes (#14961)
* fix cisco-qfp Division by zero * fix percentage calc * linting * another zero in RRD. the (int) might be consequential errors and should hurt... * no float for average_package * Update includes/polling/cisco-qfp.inc.php Co-authored-by: Tony Murray <murraytony@gmail.com> * Add floor --------- Co-authored-by: Tony Murray <murraytony@gmail.com>
This commit is contained in:
@@ -33,7 +33,7 @@ if ($width > '500') {
|
||||
|
||||
$descr = \LibreNMS\Data\Store\Rrd::fixedSafeDescr(short_hrDeviceDescr($components['name']), $descr_len);
|
||||
|
||||
$perc = $components['memory_used'] * 100 / $components['memory_total'];
|
||||
$perc = \LibreNMS\Util\Number::calculatePercent((int) $components['memory_used'], (int) $tmp_component['memory_total']);
|
||||
|
||||
$background = \LibreNMS\Util\Color::percentage($perc, 75);
|
||||
|
||||
|
||||
@@ -187,7 +187,8 @@ foreach ($components as $component_id => $tmp_component) {
|
||||
/*
|
||||
* QFP Memory resources
|
||||
*/
|
||||
$mem_prec = $tmp_component['memory_used'] * 100 / $tmp_component['memory_total'];
|
||||
$mem_prec = Number::calculatePercent((int) $tmp_component['memory_used'], (int) $tmp_component['memory_total']);
|
||||
|
||||
if ($mem_prec < 75) {
|
||||
$mem_label = 'label-success';
|
||||
} elseif ($mem_prec < 90) {
|
||||
|
||||
@@ -101,7 +101,7 @@ if (! empty($components) && is_array($components)) {
|
||||
if (! empty($util_data) && ! empty($memory_data)) {
|
||||
$total_packets = $util_data[$util_oids['InTotalPps']] + $util_data[$util_oids['OutTotalPps']];
|
||||
$throughput = $util_data[$util_oids['InTotalBps']] + $util_data[$util_oids['OutTotalBps']];
|
||||
$average_packet = $throughput / 8 / $total_packets;
|
||||
$average_packet = $total_packets ? floor($throughput / 8 / $total_packets) : 0;
|
||||
/*
|
||||
* Create component data array for `component_prefs`
|
||||
* and update components
|
||||
|
||||
Reference in New Issue
Block a user