GetData::total(GETDATA_ANONYMOUS)); $data['perLocation'] = array_values(GetData::perLocation(GETDATA_ANONYMOUS)); $data['perVM'] = GetData::perVM(GETDATA_ANONYMOUS); $data['tsFrom'] = $from; $data['tsTo'] = $to; $data['dozmod'] = Queries::getDozmodStats($from, $to); $data['machines'] = Queries::getAggregatedMachineStats($from); $data['exams'] = Queries::getExamStats($from, $to); $data['baseSystem'] = Queries::getBaseSystemStats($from, $to); $data['runmode'] = Queries::getRunmodeStats($from, $to); $data['gpus'] = self::getGpus($from, $to); $result['days' . $day] = $data; } $result['server'] = self::getLocalHardware(); } $result['version'] = CONFIG_FOOTER; return $result; } private static function getLocalHardware(): array { $cpuInfo = file_get_contents('/proc/cpuinfo'); $uptime = file_get_contents('/proc/uptime'); $memInfo = file_get_contents('/proc/meminfo'); $osInfo = parse_ini_file('/etc/os-release'); preg_match_all('/\b(\w+):\s+(\d+)\s/', $memInfo, $out, PREG_SET_ORDER); $mem = array(); foreach ($out as $e) { $mem[$e[1]] = $e[2]; } // $data = array(); $data['cpuCount'] = preg_match_all('/\bmodel name\s+:\s+(.*)$/m', $cpuInfo, $out); if ($data['cpuCount'] > 0) { $data['cpuModel'] = $out[1][0]; } if (preg_match('/^(\d+)\D/', $uptime, $out)) { $data['uptime'] = $out[1]; } if (isset($mem['MemTotal']) && isset($mem['MemFree']) && isset($mem['SwapTotal'])) { $data['memTotal'] = $mem['MemTotal']; $data['memFree'] = ($mem['MemFree'] + $mem['Buffers'] + $mem['Cached']); $data['swapTotal'] = $mem['SwapTotal']; $data['swapUsed'] = ($mem['SwapTotal'] - $mem['SwapFree']); } $data['ip'] = $_SERVER['SERVER_ADDR'] ?? Property::getServerIp(); $data['hostname'] = strtolower(gethostbyaddr($_SERVER['SERVER_ADDR'] ?? Property::getServerIp())); $data['osID'] = $osInfo['ID']; $data['osVersionID'] = $osInfo['VERSION_ID']; $data['osVersionCodename'] = $osInfo['VERSION_CODENAME']; return $data; } private static function getGpus(int $from, int $to): array { $q = new HardwareQuery(HardwareInfo::PCI_DEVICE, null, true); $q->addGlobalColumn('vendor'); $q->addGlobalColumn('device'); $q->addGlobalColumn('class')->addCondition('=', '0300'); // VGA adapter $q->addMachineWhere('lastseen', '>=', $from); $q->addMachineWhere('lastseen', '<=', $to); $res = $q->query(['vendor', 'device']); $return = []; foreach ($res as $row) { $return[] = [ 'group_count' => $row['group_count'], 'device' => $row['device'], 'vendor' => $row['vendor'], ]; } return $return; } }