/dev/null", "rpm -qa --qf '%{NAME} %{VERSION}-%{RELEASE}\n' 'php*' 2>/dev/null", ]; foreach ($commands as $command) { $output = @shell_exec($command); if (!is_string($output) || trim($output) === '') { continue; } foreach (preg_split('/\R/', trim($output)) ?: [] as $line) { $parts = preg_split('/\s+/', trim($line), 2) ?: []; if (count($parts) === 2) { $packages[] = ['name' => $parts[0], 'version' => $parts[1]]; } } } $payload = [ 'agent_version' => '1.0', 'generated_at' => gmdate('c'), 'php_version' => PHP_VERSION, 'php_sapi' => PHP_SAPI, 'os_family' => PHP_OS_FAMILY, 'distro' => [ 'id' => $osRelease['ID'] ?? null, 'version_id' => $osRelease['VERSION_ID'] ?? null, 'pretty_name' => $osRelease['PRETTY_NAME'] ?? null, ], 'packages' => $packages, 'ini' => [ 'memory_limit' => ini_get('memory_limit'), 'post_max_size' => ini_get('post_max_size'), 'max_input_nesting_level' => ini_get('max_input_nesting_level'), 'max_input_vars' => ini_get('max_input_vars'), 'max_file_uploads' => ini_get('max_file_uploads'), ], ]; echo json_encode($payload, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . PHP_EOL;