diff --git a/db/zm_create.sql.in b/db/zm_create.sql.in index 4da7ca0b4..063567e3a 100644 --- a/db/zm_create.sql.in +++ b/db/zm_create.sql.in @@ -699,6 +699,8 @@ CREATE TABLE `Server_Stats` ( `ServerId` int(10) unsigned, `TimeStamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, `CpuLoad` DECIMAL(5,1) default NULL, + `CpuUserPercent` DECIMAL(5,1) default NULL, + `CpuSystemPercent` DECIMAL(5,1) default NULL, `TotalMem` bigint unsigned default null, `FreeMem` bigint unsigned default null, `TotalSwap` bigint unsigned default null, diff --git a/db/zm_update-1.37.37.sql b/db/zm_update-1.37.37.sql new file mode 100644 index 000000000..8d3bf42ce --- /dev/null +++ b/db/zm_update-1.37.37.sql @@ -0,0 +1,29 @@ +SELECT 'Checking for CpuUserPercent in ServerStats'; +SET @s = (SELECT IF( + (SELECT COUNT(*) + FROM INFORMATION_SCHEMA.COLUMNS + WHERE table_name = 'Server_Stats' + AND table_schema = DATABASE() + AND column_name = 'CpuUserPercent' + ) > 0, +"SELECT 'Column CpuUserPercent already exists in Server_Stats'", +"ALTER TABLE Server_Stats ADD `CpuUserPercent` DECIMAL(5,1) default NULL AFTER `CpuLoad`" +)); + +PREPARE stmt FROM @s; +EXECUTE stmt; + +SELECT 'Checking for CpuSystemPercent in ServerStats'; +SET @s = (SELECT IF( + (SELECT COUNT(*) + FROM INFORMATION_SCHEMA.COLUMNS + WHERE table_name = 'Server_Stats' + AND table_schema = DATABASE() + AND column_name = 'CpuSystemPercent' + ) > 0, +"SELECT 'Column CpuSystemPercent already exists in Server_Stats'", +"ALTER TABLE Server_Stats ADD `CpuSystemPercent` DECIMAL(5,1) default NULL AFTER `CpuUserPercent`" +)); + +PREPARE stmt FROM @s; +EXECUTE stmt;