more renames

This commit is contained in:
Graham McIntire 2026-01-17 15:13:56 -06:00
parent b6f4946385
commit 541ab7e7d6
No known key found for this signature in database
10 changed files with 38 additions and 35 deletions

View file

@ -3,3 +3,6 @@
* When adding a new device, allow the community string to be empty so it will inherit from the parent
* add and track ICMP pings for each device. it should also put a latency graph on the device page that links to the universal graph like the other graphs
* when adding a new device, make it a tab selector to show the default SNMP & ICMP or ICMP only
* add valkey as a k8s sidecar
* add the latest exq to the web app
* set up any jobs that need to be run in the background to use exq

View file

@ -82,7 +82,7 @@ defmodule Towerops.Agents.Stats do
## Examples
iex> get_equipment_assignment_breakdown(org_id)
iex> get_device_assignment_breakdown(org_id)
%{
direct: 50,
site: 30,
@ -90,7 +90,7 @@ defmodule Towerops.Agents.Stats do
cloud: 5
}
"""
def get_equipment_assignment_breakdown(organization_id) do
def get_device_assignment_breakdown(organization_id) do
# Use a single SQL query with CASE to determine assignment source
# device into memory and calling get_effective_agent_token_with_source
results =
@ -266,12 +266,12 @@ defmodule Towerops.Agents.Stats do
## Examples
iex> get_unmonitored_equipment(org_id)
iex> get_unmonitored_devices(org_id)
[
%{id: "uuid", name: "Switch-01", site_name: "DC1"}
]
"""
def get_unmonitored_equipment(organization_id) do
def get_unmonitored_devices(organization_id) do
# device has no agent assigned
# device into memory
Repo.all(

View file

@ -50,11 +50,11 @@ defmodule Towerops.Snmp do
## Examples
iex> discover_equipment(device)
iex> discover_device(device)
{:ok, %Device{}}
"""
def discover_equipment(%DeviceSchema{} = device) do
Discovery.discover_equipment(device)
def discover_device(%DeviceSchema{} = device) do
Discovery.discover_device(device)
end
@doc """

View file

@ -83,19 +83,19 @@ defmodule Towerops.Snmp.Discovery do
}
@doc """
Runs discovery for a single piece of device.
Runs discovery for a single device.
Returns {:ok, device} or {:error, reason}.
## Examples
iex> discover_equipment(device)
iex> discover_device(device)
{:ok, %Device{manufacturer: "Cisco", model: "C2960"}}
iex> discover_equipment(device_without_snmp)
iex> discover_device(device_without_snmp)
{:error, :snmp_not_enabled}
"""
@spec discover_equipment(DeviceSchema.t()) :: {:ok, Device.t()} | {:error, term()}
def discover_equipment(%DeviceSchema{} = device) do
@spec discover_device(DeviceSchema.t()) :: {:ok, Device.t()} | {:error, term()}
def discover_device(%DeviceSchema{} = device) do
if device.snmp_enabled do
Logger.info("Starting SNMP discovery for device: #{device.name} (#{device.ip_address})")
@ -149,7 +149,7 @@ defmodule Towerops.Snmp.Discovery do
results =
device_list
|> Task.async_stream(
&discover_equipment/1,
&discover_device/1,
max_concurrency: 5,
timeout: 60_000,
on_timeout: :kill_task

View file

@ -318,7 +318,7 @@ defmodule ToweropsWeb.AgentChannel do
Logger.info("Discovery results received for #{device.name}, triggering full discovery")
Task.start(fn ->
case Discovery.discover_equipment(device) do
case Discovery.discover_device(device) do
{:ok, _device} ->
Logger.info("Full discovery completed for #{device.name}")

View file

@ -22,7 +22,7 @@ defmodule ToweropsWeb.AgentLive.Index do
# Get organization-wide agent health statistics
agent_health_stats = Stats.get_organization_agent_health(organization.id)
assignment_breakdown = Stats.get_equipment_assignment_breakdown(organization.id)
assignment_breakdown = Stats.get_device_assignment_breakdown(organization.id)
offline_agents = Stats.get_offline_agents(organization.id)
# Get agent image URL from config or use default
@ -71,7 +71,7 @@ defmodule ToweropsWeb.AgentLive.Index do
# Refresh health statistics
agent_health_stats = Stats.get_organization_agent_health(organization.id)
assignment_breakdown = Stats.get_equipment_assignment_breakdown(organization.id)
assignment_breakdown = Stats.get_device_assignment_breakdown(organization.id)
offline_agents = Stats.get_offline_agents(organization.id)
{:noreply,

View file

@ -157,7 +157,7 @@ defmodule ToweropsWeb.DeviceLive.Form do
# Run discovery in background
_ =
Task.start(fn ->
Snmp.discover_equipment(device)
Snmp.discover_device(device)
end)
{:noreply, put_flash(socket, :info, "Discovery started...")}
@ -214,7 +214,7 @@ defmodule ToweropsWeb.DeviceLive.Form do
defp handle_device_creation(device) do
if device.snmp_enabled do
_ = Task.start(fn -> Snmp.discover_equipment(device) end)
_ = Task.start(fn -> Snmp.discover_device(device) end)
"Device created successfully. SNMP discovery started in background."
else
"Device created successfully"
@ -223,7 +223,7 @@ defmodule ToweropsWeb.DeviceLive.Form do
defp handle_device_update(old_device, device) do
if should_trigger_snmp_discovery?(old_device, device) do
_ = Task.start(fn -> Snmp.discover_equipment(device) end)
_ = Task.start(fn -> Snmp.discover_device(device) end)
"Device updated successfully. SNMP discovery started in background."
else
"Device updated successfully"

View file

@ -11,7 +11,7 @@ defmodule ToweropsWeb.Org.SettingsLive do
available_agents = Agents.list_organization_agent_tokens(organization.id)
# Get assignment breakdown to show impact
assignment_breakdown = Agents.Stats.get_equipment_assignment_breakdown(organization.id)
assignment_breakdown = Agents.Stats.get_device_assignment_breakdown(organization.id)
changeset = Organizations.change_organization(organization)

View file

@ -98,12 +98,12 @@ defmodule Towerops.Agents.StatsTest do
end
end
describe "get_equipment_assignment_breakdown/1" do
describe "get_device_assignment_breakdown/1" do
test "returns zero counts for organization with no devices" do
user = user_fixture()
org = organization_fixture(user.id)
breakdown = Stats.get_equipment_assignment_breakdown(org.id)
breakdown = Stats.get_device_assignment_breakdown(org.id)
assert breakdown == %{direct: 0, site: 0, organization: 0, cloud: 0}
end
@ -138,7 +138,7 @@ defmodule Towerops.Agents.StatsTest do
snmp_version: "2c"
})
breakdown = Stats.get_equipment_assignment_breakdown(org.id)
breakdown = Stats.get_device_assignment_breakdown(org.id)
assert breakdown.direct == 1
assert breakdown.cloud == 1
@ -265,7 +265,7 @@ defmodule Towerops.Agents.StatsTest do
end
end
describe "get_unmonitored_equipment/1" do
describe "get_unmonitored_devices/1" do
test "returns empty list when all devices has agents" do
user = user_fixture()
org = organization_fixture(user.id)
@ -285,7 +285,7 @@ defmodule Towerops.Agents.StatsTest do
{:ok, _assignment} = Agents.assign_device_to_agent(agent_token.id, device.id)
unmonitored = Stats.get_unmonitored_equipment(org.id)
unmonitored = Stats.get_unmonitored_devices(org.id)
assert unmonitored == []
end
@ -306,7 +306,7 @@ defmodule Towerops.Agents.StatsTest do
monitoring_enabled: true
})
unmonitored = Stats.get_unmonitored_equipment(org.id)
unmonitored = Stats.get_unmonitored_devices(org.id)
assert length(unmonitored) == 1
eq = hd(unmonitored)
@ -330,7 +330,7 @@ defmodule Towerops.Agents.StatsTest do
monitoring_enabled: true
})
unmonitored = Stats.get_unmonitored_equipment(org.id)
unmonitored = Stats.get_unmonitored_devices(org.id)
assert unmonitored == []
end
@ -351,7 +351,7 @@ defmodule Towerops.Agents.StatsTest do
monitoring_enabled: false
})
unmonitored = Stats.get_unmonitored_equipment(org.id)
unmonitored = Stats.get_unmonitored_devices(org.id)
assert unmonitored == []
end

View file

@ -26,7 +26,7 @@ defmodule Towerops.Snmp.DiscoveryTest do
%{organization: organization, site: site}
end
describe "discover_equipment/1" do
describe "discover_device/1" do
test "returns error when SNMP is not enabled", %{site: site} do
{:ok, device} =
Towerops.Devices.create_device(%{
@ -36,7 +36,7 @@ defmodule Towerops.Snmp.DiscoveryTest do
snmp_enabled: false
})
assert {:error, :snmp_not_enabled} = Discovery.discover_equipment(device)
assert {:error, :snmp_not_enabled} = Discovery.discover_device(device)
end
test "successfully discovers MikroTik device", %{site: site} do
@ -147,7 +147,7 @@ defmodule Towerops.Snmp.DiscoveryTest do
end
end)
assert {:ok, device} = Discovery.discover_equipment(device)
assert {:ok, device} = Discovery.discover_device(device)
assert device.manufacturer == "MikroTik"
assert device.model == "RB750"
@ -213,7 +213,7 @@ defmodule Towerops.Snmp.DiscoveryTest do
{:ok, []}
end)
assert {:ok, device} = Discovery.discover_equipment(device)
assert {:ok, device} = Discovery.discover_device(device)
assert device.manufacturer == "Cisco"
assert device.model == "C2960"
@ -237,7 +237,7 @@ defmodule Towerops.Snmp.DiscoveryTest do
{:error, :timeout}
end)
assert {:error, :timeout} = Discovery.discover_equipment(device)
assert {:error, :timeout} = Discovery.discover_device(device)
end
test "handles partial discovery failure gracefully", %{site: site} do
@ -293,7 +293,7 @@ defmodule Towerops.Snmp.DiscoveryTest do
end)
# Should succeed even with failed interface/sensor discovery
assert {:ok, device} = Discovery.discover_equipment(device)
assert {:ok, device} = Discovery.discover_device(device)
assert device.manufacturer == "Unknown"
@ -357,7 +357,7 @@ defmodule Towerops.Snmp.DiscoveryTest do
{:ok, []}
end)
assert {:ok, updated_device} = Discovery.discover_equipment(device)
assert {:ok, updated_device} = Discovery.discover_device(device)
# Should be same device, updated
assert updated_device.id == initial_device.id