fix/traffic-graph-monitored-nil (#127)
Reviewed-on: graham/towerops-web#127
This commit is contained in:
parent
20d63c408a
commit
5436a30098
1 changed files with 11 additions and 3 deletions
|
|
@ -233,6 +233,13 @@ defmodule ToweropsWeb.DeviceLive.Show do
|
|||
end
|
||||
end
|
||||
|
||||
@impl true
|
||||
def handle_info({:alert_changed, _organization_id}, socket) do
|
||||
# Alert changed in this organization - we don't show alerts on device page
|
||||
# so just ignore this message
|
||||
{:noreply, socket}
|
||||
end
|
||||
|
||||
@impl true
|
||||
def handle_info({FormComponent, {:check_created, _check}}, socket) do
|
||||
{:noreply,
|
||||
|
|
@ -1204,10 +1211,10 @@ defmodule ToweropsWeb.DeviceLive.Show do
|
|||
|
||||
# Calculate BPS per interface first, then aggregate by timestamp
|
||||
# This avoids issues with misaligned timestamps between interfaces
|
||||
# Only processes monitored interfaces to match actual traffic being tracked
|
||||
# Only processes monitored interfaces (nil treated as true for backwards compatibility)
|
||||
defp aggregate_interface_traffic_stats(interfaces, since) do
|
||||
interfaces
|
||||
|> Enum.filter(& &1.monitored)
|
||||
|> Enum.filter(&(&1.monitored != false))
|
||||
|> Enum.flat_map(fn interface ->
|
||||
interface.id
|
||||
|> Snmp.get_interface_stats(since: since, limit: 1000)
|
||||
|
|
@ -1407,9 +1414,10 @@ defmodule ToweropsWeb.DeviceLive.Show do
|
|||
# Sums capacity of active interfaces at each timestamp
|
||||
defp calculate_interface_capacity_data(all_stats, device) do
|
||||
# Build a map of interface_id -> {rx_capacity, tx_capacity} for quick lookup
|
||||
# Only include monitored interfaces (nil treated as true for backwards compatibility)
|
||||
interface_capacity_map =
|
||||
device.interfaces
|
||||
|> Enum.filter(& &1.monitored)
|
||||
|> Enum.filter(&(&1.monitored != false))
|
||||
|> Map.new(fn interface ->
|
||||
cap = interface.configured_capacity_bps || interface.if_speed || 0
|
||||
{interface.id, {cap, cap}}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue