-- Create router monitoring table CREATE TABLE IF NOT EXISTS `tbl_router_monitoring` ( `id` int(11) NOT NULL AUTO_INCREMENT, `router_id` int(11) NOT NULL, `timestamp` datetime NOT NULL, `ping_status` tinyint(1) NOT NULL DEFAULT 0, `api_status` tinyint(1) NOT NULL DEFAULT 0, `uptime` varchar(50) DEFAULT NULL, `free_memory` bigint(20) DEFAULT NULL, `total_memory` bigint(20) DEFAULT NULL, `cpu_load` int(11) DEFAULT NULL, `temperature` varchar(20) DEFAULT NULL, `voltage` varchar(20) DEFAULT NULL, `error` text DEFAULT NULL, PRIMARY KEY (`id`), KEY `router_id` (`router_id`), KEY `timestamp` (`timestamp`), KEY `router_timestamp` (`router_id`, `timestamp`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- Add monitoring columns to router table if they don't exist ALTER TABLE `tbl_routers` ADD COLUMN IF NOT EXISTS `last_error` text DEFAULT NULL, ADD COLUMN IF NOT EXISTS `offline_since` datetime DEFAULT NULL;