diff options
Diffstat (limited to 'modules-available/statistics/api.inc.php')
-rw-r--r-- | modules-available/statistics/api.inc.php | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/modules-available/statistics/api.inc.php b/modules-available/statistics/api.inc.php index 04614521..0a194f2e 100644 --- a/modules-available/statistics/api.inc.php +++ b/modules-available/statistics/api.inc.php @@ -1,5 +1,21 @@ <?php +if (Request::any('action') === 'test' && isLocalExecution()) { + $x = new HardwareQuery(HardwareInfo::PCI_DEVICE); + //$x->addCompare(false, 'Memory Slot Occupied', '>=', true, 'Memory Slot Count'); + $x->addWhere(true, 'vendor', '=', '8086'); + $x->addColumn(true, 'device'); + $res = $x->query(); + foreach ($res as $row) { + error_log(json_encode($row)); + } + exit; + HardwareParser::parseMachine('0A5D9E23-80F4-9C43-912C-96D80AE7E80B', + file_get_contents('/tmp/bla.json')); + echo 'Kweries: ' . Database::getQueryCount(); + exit; +} + if (empty($_POST['type'])) die('Missing options.'); $type = mb_strtolower($_POST['type']); @@ -62,7 +78,11 @@ if ($type[0] === '~') { if (!is_string($hostname) || $hostname === $ip) { $hostname = ''; } - $data = Util::cleanUtf8(Request::post('data', '', 'string')); + $data = Util::cleanUtf8(Request::post('json', '', 'string')); + $hasJson = !empty($data); + if (!$hasJson) { + $data = Util::cleanUtf8(Request::post('data', '', 'string')); + } // Prepare insert/update to machine table $new = array( 'machineuuid'=> $uuid, @@ -119,7 +139,7 @@ if ($type[0] === '~') { . ' id44mb = :id44mb,' . ' live_tmpsize = 0, live_swapsize = 0, live_memsize = 0, live_cpuload = 255, live_cputemp = 0,' . ' badsectors = :badsectors,' - . ' data = :data,' + . ' data = ' . ($hasJson ? ':data' : "If(Left(data, 1) = '{', data, :data)") . ',' . ' state = :state ' . " WHERE machineuuid = :machineuuid AND state = :oldstate AND lastseen = :oldlastseen", $new); if ($res === 0) { @@ -151,6 +171,10 @@ if ($type[0] === '~') { $new['locationid'] = $loc; // For Filter Event } + if ($hasJson) { + HardwareParser::parseMachine($uuid, $data); + } + // Check for suspicious hardware changes if ($old !== false) { checkHardwareChange($old, $new); @@ -316,6 +340,7 @@ if ($type[0] === '~') { 'hwid' => $hwid, 'machineuuid' => $uuid, 'devpath' => $port, + 'serial' => '', ), array('disconnecttime' => 0)); $validProps = array(); if (count($screen) > 1) { |