From ae665fc0a46004c0458347163355f882a90a3f46 Mon Sep 17 00:00:00 2001 From: "courtmanr@gmail.com" Date: Fri, 30 May 2025 10:53:51 +0100 Subject: [PATCH] feat: add comprehensive configuration options to setup page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add advanced settings section with all .env.example options - Include metric/discovery intervals configuration - Add alert system configuration (enabled/thresholds) - Add PBS node name field (required for non-Sys.Audit tokens) - Update config API to handle all settings - Group settings logically in generated .env file - Load and save all configuration options properly 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- server/configApi.js | 75 ++++++++++++++++++- src/public/setup.html | 162 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 233 insertions(+), 4 deletions(-) diff --git a/server/configApi.js b/server/configApi.js index 85c7aca14..343045d1b 100644 --- a/server/configApi.js +++ b/server/configApi.js @@ -26,12 +26,34 @@ class ConfigApi { host: config.PBS_HOST, port: config.PBS_PORT || '8007', tokenId: config.PBS_TOKEN_ID, + nodeName: config.PBS_NODE_NAME, // Don't send the secret - } : null + } : null, + advanced: { + metricInterval: config.PULSE_METRIC_INTERVAL_MS, + discoveryInterval: config.PULSE_DISCOVERY_INTERVAL_MS, + alerts: { + cpu: { + enabled: config.ALERT_CPU_ENABLED !== 'false', + threshold: config.ALERT_CPU_THRESHOLD + }, + memory: { + enabled: config.ALERT_MEMORY_ENABLED !== 'false', + threshold: config.ALERT_MEMORY_THRESHOLD + }, + disk: { + enabled: config.ALERT_DISK_ENABLED !== 'false', + threshold: config.ALERT_DISK_THRESHOLD + }, + down: { + enabled: config.ALERT_DOWN_ENABLED !== 'false' + } + } + } }; } catch (error) { console.error('Error reading configuration:', error); - return { proxmox: null, pbs: null }; + return { proxmox: null, pbs: null, advanced: {} }; } } @@ -58,10 +80,50 @@ class ConfigApi { existingConfig.PBS_PORT = config.pbs.port || '8007'; existingConfig.PBS_TOKEN_ID = config.pbs.tokenId; existingConfig.PBS_TOKEN_SECRET = config.pbs.tokenSecret; + if (config.pbs.nodeName) { + existingConfig.PBS_NODE_NAME = config.pbs.nodeName; + } // Always allow self-signed certificates by default for PBS existingConfig.PBS_ALLOW_SELF_SIGNED_CERT = 'true'; } + // Add advanced settings + if (config.advanced) { + // Service intervals + if (config.advanced.metricInterval) { + existingConfig.PULSE_METRIC_INTERVAL_MS = config.advanced.metricInterval; + } + if (config.advanced.discoveryInterval) { + existingConfig.PULSE_DISCOVERY_INTERVAL_MS = config.advanced.discoveryInterval; + } + + // Alert settings + if (config.advanced.alerts) { + const alerts = config.advanced.alerts; + if (alerts.cpu) { + existingConfig.ALERT_CPU_ENABLED = alerts.cpu.enabled ? 'true' : 'false'; + if (alerts.cpu.threshold) { + existingConfig.ALERT_CPU_THRESHOLD = alerts.cpu.threshold; + } + } + if (alerts.memory) { + existingConfig.ALERT_MEMORY_ENABLED = alerts.memory.enabled ? 'true' : 'false'; + if (alerts.memory.threshold) { + existingConfig.ALERT_MEMORY_THRESHOLD = alerts.memory.threshold; + } + } + if (alerts.disk) { + existingConfig.ALERT_DISK_ENABLED = alerts.disk.enabled ? 'true' : 'false'; + if (alerts.disk.threshold) { + existingConfig.ALERT_DISK_THRESHOLD = alerts.disk.threshold; + } + } + if (alerts.down) { + existingConfig.ALERT_DOWN_ENABLED = alerts.down.enabled ? 'true' : 'false'; + } + } + } + // Write back to .env file await this.writeEnvFile(existingConfig); @@ -170,7 +232,14 @@ class ConfigApi { // Group related settings const groups = { 'Proxmox VE Settings': ['PROXMOX_HOST', 'PROXMOX_PORT', 'PROXMOX_TOKEN_ID', 'PROXMOX_TOKEN_SECRET', 'PROXMOX_ALLOW_SELF_SIGNED_CERT'], - 'Proxmox Backup Server Settings': ['PBS_HOST', 'PBS_PORT', 'PBS_TOKEN_ID', 'PBS_TOKEN_SECRET', 'PBS_ALLOW_SELF_SIGNED_CERT'], + 'Proxmox Backup Server Settings': ['PBS_HOST', 'PBS_PORT', 'PBS_TOKEN_ID', 'PBS_TOKEN_SECRET', 'PBS_NODE_NAME', 'PBS_ALLOW_SELF_SIGNED_CERT'], + 'Pulse Service Settings': ['PULSE_METRIC_INTERVAL_MS', 'PULSE_DISCOVERY_INTERVAL_MS'], + 'Alert System Configuration': [ + 'ALERT_CPU_ENABLED', 'ALERT_CPU_THRESHOLD', 'ALERT_CPU_DURATION', + 'ALERT_MEMORY_ENABLED', 'ALERT_MEMORY_THRESHOLD', 'ALERT_MEMORY_DURATION', + 'ALERT_DISK_ENABLED', 'ALERT_DISK_THRESHOLD', 'ALERT_DISK_DURATION', + 'ALERT_DOWN_ENABLED', 'ALERT_DOWN_DURATION' + ], 'Other Settings': [] // Will contain all other keys }; diff --git a/src/public/setup.html b/src/public/setup.html index 7fa3683db..35772ae88 100644 --- a/src/public/setup.html +++ b/src/public/setup.html @@ -99,6 +99,96 @@ + +
+ + Advanced Settings (Optional) + +
+
+
+ + +

How often to fetch VM/Container metrics

+
+ +
+ + +

How often to discover nodes and VMs

+
+
+ + +
+

Alert Settings

+ +
+ + + + +
+ +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+
+

Proxmox Backup Server (Optional)

@@ -122,6 +212,16 @@ class="w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
+
+ + +

Required unless token has Sys.Audit permission

+
+