

-- 创建表 监控_基本信息

ALTER TABLE `omc_db`.`monitor_base` DROP COLUMN IF EXISTS `created_at`;
ALTER TABLE
    `omc_db`.`monitor_base` DROP COLUMN IF EXISTS `updated_at`;
ALTER TABLE `omc_db`.`monitor_base` DROP COLUMN IF EXISTS `db_size`;
ALTER TABLE
    `omc_db`.`monitor_base` MODIFY COLUMN `id` bigint(20) NOT NULL COMMENT 'id' FIRST;
ALTER TABLE
    `omc_db`.`monitor_base`
ADD
    COLUMN IF NOT EXISTS `create_time` bigint(20) NULL DEFAULT 0 COMMENT '创建时间' AFTER `id`;
ALTER TABLE
    `omc_db`.`monitor_base` MODIFY COLUMN `cpu` float NULL DEFAULT 0 COMMENT 'cpu使用率' AFTER `create_time`;
ALTER TABLE
    `omc_db`.`monitor_base` MODIFY COLUMN `load_usage` float NULL DEFAULT 0 COMMENT 'cpu平均使用率' AFTER `cpu`;
ALTER TABLE
    `omc_db`.`monitor_base` MODIFY COLUMN `cpu_load1` float NULL DEFAULT 0 COMMENT 'cpu使用1分钟' AFTER `load_usage`;
ALTER TABLE
    `omc_db`.`monitor_base` MODIFY COLUMN `cpu_load5` float NULL DEFAULT 0 COMMENT 'cpu使用5分钟' AFTER `cpu_load1`;
ALTER TABLE
    `omc_db`.`monitor_base` MODIFY COLUMN `cpu_load15` float NULL DEFAULT 0 COMMENT 'cpu使用15分钟' AFTER `cpu_load5`;
ALTER TABLE
    `omc_db`.`monitor_base` MODIFY COLUMN `memory` float NULL DEFAULT 0 COMMENT '内存使用率' AFTER `cpu_load15`;
ALTER TABLE
    `omc_db`.`monitor_base`
ADD
    COLUMN IF NOT EXISTS `ne_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '网元类型' AFTER `memory`;
ALTER TABLE
    `omc_db`.`monitor_base`
ADD
    COLUMN IF NOT EXISTS `ne_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '网元ID' AFTER `ne_type`;
ALTER TABLE
    `omc_db`.`monitor_base` MODIFY COLUMN `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id';

-- 创建表 监控_磁盘IO

ALTER TABLE `omc_db`.`monitor_io` DROP COLUMN IF EXISTS `created_at`;
ALTER TABLE `omc_db`.`monitor_io` DROP COLUMN IF EXISTS `updated_at`;
ALTER TABLE
    `omc_db`.`monitor_io` MODIFY COLUMN `id` bigint(20) NOT NULL COMMENT 'id' FIRST;
ALTER TABLE
    `omc_db`.`monitor_io`
ADD
    COLUMN IF NOT EXISTS `create_time` bigint(20) NULL DEFAULT 0 COMMENT '创建时间' AFTER `id`;
ALTER TABLE
    `omc_db`.`monitor_io` MODIFY COLUMN `name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '磁盘名' AFTER `create_time`;
ALTER TABLE
    `omc_db`.`monitor_io` MODIFY COLUMN `read` int(11) NULL DEFAULT 0 COMMENT '读取K' AFTER `name`;
ALTER TABLE
    `omc_db`.`monitor_io` MODIFY COLUMN `write` int(11) NULL DEFAULT 0 COMMENT '写入K' AFTER `read`;
ALTER TABLE `omc_db`.`monitor_io` MODIFY COLUMN `count` int NULL DEFAULT 0 COMMENT '读写次数' AFTER `write`;
ALTER TABLE `omc_db`.`monitor_io` MODIFY COLUMN `time` int NULL DEFAULT 0 COMMENT '读写延迟' AFTER `count`;
ALTER TABLE
    `omc_db`.`monitor_io`
ADD
    COLUMN IF NOT EXISTS `ne_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '网元类型' AFTER `time`;
ALTER TABLE
    `omc_db`.`monitor_io`
ADD
    COLUMN IF NOT EXISTS `ne_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '网元ID' AFTER `ne_type`;
ALTER TABLE
    `omc_db`.`monitor_io` MODIFY COLUMN `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id';

-- 创建表 监控_网络IO

ALTER TABLE `omc_db`.`monitor_network` DROP COLUMN IF EXISTS `created_at`;
ALTER TABLE `omc_db`.`monitor_network` DROP COLUMN IF EXISTS `updated_at`;
ALTER TABLE
    `omc_db`.`monitor_network` MODIFY COLUMN `id` bigint(20) NOT NULL COMMENT 'id' FIRST;
ALTER TABLE
    `omc_db`.`monitor_network`
ADD
    COLUMN IF NOT EXISTS `create_time` bigint(20) NULL DEFAULT 0 COMMENT '创建时间' AFTER `id`;
ALTER TABLE
    `omc_db`.`monitor_network` MODIFY COLUMN `name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '网卡名' AFTER `create_time`;
ALTER TABLE
    `omc_db`.`monitor_network` MODIFY COLUMN `up` float NULL DEFAULT 0 COMMENT '上行' AFTER `name`;
ALTER TABLE
    `omc_db`.`monitor_network` MODIFY COLUMN `down` float NULL DEFAULT 0 COMMENT '下行' AFTER `up`;
ALTER TABLE
    `omc_db`.`monitor_network`
ADD
    COLUMN IF NOT EXISTS `ne_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '网元类型' AFTER `down`;
ALTER TABLE
    `omc_db`.`monitor_network`
ADD
    COLUMN IF NOT EXISTS `ne_id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '网元ID' AFTER `ne_type`;
ALTER TABLE
    `omc_db`.`monitor_network` MODIFY COLUMN `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id';
