INNER CODE UNIT · Python
run_snapshot_thread
itbench-hub/ITBench · scenarios/sre/tools/kubernetes-topology-monitor/main.py:21
def run_snapshot_thread(topology, interval, logger):
"""Periodically save topology snapshots."""
while True:
try:
topology.save_snapshot()
topology.cleanup_old_snapshots()
time.sleep(interval)
except Exception as e:
logger.error(f"Error in snapshot thread: {e}", exc_info=True)
time.sleep(60)
def parse_args():
"""Parse command line arguments."""
parser = argparse.ArgumentParser(description='Kubernetes Topology Monitor')
parser.add_argument('--kubeconfig',
help='Path to kubeconfig file. If not specified, uses default ~/.kube/config. '
'The current-context from the kubeconfig will be used.')
parser.add_argument('--data-dir', default='./topology_data',