feat: Implement server and client metrics collection and monitoring

- Added a new PHP script for collecting server metrics every 30 seconds.
- Created a ServerMonitoring class to handle metrics collection for CPU, RAM, Disk, and Network.
- Introduced database tables for storing server and client metrics.
- Updated server view template to display real-time metrics using Chart.js.
- Added translations for monitoring UI elements.
- Created a new monitoring template for detailed server metrics visualization.
- Implemented client speed tracking and display in the monitoring UI.
This commit is contained in:
infosave2007
2025-11-08 15:35:17 +03:00
parent 932a893d69
commit 7c9136152b
11 changed files with 1545 additions and 26 deletions
+31
View File
@@ -0,0 +1,31 @@
-- Add server metrics tables
-- This migration adds functionality to store and display server monitoring data
-- Server metrics (CPU, RAM, Disk, Network)
CREATE TABLE IF NOT EXISTS server_metrics (
id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
server_id INT UNSIGNED NOT NULL,
cpu_percent DECIMAL(5,2) NULL COMMENT 'CPU usage percentage',
ram_used_mb INT UNSIGNED NULL COMMENT 'RAM used in MB',
ram_total_mb INT UNSIGNED NULL COMMENT 'Total RAM in MB',
disk_used_gb DECIMAL(10,2) NULL COMMENT 'Disk used in GB',
disk_total_gb DECIMAL(10,2) NULL COMMENT 'Total disk in GB',
network_rx_mbps DECIMAL(10,2) NULL COMMENT 'Network receive speed in Mbps',
network_tx_mbps DECIMAL(10,2) NULL COMMENT 'Network transmit speed in Mbps',
collected_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
INDEX idx_server_time (server_id, collected_at),
FOREIGN KEY (server_id) REFERENCES vpn_servers(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- Client traffic metrics (speed tracking)
CREATE TABLE IF NOT EXISTS client_metrics (
id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
client_id INT UNSIGNED NOT NULL,
bytes_sent BIGINT UNSIGNED DEFAULT 0 COMMENT 'Bytes sent at this moment',
bytes_received BIGINT UNSIGNED DEFAULT 0 COMMENT 'Bytes received at this moment',
speed_up_kbps DECIMAL(10,2) NULL COMMENT 'Upload speed in Kbps',
speed_down_kbps DECIMAL(10,2) NULL COMMENT 'Download speed in Kbps',
collected_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
INDEX idx_client_time (client_id, collected_at),
FOREIGN KEY (client_id) REFERENCES vpn_clients(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;