109 lines
3.7 KiB
PHP
109 lines
3.7 KiB
PHP
<?php
|
|
require_once __DIR__ . '/tencentcloud.php';
|
|
|
|
echo "=== 腾讯云VPS获取诊断 ===\n\n";
|
|
|
|
// 1. 检查配置
|
|
echo "【步骤1】检查配置...\n";
|
|
$db = getVpsDB();
|
|
$configs = $db->query('SELECT * FROM configs WHERE site_type = ?', ['tencent']);
|
|
|
|
if (empty($configs)) {
|
|
echo "❌ 未找到腾讯云配置\n";
|
|
exit;
|
|
}
|
|
|
|
echo "✅ 找到 " . count($configs) . " 个腾讯云配置\n\n";
|
|
|
|
foreach ($configs as $configIndex => $config) {
|
|
echo "--- 配置 #" . ($configIndex + 1) . " ---\n";
|
|
echo "ID: {$config['id']}\n";
|
|
echo "API标识: {$config['api_label']}\n";
|
|
echo "API域名: {$config['site_url']}\n";
|
|
echo "SecretId: " . substr($config['account'], 0, 15) . "...\n";
|
|
echo "\n";
|
|
|
|
// 2. 测试区域获取
|
|
echo "【步骤2】测试区域获取...\n";
|
|
try {
|
|
$regions = getTencentRegions($config['id'], 'lighthouse');
|
|
echo "✅ 获取到 " . count($regions) . " 个区域\n";
|
|
echo "前3个区域: " . implode(', ', array_slice($regions, 0, 3)) . "\n\n";
|
|
} catch (Exception $e) {
|
|
echo "❌ 区域获取失败: " . $e->getMessage() . "\n\n";
|
|
continue;
|
|
}
|
|
|
|
// 3. 测试实例列表获取
|
|
echo "【步骤3】测试实例列表获取...\n";
|
|
if (!empty($regions)) {
|
|
$testRegion = $regions[0];
|
|
echo "测试区域: {$testRegion}\n";
|
|
|
|
$result = tencentGetLighthouseList($config['id'], $testRegion, 0, 10);
|
|
|
|
if (!$result) {
|
|
echo "❌ API返回null\n\n";
|
|
continue;
|
|
}
|
|
|
|
echo "HTTP状态码: {$result['status']}\n";
|
|
|
|
if (isset($result['error'])) {
|
|
echo "❌ API错误: {$result['error']}\n";
|
|
if (isset($result['code'])) {
|
|
echo "错误代码: {$result['code']}\n";
|
|
}
|
|
if (isset($result['request_id'])) {
|
|
echo "Request ID: {$result['request_id']}\n";
|
|
}
|
|
echo "\n";
|
|
continue;
|
|
}
|
|
|
|
if ($result['status'] !== 200) {
|
|
echo "❌ HTTP状态码异常: {$result['status']}\n\n";
|
|
continue;
|
|
}
|
|
|
|
$instances = $result['data']['InstanceSet'] ?? [];
|
|
$totalCount = $result['data']['TotalCount'] ?? 0;
|
|
|
|
echo "✅ API调用成功\n";
|
|
echo "总实例数: {$totalCount}\n";
|
|
echo "当前页实例数: " . count($instances) . "\n\n";
|
|
|
|
if (!empty($instances)) {
|
|
echo "【步骤4】检查第一个实例数据...\n";
|
|
$instance = $instances[0];
|
|
echo "实例ID: " . ($instance['InstanceId'] ?? 'N/A') . "\n";
|
|
echo "实例名称: " . ($instance['InstanceName'] ?? 'N/A') . "\n";
|
|
echo "状态: " . ($instance['InstanceState'] ?? 'N/A') . "\n";
|
|
echo "CPU: " . ($instance['CPU'] ?? 'N/A') . "核\n";
|
|
echo "内存: " . ($instance['Memory'] ?? 'N/A') . "GB\n";
|
|
|
|
// 检查带宽
|
|
if (isset($instance['InternetAccessible'])) {
|
|
echo "InternetAccessible: 存在\n";
|
|
if (isset($instance['InternetAccessible']['InternetMaxBandwidthOut'])) {
|
|
echo "带宽: " . $instance['InternetAccessible']['InternetMaxBandwidthOut'] . "Mbps\n";
|
|
} else {
|
|
echo "带宽字段: 不存在\n";
|
|
}
|
|
} else {
|
|
echo "InternetAccessible: 不存在\n";
|
|
}
|
|
|
|
echo "\n完整数据结构:\n";
|
|
echo json_encode($instance, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT) . "\n";
|
|
} else {
|
|
echo "⚠️ 该区域没有实例\n";
|
|
}
|
|
}
|
|
|
|
echo "\n" . str_repeat("=", 60) . "\n\n";
|
|
}
|
|
|
|
echo "诊断完成!\n";
|
|
?>
|