Add balance monitor, low-balance admin banner, dry-run auto-topup (sweep) framework
This commit is contained in:
21
monitor.py
Normal file
21
monitor.py
Normal file
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Monitor IPRoyal reseller balance. Prints an ALERT line (for cron -> Telegram)
|
||||
when below threshold. Exit 0 = OK, 1 = low/failed."""
|
||||
import sys
|
||||
|
||||
import iproyal
|
||||
|
||||
threshold = iproyal.CFG.get("alerts", {}).get("low_balance_threshold", 10.0)
|
||||
|
||||
try:
|
||||
bal = iproyal.get_balance()
|
||||
except Exception as e:
|
||||
print(f"ALERT: IPRoyal balance check FAILED: {e}")
|
||||
sys.exit(1)
|
||||
|
||||
if isinstance(bal, (int, float)) and bal < threshold:
|
||||
print(f"ALERT: IPRoyal reseller balance ${bal:.2f} is below ${threshold:.2f}. Top up now.")
|
||||
sys.exit(1)
|
||||
|
||||
print(f"OK: IPRoyal balance ${bal}")
|
||||
sys.exit(0)
|
||||
Reference in New Issue
Block a user