Update agents, dashboard, kb +2 more (+6 ~11)

This commit is contained in:
Echo
2026-01-31 22:05:53 +00:00
parent 6555ea28ee
commit d2d9016da5
17 changed files with 900 additions and 187 deletions

View File

@@ -14,6 +14,7 @@ SCRIPT_DIR = Path(__file__).parent
CONFIG_FILE = SCRIPT_DIR / "config.json"
VERSIONS_FILE = SCRIPT_DIR / "versions.json"
LOG_FILE = SCRIPT_DIR / "monitor.log"
DASHBOARD_STATUS = SCRIPT_DIR.parent.parent / "dashboard" / "status.json"
SSL_CTX = ssl.create_default_context()
SSL_CTX.check_hostname = False
@@ -171,6 +172,21 @@ def check_page(page, saved_versions):
log(f"OK: {page_id}")
return None
def update_dashboard_status(has_changes, changes_count):
"""Actualizează status.json pentru dashboard"""
try:
status = load_json(DASHBOARD_STATUS, {})
status['anaf'] = {
'ok': not has_changes,
'status': 'MODIFICĂRI' if has_changes else 'OK',
'message': f'{changes_count} modificări detectate' if has_changes else 'Nicio modificare detectată',
'lastCheck': datetime.now().strftime('%d %b %Y, %H:%M'),
'changesCount': changes_count
}
save_json(DASHBOARD_STATUS, status)
except Exception as e:
log(f"ERROR updating dashboard status: {e}")
def main():
log("=== Starting ANAF monitor v2 ===")
@@ -184,6 +200,10 @@ def main():
all_changes.append(result)
save_json(VERSIONS_FILE, saved_versions)
# Update dashboard status
update_dashboard_status(len(all_changes) > 0, len(all_changes))
log("=== Monitor complete ===")
print(json.dumps({"changes": all_changes}, ensure_ascii=False, indent=2))