Update exporter.py
All checks were successful
Build / build (push) Successful in 5s

This commit is contained in:
2026-03-18 12:28:58 +03:00
parent 54336fd622
commit 6e5342d2a9

View File

@@ -1,7 +1,8 @@
import time
import threading
import docker
from prometheus_client import start_http_server, Gauge, Counter, Info
from concurrent.futures import ThreadPoolExecutor
from prometheus_client import start_http_server, Gauge, Counter
from concurrent.futures import ThreadPoolExecutor, wait, FIRST_EXCEPTION
client = docker.from_env()
@@ -49,12 +50,19 @@ def collect_one(c):
except Exception:
pass
def collect():
containers = client.containers.list()
with ThreadPoolExecutor(max_workers=10) as executor:
executor.map(collect_one, containers)
start_http_server(9338)
def collect_loop():
while True:
collect()
try:
containers = client.containers.list()
with ThreadPoolExecutor(max_workers=20) as executor:
executor.map(collect_one, containers)
except Exception:
pass
time.sleep(15)
threading.Thread(target=collect_loop, daemon=True).start()
start_http_server(9338)
while True:
time.sleep(60)