port_error_perc macro (#15016)

* port_error_perc

* Update macros.json

* Update macros.json

* Update querybuilder.json

* Revert

* Update macros.json

* Change macro names so they match usage_perc

* Try *100.0

* Attempt 2 - Encapsulate in parenthesis

* Undo Parenthesis

* Trying laf's suggestions

* Update QueryBuilderFilter.php
This commit is contained in:
Justin Lentz 2023-07-31 22:26:21 -05:00 committed by GitHub
parent c030b0c00e
commit 90b16bab81
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View File

@ -70,7 +70,7 @@ class QueryBuilderFilter implements \JsonSerializable
continue; // don't include the time based macros, they don't work like that
}
if (Str::endsWith($key, '_usage_perc') || Str::startsWith($key, 'packet_loss_')) {
if (Str::endsWith($key, '_perc') || Str::startsWith($key, 'packet_loss_')) {
$this->filter[$field] = [
'id' => $field,
'type' => 'integer',

View File

@ -20,6 +20,8 @@
"past_30m": "DATE_SUB(NOW(),INTERVAL 30 MINUTE)",
"past_60m": "DATE_SUB(NOW(),INTERVAL 60 MINUTE)",
"port": "(%ports.deleted = 0 && %ports.ignore = 0 && %ports.disabled = 0)",
"port_out_error_perc": "((%ports.ifOutErrors_rate) \/ %ports.ifOutUcastPkts_rate)*100",
"port_in_error_perc": "((%ports.ifInErrors_rate) \/ %ports.ifInUcastPkts_rate)*100",
"port_down": "(%ports.ifOperStatus = \"down\" && %ports.ifAdminStatus != \"down\" && %macros.port)",
"port_up": "(%ports.ifOperStatus = \"up\" && %ports.ifAdminStatus = \"up\" && %macros.port)",
"port_usage_perc": "((SELECT IF(%ports.ifOutOctets_rate>%ports.ifInOctets_rate, %ports.ifOutOctets_rate, %ports.ifInOctets_rate)*8) \/ %ports.ifSpeed)*100",