Skip to content

Commit

Permalink
Fix monitoring stable vs not
Browse files Browse the repository at this point in the history
  • Loading branch information
jmwanderer committed Jun 24, 2024
1 parent 248ed79 commit b1ed1cf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
13 changes: 6 additions & 7 deletions mnet/frr_topo.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ def __init__(self, name: str, default_ip: str, uplinks: list[dict[str,typing.Any
for link in uplinks:
entry = IPPoolEntry(network=link["nw"], ip1=link["ip1"], ip2=link["ip2"])
self.ip_pool.append(entry)
print(f"added pool entry {entry.network}")

def stable_node(self) -> bool:
"""
Expand Down Expand Up @@ -444,6 +443,11 @@ def __init__(self, topo: NetxTopo, net: mininet.net.Mininet, stable_monitors: bo
self.ground_stations: dict[str, GroundStation] = {}
self.stable_monitors = stable_monitors

# Create monitoring DB file.
fd, self.db_file = tempfile.mkstemp(suffix=".sqlite")
open(fd, "r").close()
print(f"Master db file {self.db_file}")

for frr_router in topo.routers:
self.nodes[frr_router.name] = frr_router
self.routers[frr_router.name] = frr_router
Expand All @@ -452,18 +456,13 @@ def __init__(self, topo: NetxTopo, net: mininet.net.Mininet, stable_monitors: bo
self.ground_stations[ground_station.name] = ground_station

self.stat_samples = []
fd, self.db_file = tempfile.mkstemp(suffix=".sqlite")
self.net = net
self.stub_net = False
# If net is none, we are running in a stub mode without mininet or FRR.
if self.net is None:
self.net = StubMininet()
self.stub_net = True

# Create monitoring DB file.
open(fd, "r").close()
print(f"Master db file {self.db_file}")

def start_routers(self) -> None:
# Populate master db file
data = []
Expand All @@ -472,7 +471,7 @@ def start_routers(self) -> None:
data.append((router.name, router.defaultIP(), router.stable_node()))
# Not stable targets - don't monitor
for station in self.ground_stations.values():
data.append((station.name, station.defaultIP(), router.stable_node()))
data.append((station.name, station.defaultIP(), station.stable_node()))
mnet.pmonitor.init_targets(self.db_file, data)

# Start all nodes
Expand Down
3 changes: 1 addition & 2 deletions mnet/pmonitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,7 @@ def monitor_targets(db_path_master: str, db_path_local: str, address: str):
if not TEST:
time.sleep(5)
running = can_run(db_master, address)
target_running = is_running(db_master, target[1])
if running and target_running:
if running:
sample_target(db_local, target[0], target[1])
if TEST:
set_can_run(db_master, address, False)
Expand Down

0 comments on commit b1ed1cf

Please sign in to comment.