+
🚨 Diagnóstico Inteligente & Ação Prioritária (Erro {job_row['exit_code']})
+
Identificação: {err_info['desc']}
+
🛠️ Troubleshooting Recomendado (Prioridade Máxima):
+
{err_info['action']}
+
+ """, unsafe_allow_html=True)
+
with st.form(key="mitigation_form_v3", clear_on_submit=False):
action_text = st.text_area(
"Ação Tomada / Nota Técnica:",
diff --git a/report_gen.py b/report_gen.py
index f7e5d86..e397951 100644
--- a/report_gen.py
+++ b/report_gen.py
@@ -152,13 +152,14 @@ def generate_mitigation_pdf(jobs_list, filter_name="Consolidated"):
pdf.set_fill_color(30, 38, 64)
pdf.set_font('Helvetica', 'B', 8)
pdf.set_text_color(255, 255, 255)
- pdf.cell(15, 6, 'Job ID', 1, 0, 'C', True)
- pdf.cell(32, 6, 'Cliente', 1, 0, 'L', True)
- pdf.cell(35, 6, 'Politica', 1, 0, 'L', True)
- pdf.cell(15, 6, 'Erro', 1, 0, 'C', True)
- pdf.cell(28, 6, 'Resolucao Rerun', 1, 0, 'C', True)
- pdf.cell(20, 6, 'Mitigacao', 1, 0, 'C', True)
- pdf.cell(45, 6, 'Acao Registrada', 1, 1, 'L', True)
+ pdf.cell(14, 6, 'Job ID', 1, 0, 'C', True)
+ pdf.cell(16, 6, 'Infra/Cloud', 1, 0, 'C', True)
+ pdf.cell(26, 6, 'Cliente', 1, 0, 'L', True)
+ pdf.cell(30, 6, 'Politica', 1, 0, 'L', True)
+ pdf.cell(12, 6, 'Erro', 1, 0, 'C', True)
+ pdf.cell(24, 6, 'Resolucao Rerun', 1, 0, 'C', True)
+ pdf.cell(18, 6, 'Mitigacao', 1, 0, 'C', True)
+ pdf.cell(50, 6, 'Acao Registrada', 1, 1, 'L', True)
# Table Rows formatting
pdf.set_font('Helvetica', '', 7.5)
@@ -175,27 +176,37 @@ def generate_mitigation_pdf(jobs_list, filter_name="Consolidated"):
action = clean_str(j.get('action_taken'), 'Nenhuma nota registrada.')
# String safety trims
- if len(client) > 20: client = client[:18] + '..'
- if len(policy) > 20: policy = policy[:18] + '..'
- if len(action) > 30: action = action[:28] + '..'
+ if len(client) > 16: client = client[:14] + '..'
+ if len(policy) > 18: policy = policy[:16] + '..'
+ if len(action) > 34: action = action[:32] + '..'
+ # Resolve Infra / Cloud based on Primary Server name
+ srv = clean_str(j.get('primary_server'), '').lower()
+ if 'srvpalcvnbu01' in srv:
+ infra = 'Azure'
+ elif 'srvpalcocinbupri01' in srv:
+ infra = 'OCI'
+ else:
+ infra = 'Outro'
+
# Row alternating colors
if fill_row:
pdf.set_fill_color(241, 245, 249)
else:
pdf.set_fill_color(255, 255, 255)
- pdf.cell(15, 6, str(jid), 1, 0, 'C', True)
- pdf.cell(32, 6, client, 1, 0, 'L', True)
- pdf.cell(35, 6, policy, 1, 0, 'L', True)
- pdf.cell(15, 6, str(code), 1, 0, 'C', True)
+ pdf.cell(14, 6, str(jid), 1, 0, 'C', True)
+ pdf.cell(16, 6, infra, 1, 0, 'C', True)
+ pdf.cell(26, 6, client, 1, 0, 'L', True)
+ pdf.cell(30, 6, policy, 1, 0, 'L', True)
+ pdf.cell(12, 6, str(code), 1, 0, 'C', True)
# Write rerun status with semantic colors
if reex == 'Reexecutado':
pdf.set_text_color(0, 150, 60) # Green text
else:
pdf.set_text_color(255, 75, 75) # Red text
- pdf.cell(28, 6, reex, 1, 0, 'C', True)
+ pdf.cell(24, 6, reex, 1, 0, 'C', True)
# Set action status background color
pdf.set_text_color(30, 41, 59)
@@ -205,14 +216,14 @@ def generate_mitigation_pdf(jobs_list, filter_name="Consolidated"):
pdf.set_fill_color(255, 235, 180) # Soft yellow cell
else:
pdf.set_fill_color(255, 210, 210) # Soft red cell
- pdf.cell(20, 6, status, 1, 0, 'C', True)
+ pdf.cell(18, 6, status, 1, 0, 'C', True)
# Action notes column
if fill_row:
pdf.set_fill_color(241, 245, 249)
else:
pdf.set_fill_color(255, 255, 255)
- pdf.cell(45, 6, action, 1, 1, 'L', True)
+ pdf.cell(50, 6, action, 1, 1, 'L', True)
fill_row = not fill_row
diff --git a/spec.md b/spec.md
index a14e556..1689f78 100644
--- a/spec.md
+++ b/spec.md
@@ -1,103 +1,124 @@
-Markdown
-# Software Requirements Specification (SRS) - v2.0
-## Project Name: NetBackup Log Insights & Action Tracker (Docker & Gitea Edition)
-## Target Environment: Docker Container for VPS Deployment
-## IDE Target: Antigravity IDE
-
----
-
-## 1. Executive Summary & New Objectives
-The objective is to build a modern, containerized backup management dashboard using Python, Streamlit, and SQLite. The system processes NetBackup "Job Summary" CSV exports, segregates infrastructure cloud zones, cross-references transient errors with automatic successes, tracks manual operational actions, and exports standardized PDF mitigation reports.
-
----
-
-## 2. Infrastructure & Portability Guardrails (Docker Shift)
-
-### 2.1 Containerization Deployment
-* **Base Image:** `python:3.11-slim` (to keep the cloud footprint minimal).
-* **Port Configuration:** Expose port `8501` internally, mapped via Docker Compose.
-* **Volume Mapping:** Data persistence must be maintained by mapping a host directory to the container’s internal storage path (`/app/data`).
-
-### 2.2 Advanced Database Architecture & Persistence
-* **Database File:** `/app/data/nbu_insights.db` (Mapped volume).
-* **Historical Traceability:** Data uploaded via CSV must be completely persisted. If a new CSV is processed, the system must perform an `UPSERT` operation based on the unique key `(Job Id, Client, Policy)` to preserve historical runs and ensure that previously typed mitigation actions are never overwritten.
-
-```sql
-CREATE TABLE IF NOT EXISTS processed_files (
- file_hash TEXT PRIMARY KEY,
- file_name TEXT,
- upload_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP
-);
-
-CREATE TABLE IF NOT EXISTS backup_jobs (
- job_id INTEGER PRIMARY KEY,
- client TEXT,
- policy TEXT,
- type TEXT,
- exit_code INTEGER,
- start_time TIMESTAMP,
- finish_time TIMESTAMP,
- duration_secs INTEGER,
- mbytes REAL,
- files_count INTEGER,
- primary_server TEXT,
- media_server TEXT,
- is_rerun_success INTEGER DEFAULT 0
-);
-
-CREATE TABLE IF NOT EXISTS job_actions (
- job_id INTEGER PRIMARY KEY,
- action_taken TEXT,
- status TEXT DEFAULT 'Pendente', -- Enum: 'Pendente', 'Em Progresso', 'Resolvido'
- updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
- FOREIGN KEY(job_id) REFERENCES backup_jobs(job_id)
-);
-3. UI/UX Design & Branding Strategy (CXP-Inspired Dark Tech)
-Primary Background: #0B0F19 (Deep Midnight Blue)
-
-Card / Container Background: #1E2640 (Slate Corporate Blue)
-
-Primary Accent: #00D2FF (Vibrant Cyan)
-
-Typography Hierarchy: Clean, highly visible tech elements with colored status badges (#00C853 for active success, #FF4B4B for unmitigated failure).
-
-4. Full Functional Requirements & Data Insights Engine
-4.1 Ingestion & Cleansing Pipeline
-CSV Offset: Dynamically strip metadata row 0 (###################### TABLE...).
-
-Metric Extraction: Auto-calculate MSDP Deduplication Ratio and Savings. Show globally and separate per Primary Server.
-
-4.2 Multi-Cloud Tenant Views (Sidebar Selector)
-Consolidated View: Combined global metrics.
-
-Azure Infrastructure Zone: Filters data where Primary Server == 'srvpalcvnbu01.elo.corp'.
-
-OCI Infrastructure Zone: Filters data where Primary Server == 'srvpalcocinbupri01.elo.corp'.
-
-4.3 Advanced Rerun & Target Resolution Analytics
-Automated Clearing: If a job fails (Exit Code > 1) but the same Client and Policy have a subsequent successful job (Exit Code 0 or 1) inside the logs, flag it automatically as [✓ Reexecutado com Sucesso].
-
-State Filtering: Create a dedicated filter to view:
-
-Todos os Erros
-
-Erros Sem Tratativa / Pendentes
-
-Erros Corrigidos Automatizados (Reexecutados)
-
-4.4 Action Register & PDF Mitigation Report Engine
-Form Action: Input text fields for engineers to log infrastructure actions (e.g., "Adjusted firewall rules on port 1556", "Expanded snapshot window").
-
-PDF Generation Engine: Integrating the fpdf2 or reportlab library. Clicking "Exportar Plano de Mitigação PDF" triggers a compiled file containing a professional summary header, performance graphs metrics, and a clean table of all logged actions and resolutions.
-
-5. Repository File Layout
-Plaintext
-netbackup-insights/
-│
-├── app.py # Main UI Orchestrator
-├── database.py # SQLite Connection & Upsert Engine
-├── parser.py # Pandas Data Cleansing and Ratio Math
-├── report_gen.py # PDF Layout Compilation Engine
-├── requirements.txt # Python Dependencies
-├── Dockerfile # App Container Specification
-└── docker-compose.yml # Multi-environment VPS deployment spec
\ No newline at end of file
+Markdown
+# Software Requirements Specification (SRS) - v2.0
+## Project Name: NetBackup Log Insights & Action Tracker (Docker & Gitea Edition)
+## Target Environment: Docker Container for VPS Deployment
+## IDE Target: Antigravity IDE
+
+---
+
+## 1. Executive Summary & New Objectives
+The objective is to build a modern, containerized backup management dashboard using Python, Streamlit, and SQLite. The system processes NetBackup "Job Summary" CSV exports, segregates infrastructure cloud zones, cross-references transient errors with automatic successes, tracks manual operational actions, and exports standardized PDF mitigation reports.
+
+---
+
+## 2. Infrastructure & Portability Guardrails (Docker Shift)
+
+### 2.1 Containerization Deployment
+* **Base Image:** `python:3.11-slim` (to keep the cloud footprint minimal).
+* **Port Configuration:** Expose port `8501` internally, mapped via Docker Compose.
+* **Volume Mapping:** Data persistence must be maintained by mapping a host directory to the container’s internal storage path (`/app/data`).
+
+### 2.2 Advanced Database Architecture & Persistence
+* **Database File:** `/app/data/nbu_insights.db` (Mapped volume).
+* **Historical Traceability:** Data uploaded via CSV must be completely persisted. If a new CSV is processed, the system must perform an `UPSERT` operation based on the unique key `(Job Id, Client, Policy)` to preserve historical runs and ensure that previously typed mitigation actions are never overwritten.
+
+```sql
+CREATE TABLE IF NOT EXISTS processed_files (
+ file_hash TEXT PRIMARY KEY,
+ file_name TEXT,
+ upload_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP
+);
+
+CREATE TABLE IF NOT EXISTS backup_jobs (
+ job_id INTEGER PRIMARY KEY,
+ client TEXT,
+ policy TEXT,
+ type TEXT,
+ exit_code INTEGER,
+ start_time TIMESTAMP,
+ finish_time TIMESTAMP,
+ duration_secs INTEGER,
+ mbytes REAL,
+ files_count INTEGER,
+ primary_server TEXT,
+ media_server TEXT,
+ is_rerun_success INTEGER DEFAULT 0
+);
+
+CREATE TABLE IF NOT EXISTS job_actions (
+ job_id INTEGER PRIMARY KEY,
+ action_taken TEXT,
+ status TEXT DEFAULT 'Pendente', -- Enum: 'Pendente', 'Em Progresso', 'Resolvido'
+ updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
+ FOREIGN KEY(job_id) REFERENCES backup_jobs(job_id)
+);
+3. UI/UX Design & Branding Strategy (CXP-Inspired Dark Tech)
+Primary Background: #0B0F19 (Deep Midnight Blue)
+
+Card / Container Background: #1E2640 (Slate Corporate Blue)
+
+Primary Accent: #00D2FF (Vibrant Cyan)
+
+Typography Hierarchy: Clean, highly visible tech elements with colored status badges (#00C853 for active success, #FF4B4B for unmitigated failure).
+
+4. Full Functional Requirements & Data Insights Engine
+4.1 Ingestion & Cleansing Pipeline
+CSV Offset: Dynamically strip metadata row 0 (###################### TABLE...).
+
+Metric Extraction: Auto-calculate MSDP Deduplication Ratio and Savings. Show globally and separate per Primary Server.
+
+4.2 Multi-Cloud Tenant Views (Sidebar Selector)
+Consolidated View: Combined global metrics.
+
+Azure Infrastructure Zone: Filters data where Primary Server == 'srvpalcvnbu01.elo.corp'.
+
+OCI Infrastructure Zone: Filters data where Primary Server == 'srvpalcocinbupri01.elo.corp'.
+
+4.3 Advanced Rerun & Target Resolution Analytics
+Automated Clearing: If a job fails (Exit Code > 1) but the same Client and Policy have a subsequent successful job (Exit Code 0 or 1) inside the logs, flag it automatically as [✓ Reexecutado com Sucesso].
+
+State Filtering: Create a dedicated filter to view:
+
+Todos os Erros
+
+Erros Sem Tratativa / Pendentes
+
+Erros Corrigidos Automatizados (Reexecutados)
+
+4.4 Action Register & PDF Mitigation Report Engine
+Form Action: Input text fields for engineers to log infrastructure actions (e.g., "Adjusted firewall rules on port 1556", "Expanded snapshot window").
+
+PDF Generation Engine: Integrating the fpdf2 or reportlab library. Clicking "Exportar Plano de Mitigação PDF" triggers a compiled file containing a professional summary header, performance graphs metrics, and a clean table of all logged actions and resolutions.
+
+5. Repository File Layout
+Plaintext
+netbackup-insights/
+│
+├── app.py # Main UI Orchestrator
+├── database.py # SQLite Connection & Upsert Engine
+├── parser.py # Pandas Data Cleansing and Ratio Math
+├── report_gen.py # PDF Layout Compilation Engine
+├── requirements.txt # Python Dependencies
+├── Dockerfile # App Container Specification
+└── docker-compose.yml # Multi-environment VPS deployment spec
+
+---
+
+## 6. Enhanced Web Features (v2.1)
+
+### 6.1 Contrast & Accessibility Standardization
+* **Backgrounds:** Maintain `#0B0F19` deep blue background for pages. Use a distinct slate-blue `#161E35` for metric cards and inputs to separate sections visually.
+* **Text Contrast:** Ensure all metric values use `#FFFFFF`. Use `#F1F5F9` for secondary headers/body text and `#CBD5E1` for metric labels.
+* **Badges:** Success badge uses brighter `#00E676` green, warning badge uses `#FFD600` yellow.
+
+### 6.2 MSDP Volumetry Grouped Chart
+* Show a double bar chart for client data consumption comparison.
+* **Metrics:** Side-by-side comparison of **Pré-Dedup (Volume Bruto)** in `#3B82F6` blue and **Pós-Dedup (Volume Gravado)** in `#10B981` green for the top 7 clients.
+
+### 6.3 PDF Cloud Infrastructure Flag
+* The PDF report table must contain a dedicated **Infra/Cloud** column.
+* **Rules:** If `Primary Server` contains `srvpalcvnbu01`, classify as `Azure`. If it contains `srvpalcocinbupri01`, classify as `OCI`. Otherwise, label as `Outro`.
+
+### 6.4 Live Internet Troubleshooting & Diagnostic Engine
+* For failed jobs that are not cleared by re-runs (`is_rerun_success == 0`), the UI must resolve troubleshooting steps dynamically.
+* **Mechanism:** Fall back to a local database dictionary (for status codes 2, 25, 26, 57, 58, 96, 156), and perform a real-time HTTP search query against `html.duckduckgo.com` to fetch supplemental resolution notes online.
\ No newline at end of file