diff options
author | Simon Rettberg | 2021-08-24 16:31:13 +0200 |
---|---|---|
committer | Simon Rettberg | 2022-03-09 15:06:25 +0100 |
commit | 291837061ba13647f49cc32092fd0a3ec89d51ed (patch) | |
tree | a3aa5d197d052189bc10273ef0d8ae5168f06e24 /modules-available/statistics/install.inc.php | |
parent | [statistics_reporting] Gather some more os infos (diff) | |
download | slx-admin-291837061ba13647f49cc32092fd0a3ec89d51ed.tar.gz slx-admin-291837061ba13647f49cc32092fd0a3ec89d51ed.tar.xz slx-admin-291837061ba13647f49cc32092fd0a3ec89d51ed.zip |
[statistics] Support new json-format of hardware info from client
We now try to use JSON output mode from any tool on the client
to supply information, for easier parsability and hopefully, a more
stable format.
Diffstat (limited to 'modules-available/statistics/install.inc.php')
-rw-r--r-- | modules-available/statistics/install.inc.php | 58 |
1 files changed, 51 insertions, 7 deletions
diff --git a/modules-available/statistics/install.inc.php b/modules-available/statistics/install.inc.php index 15d0d633..5856c81e 100644 --- a/modules-available/statistics/install.inc.php +++ b/modules-available/statistics/install.inc.php @@ -41,7 +41,8 @@ $res[] = tableCreate('machine', " `systemmodel` varchar(120) NOT NULL DEFAULT '', `id44mb` int(10) unsigned NOT NULL, `badsectors` int(10) unsigned NOT NULL, - `data` mediumtext NOT NULL, + `data` mediumblob NOT NULL, + `dataparsetime` int(10) unsigned NOT NULL DEFAULT 0, `hostname` varchar(200) NOT NULL DEFAULT '', `currentsession` varchar(120) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, `currentuser` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL, @@ -64,7 +65,7 @@ $res[] = $machineHwCreate = tableCreate('machine_x_hw', " `machinehwid` int(10) unsigned NOT NULL AUTO_INCREMENT, `hwid` int(10) unsigned NOT NULL, `machineuuid` char(36) CHARACTER SET ascii NOT NULL, - `devpath` char(50) CHARACTER SET ascii NOT NULL, + `devpath` char(32) CHARACTER SET ascii NOT NULL, `disconnecttime` int(10) unsigned NOT NULL COMMENT 'time the device was not connected to the pc anymore for the first time, 0 if it is connected', PRIMARY KEY (`machinehwid`), UNIQUE KEY `hwid` (`hwid`,`machineuuid`,`devpath`), @@ -74,23 +75,25 @@ $res[] = $machineHwCreate = tableCreate('machine_x_hw', " $res[] = tableCreate('machine_x_hw_prop', " `machinehwid` int(10) unsigned NOT NULL, - `prop` char(16) CHARACTER SET ascii NOT NULL, + `prop` varchar(64) CHARACTER SET ascii NOT NULL, `value` varchar(500) NOT NULL, + `numeric` bigint(20) DEFAULT NULL, PRIMARY KEY (`machinehwid`,`prop`) "); $res[] = tableCreate('statistic_hw', " `hwid` int(10) unsigned NOT NULL AUTO_INCREMENT, - `hwtype` char(11) CHARACTER SET ascii NOT NULL, - `hwname` varchar(200) NOT NULL, + `hwtype` char(16) CHARACTER SET ascii NOT NULL, + `hwname` char(32) CHARACTER SET ascii NOT NULL, PRIMARY KEY (`hwid`), UNIQUE KEY `hwtype` (`hwtype`,`hwname`) "); $res[] = tableCreate('statistic_hw_prop', " `hwid` int(10) unsigned NOT NULL, - `prop` char(16) CHARACTER SET ascii NOT NULL, + `prop` varchar(64) CHARACTER SET ascii NOT NULL, `value` varchar(500) NOT NULL, + `numeric` bigint(20) DEFAULT NULL, PRIMARY KEY (`hwid`,`prop`) "); @@ -298,6 +301,47 @@ if (!tableHasColumn('machine', 'live_id45size')) { } $res[] = UPDATE_DONE; } - +// 2021-08-19 Enhanced machine property indexing +if (stripos(tableColumnType('statistic_hw_prop', 'prop'), 'varchar(64)') === false) { + $ret = Database::exec("ALTER TABLE statistic_hw_prop + MODIFY `prop` varchar(64) CHARACTER SET ascii NOT NULL, + ADD `numeric` bigint(20) DEFAULT NULL"); + if ($ret === false) { + finalResponse(UPDATE_FAILED, 'Changing prop of statistic_hw_prop failed: ' . Database::lastError()); + } + $res[] = UPDATE_DONE; +} +if (stripos(tableColumnType('machine_x_hw_prop', 'prop'), 'varchar(64)') === false) { + $ret = Database::exec("ALTER TABLE machine_x_hw_prop + MODIFY `prop` varchar(64) CHARACTER SET ascii NOT NULL, + ADD `numeric` bigint(20) DEFAULT NULL"); + if ($ret === false) { + finalResponse(UPDATE_FAILED, 'Changing prop of machine_x_hw_prop failed: ' . Database::lastError()); + } + $res[] = UPDATE_DONE; +} +if (stripos(tableColumnType('statistic_hw', 'hwname'), 'char(32)') === false) { + $ret = Database::exec("ALTER TABLE statistic_hw MODIFY `hwname` char(32) CHARACTER SET ascii NOT NULL, + MODIFY `hwtype` char(16) CHARACTER SET ascii NOT NULL"); + if ($ret === false) { + finalResponse(UPDATE_FAILED, 'Changing hwname/hwtype of statistic_hw failed: ' . Database::lastError()); + } + $res[] = UPDATE_DONE; +} +if (stripos(tableColumnType('machine_x_hw', 'devpath'), 'char(32)') === false) { + $ret = Database::exec("ALTER TABLE machine_x_hw MODIFY `devpath` char(32) CHARACTER SET ascii NOT NULL"); + if ($ret === false) { + finalResponse(UPDATE_FAILED, 'Changing devpath of machine_x_hw failed: ' . Database::lastError()); + } + $res[] = UPDATE_DONE; +} +if (!tableHasColumn('machine', 'dataparsetime')) { + $ret = Database::exec("ALTER TABLE `machine` + ADD COLUMN `dataparsetime` int(10) unsigned NOT NULL DEFAULT '0' AFTER `data`"); + if ($ret === false) { + finalResponse(UPDATE_FAILED, 'Adding mem-stat columns to machine table failed: ' . Database::lastError()); + } + $res[] = UPDATE_DONE; +} // Create response responseFromArray($res); |