mirror of
https://github.com/malarinv/iperf3-monitor.git
synced 2026-03-08 05:22:35 +00:00
Compare commits
1 Commits
v0.2.4
...
587290f1fb
| Author | SHA1 | Date | |
|---|---|---|---|
| 587290f1fb |
@@ -92,16 +92,18 @@ def discover_iperf_servers():
|
|||||||
|
|
||||||
logging.info(f"Discovering iperf3 servers with label '{label_selector}' in namespace '{namespace}'")
|
logging.info(f"Discovering iperf3 servers with label '{label_selector}' in namespace '{namespace}'")
|
||||||
|
|
||||||
ret = v1.list_pod_for_all_namespaces(label_selector=label_selector, watch=False)
|
# Use list_namespaced_pod to query only the specified namespace
|
||||||
|
ret = v1.list_namespaced_pod(namespace=namespace, label_selector=label_selector, watch=False)
|
||||||
|
|
||||||
servers = []
|
servers = []
|
||||||
for item in ret.items:
|
for item in ret.items:
|
||||||
|
# No need to filter by namespace here as the API call is already namespaced
|
||||||
if item.status.pod_ip and item.status.phase == 'Running':
|
if item.status.pod_ip and item.status.phase == 'Running':
|
||||||
servers.append({
|
servers.append({
|
||||||
'ip': item.status.pod_ip,
|
'ip': item.status.pod_ip,
|
||||||
'node_name': item.spec.node_name # Node where the iperf server pod is running
|
'node_name': item.spec.node_name # Node where the iperf server pod is running
|
||||||
})
|
})
|
||||||
logging.info(f"Discovered {len(servers)} iperf3 server pods.")
|
logging.info(f"Discovered {len(servers)} iperf3 server pods in namespace '{namespace}'.")
|
||||||
return servers
|
return servers
|
||||||
except config.ConfigException as e:
|
except config.ConfigException as e:
|
||||||
logging.error(f"Kubernetes config error: {e}. Is the exporter running in a cluster with RBAC permissions?")
|
logging.error(f"Kubernetes config error: {e}. Is the exporter running in a cluster with RBAC permissions?")
|
||||||
|
|||||||
Reference in New Issue
Block a user