16 lines
586 B
Python
16 lines
586 B
Python
import requests
|
|
import urllib3
|
|
urllib3.disable_warnings()
|
|
|
|
headers = {"X-API-Key": "ptr_TCVm8ujeB4zT0oRejyMCwKw5enaPG/uKj1KuF0uOWX8="}
|
|
url = "https://140.44.4.71:9443/api/endpoints/3/docker/containers/json?all=1"
|
|
|
|
r = requests.get(url, headers=headers, verify=False)
|
|
print("Portainer containers status:", r.status_code)
|
|
if r.status_code == 200:
|
|
data = r.json()
|
|
running = len([c for c in data if c.get("State") == "running"])
|
|
stopped = len([c for c in data if c.get("State") == "exited"])
|
|
print(f"Containers: Running: {running}, Stopped: {stopped}, Total: {len(data)}")
|
|
|