Trigger immediate poll after SNMP discovery completes
This commit is contained in:
parent
62689ea939
commit
8f7ed19d34
1 changed files with 11 additions and 0 deletions
|
|
@ -48,6 +48,9 @@ defmodule Towerops.Snmp.PollerWorker do
|
|||
def init(equipment_id) do
|
||||
equipment = Equipment.get_equipment!(equipment_id)
|
||||
|
||||
# Subscribe to discovery completion events for this equipment
|
||||
Phoenix.PubSub.subscribe(Towerops.PubSub, "equipment:#{equipment_id}")
|
||||
|
||||
if equipment.snmp_enabled do
|
||||
# Get the device to check if it has sensors/interfaces
|
||||
device = Snmp.get_device_with_associations(equipment_id)
|
||||
|
|
@ -67,6 +70,14 @@ defmodule Towerops.Snmp.PollerWorker do
|
|||
{:noreply, state}
|
||||
end
|
||||
|
||||
@impl true
|
||||
def handle_info({:discovery_completed, _equipment_id}, state) do
|
||||
Logger.info("Discovery completed, triggering immediate poll")
|
||||
# Trigger immediate poll after discovery
|
||||
send(self(), :poll_data)
|
||||
{:noreply, state}
|
||||
end
|
||||
|
||||
@impl true
|
||||
def handle_cast(:poll_now, state) do
|
||||
_ = perform_poll(state.equipment_id)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue