mirror of
https://github.com/hansjone/netx.git
synced 2026-10-11 19:33:20 +08:00
Add biz_state monitoring with shared LLDP parse and batch collect.
Introduce ParseProfile-based business state tasks that reuse LLDP parsing for snapshot batches (separate from topology Fabric writes), with scheduler, export, and a Phase1 UI under network tasks. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
066158d2f7
commit
4fa1b9b4dc
27 changed files with 2487 additions and 1 deletions
|
|
@ -62,6 +62,12 @@ def run_api_startup() -> None:
|
|||
apply_topology_schema_safety_net(conn)
|
||||
apply_collection_schema_safety_net(conn)
|
||||
apply_hop_schema_safety_net(conn)
|
||||
try:
|
||||
from .biz_state.schema_ensure import apply_biz_state_schema
|
||||
|
||||
apply_biz_state_schema(conn)
|
||||
except Exception:
|
||||
_log.exception("startup: biz_state schema safety patch failed")
|
||||
except Exception:
|
||||
_log.exception("startup: auth/topology/collection/hop schema safety patches failed")
|
||||
if skip_ddl and alembic_ok:
|
||||
|
|
@ -133,6 +139,22 @@ def run_api_startup() -> None:
|
|||
pt_cleared = recover_port_traffic_on_startup(db)
|
||||
if pt_cleared:
|
||||
_log.info("startup: cleared %s port_traffic stuck collect_running flag(s)", pt_cleared)
|
||||
try:
|
||||
from .models import BizStateTask
|
||||
|
||||
stuck = (
|
||||
db.query(BizStateTask)
|
||||
.filter(BizStateTask.collect_running.is_(True))
|
||||
.all()
|
||||
)
|
||||
for t in stuck:
|
||||
t.collect_running = False
|
||||
t.last_error = (t.last_error or "")[:900] + " | reset_on_startup"
|
||||
if stuck:
|
||||
db.commit()
|
||||
_log.info("startup: cleared %s biz_state stuck collect_running flag(s)", len(stuck))
|
||||
except Exception:
|
||||
_log.exception("startup: biz_state collect_running recovery failed")
|
||||
try:
|
||||
from .port_traffic_migrate import backfill_port_traffic_series
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue