diff --git a/lib/towerops/workers/check_executor_worker.ex b/lib/towerops/workers/check_executor_worker.ex index e95e9a11..0cfcb547 100644 --- a/lib/towerops/workers/check_executor_worker.ex +++ b/lib/towerops/workers/check_executor_worker.ex @@ -40,6 +40,7 @@ defmodule Towerops.Workers.CheckExecutorWorker do require Logger @snmp_check_types ~w(snmp_sensor snmp_interface snmp_processor snmp_storage) + @service_check_types ~w(http tcp dns) @impl Oban.Worker def perform(%Oban.Job{args: %{"check_id" => check_id}}) do @@ -56,6 +57,9 @@ defmodule Towerops.Workers.CheckExecutorWorker do should_skip_snmp_check?(check) -> Logger.debug("Skipping SNMP check #{check_id} - Phoenix SNMP disabled or device assigned to agent") + should_skip_service_check?(check) -> + Logger.debug("Skipping service check #{check_id} - device assigned to agent") + true -> execute_and_record(check) schedule_next_check(check) @@ -72,6 +76,14 @@ defmodule Towerops.Workers.CheckExecutorWorker do defp should_skip_snmp_check?(_check), do: false + defp should_skip_service_check?(%{check_type: check_type} = check) when check_type in @service_check_types do + # Skip service checks (HTTP/TCP/DNS) if device is assigned to an agent + # The agent will execute these checks from the device's network location + check.device_id != nil and not Agents.should_phoenix_poll_device?(%Device{id: check.device_id}) + end + + defp should_skip_service_check?(_check), do: false + defp execute_and_record(check) do Logger.debug("Executing check #{check.id} (#{check.check_type})") diff --git a/lib/towerops_web/live/check_live/form_component.ex b/lib/towerops_web/live/check_live/form_component.ex index 78e29eff..7fb617a9 100644 --- a/lib/towerops_web/live/check_live/form_component.ex +++ b/lib/towerops_web/live/check_live/form_component.ex @@ -97,21 +97,21 @@ defmodule ToweropsWeb.CheckLive.FormComponent do -