diff --git a/containers/backupchecks/src/backend/app/main/routes_parsers.py b/containers/backupchecks/src/backend/app/main/routes_parsers.py index ec6920b..b9ee6f4 100644 --- a/containers/backupchecks/src/backend/app/main/routes_parsers.py +++ b/containers/backupchecks/src/backend/app/main/routes_parsers.py @@ -1,106 +1,16 @@ from .routes_shared import * # noqa: F401,F403 +# Keep the parser overview page in sync with the actual parser registry. +from app.parsers.registry import PARSER_DEFINITIONS + @main_bp.route("/parsers") @login_required @roles_required("admin") def parsers_overview(): - # Only show what is currently implemented in code. - # Currently implemented parsers: - # - 3CX (Backup Complete notifications) - # - Veeam (status mails in multiple variants) - parsers = [ - { - "name": "3CX backup complete", - "backup_software": "3CX", - "backup_types": [], - "order": 10, - "enabled": True, - "match": { - "subject_regex": r"^3CX Notification:\\s*Backup Complete\\s*-\\s*(.+)$", - }, - "description": "Parses 3CX backup notifications (Backup Complete).", - "examples": [ - { - "subject": "3CX Notification: Backup Complete - PBX01", - "from_address": "noreply@3cx.local", - "body_snippet": "Backup name: PBX01_2025-12-17.zip", - "parsed_result": { - "backup_software": "3CX", - "backup_type": "", - "job_name": "PBX01", - "objects": [ - { - "name": "PBX01_2025-12-17.zip", - "status": "Success", - "error_message": "", - } - ], - }, - } - ], - }, - { - "name": "3CX SSL certificate renewal", - "backup_software": "3CX", - "backup_types": ["SSL Certificate"], - "order": 11, - "enabled": True, - "match": { - "subject_regex": r"^3CX Notification:\\s*SSL Certificate Renewal\\s*-\\s*(.+)$", - }, - "description": "Parses 3CX SSL certificate renewal notifications (informational) so they are tracked and included in reporting.", - "examples": [], - }, - { - "name": "Veeam status mails", - "backup_software": "Veeam", - "backup_types": [ - "Backup Job", - "Backup Copy Job", - "Replica Job", - "Replication job", - "Configuration Backup", - "Agent Backup job", - "Veeam Backup for Microsoft 365", - "Scale Out Back-up Repository", - ], - "order": 20, - "enabled": True, - "match": { - "subject_regex": r"\\[(Success|Warning|Failed)\\]\\s*(.+)$", - }, - "description": "Parses Veeam status mails. Job name/type are preferably extracted from the HTML header to avoid subject suffix noise.", - "examples": [ - { - "subject": "[Warning] Daily-VM-Backup (3 objects) 1 warning", - "from_address": "veeam@customer.local", - "body_snippet": "Backup job: Daily-VM-Backup\\n...", - "parsed_result": { - "backup_software": "Veeam", - "backup_type": "Backup job", - "job_name": "Daily-VM-Backup", - "objects": [ - {"name": "VM-APP01", "status": "Success", "error_message": ""}, - {"name": "VM-DB01", "status": "Warning", "error_message": "Low disk space"}, - ], - }, - }, - { - "subject": "[Success] Offsite-Repository", - "from_address": "veeam@customer.local", - "body_snippet": "Backup Copy job: Offsite-Repository\\n...", - "parsed_result": { - "backup_software": "Veeam", - "backup_type": "Backup Copy job", - "job_name": "Offsite-Repository", - "objects": [ - {"name": "Backup Copy Chain", "status": "Success", "error_message": ""} - ], - }, - }, - ], - }, - ] + parsers = sorted( + PARSER_DEFINITIONS, + key=lambda p: (p.get("order", 9999), p.get("backup_software", ""), p.get("name", "")), + ) return render_template( "main/parsers.html",