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:
Stef
2023-04-15 05:11:36 +02:00
committed by GitHub
parent b6572e0acc
commit 0430f6acb1
3 changed files with 4 additions and 3 deletions
+1 -1
View File
@@ -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) {
+1 -1
View File
@@ -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