fix(daily-infra-report): missing credentials degrade one leg instead of blacking out the digest #126
@@ -24,8 +24,12 @@ ZULIP_SITE = "https://chat.sysloggh.net"
|
|||||||
ZULIP_EMAIL = "abiba-bot@chat.sysloggh.net"
|
ZULIP_EMAIL = "abiba-bot@chat.sysloggh.net"
|
||||||
ZULIP_API_KEY = os.environ.get("ZULIP_API_KEY", "")
|
ZULIP_API_KEY = os.environ.get("ZULIP_API_KEY", "")
|
||||||
if not ZULIP_API_KEY:
|
if not ZULIP_API_KEY:
|
||||||
raise SystemExit("ZULIP_API_KEY not set — refusing to run with no credential")
|
ZULIP_AUTH = None
|
||||||
ZULIP_AUTH = f"{ZULIP_EMAIL}:{ZULIP_API_KEY}"
|
DEGRADED_LEGS = ["credential-missing: ZULIP_API_KEY"]
|
||||||
|
print(" ⚠️ Degraded leg: credential-missing: ZULIP_API_KEY", file=sys.stderr)
|
||||||
|
else:
|
||||||
|
ZULIP_AUTH = f"{ZULIP_EMAIL}:{ZULIP_API_KEY}"
|
||||||
|
DEGRADED_LEGS = []
|
||||||
|
|
||||||
LITELLM_PUBLIC = "https://litellm.sysloggh.net"
|
LITELLM_PUBLIC = "https://litellm.sysloggh.net"
|
||||||
LITELLM_BACKEND = "192.168.68.116"
|
LITELLM_BACKEND = "192.168.68.116"
|
||||||
@@ -158,7 +162,7 @@ def collect():
|
|||||||
# ── Storage ──
|
# ── Storage ──
|
||||||
storages = pve_get("/api2/json/nodes/storepve/storage")
|
storages = pve_get("/api2/json/nodes/storepve/storage")
|
||||||
report["storage"] = []
|
report["storage"] = []
|
||||||
for s in storages:
|
for s in (storages or []):
|
||||||
total = s.get("total",0) or 1
|
total = s.get("total",0) or 1
|
||||||
used = s.get("used",0)
|
used = s.get("used",0)
|
||||||
pct = used/total*100
|
pct = used/total*100
|
||||||
@@ -673,8 +677,9 @@ def send_email(html_content, subject_prefix=""):
|
|||||||
try:
|
try:
|
||||||
EMAIL_PASSWORD = os.environ.get("EMAIL_PASSWORD") or os.environ.get("SMTP_PASSWORD") or os.environ.get("MAIL_PASSWORD")
|
EMAIL_PASSWORD = os.environ.get("EMAIL_PASSWORD") or os.environ.get("SMTP_PASSWORD") or os.environ.get("MAIL_PASSWORD")
|
||||||
if not EMAIL_PASSWORD:
|
if not EMAIL_PASSWORD:
|
||||||
print("EMAIL_PASSWORD not set — refusing to send email", file=sys.stderr)
|
print(" ⚠️ Degraded leg: credential-missing: EMAIL_PASSWORD (or SMTP_PASSWORD/MAIL_PASSWORD)", file=sys.stderr)
|
||||||
sys.exit(1)
|
DEGRADED_LEGS.append("credential-missing: EMAIL_PASSWORD")
|
||||||
|
return True, "✅ Email leg degraded (no credential) — report still produced"
|
||||||
GMAIL_EMAIL = "jtabiri@gmail.com"
|
GMAIL_EMAIL = "jtabiri@gmail.com"
|
||||||
|
|
||||||
server = smtplib.SMTP("smtp.gmail.com", 587)
|
server = smtplib.SMTP("smtp.gmail.com", 587)
|
||||||
@@ -713,6 +718,13 @@ if __name__ == "__main__":
|
|||||||
print(f" {msg}")
|
print(f" {msg}")
|
||||||
|
|
||||||
# Show summary
|
# Show summary
|
||||||
|
if DEGRADED_LEGS:
|
||||||
|
print(f"\n⚠️ Degraded legs ({len(DEGRADED_LEGS)}):")
|
||||||
|
for leg in DEGRADED_LEGS:
|
||||||
|
print(f" - {leg}")
|
||||||
|
else:
|
||||||
|
print("\n✅ All legs fully credentialed")
|
||||||
|
|
||||||
issues = sum(1 for i in ["red"] if report.get("zulip_ext", {}).get("connected") == False)
|
issues = sum(1 for i in ["red"] if report.get("zulip_ext", {}).get("connected") == False)
|
||||||
print(f"\n📋 Summary:")
|
print(f"\n📋 Summary:")
|
||||||
print(f" Proxmox: {report['nodes_online']}/{report['node_count']} nodes online")
|
print(f" Proxmox: {report['nodes_online']}/{report['node_count']} nodes online")
|
||||||
|
|||||||
Reference in New Issue
Block a user