refactor(discovery): use ping for discovery and fill MAC via SSH
This commit is contained in:
131
auto-check/pkg/stress/chart.go
Normal file
131
auto-check/pkg/stress/chart.go
Normal file
@@ -0,0 +1,131 @@
|
||||
package stress
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// chartData 给 JS 用的数据
|
||||
type chartData struct {
|
||||
Labels []string `json:"labels"`
|
||||
CPU []float64 `json:"cpu"`
|
||||
Temp []float64 `json:"temp"`
|
||||
Title string `json:"title"`
|
||||
}
|
||||
|
||||
// WriteChartHTML 根据采样数据生成折线图 HTML 文件,返回文件路径
|
||||
func WriteChartHTML(ip string, result Result, reportDir string) (string, error) {
|
||||
if len(result.Samples) == 0 {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
cd := chartData{
|
||||
Title: fmt.Sprintf("%s - %s 压测曲线 (%s)", ip, result.Type, result.Duration),
|
||||
}
|
||||
for _, s := range result.Samples {
|
||||
cd.Labels = append(cd.Labels, s.Time)
|
||||
cd.CPU = append(cd.CPU, s.CPU)
|
||||
cd.Temp = append(cd.Temp, s.Temp)
|
||||
}
|
||||
|
||||
dataJSON, err := json.Marshal(cd)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
html := strings.Replace(chartHTMLTemplate, "__DATA__", string(dataJSON), 1)
|
||||
|
||||
os.MkdirAll(reportDir, 0755)
|
||||
filename := fmt.Sprintf("%s/chart-%s-%s.html", reportDir, result.Type, SanitizeFilename(ip))
|
||||
if err := os.WriteFile(filename, []byte(html), 0644); err != nil {
|
||||
return "", err
|
||||
}
|
||||
return filename, nil
|
||||
}
|
||||
|
||||
// SanitizeFilename 清理 IP 中的特殊字符,用于文件名
|
||||
func SanitizeFilename(ip string) string {
|
||||
return strings.ReplaceAll(ip, ":", "_")
|
||||
}
|
||||
|
||||
const chartHTMLTemplate = `<!DOCTYPE html>
|
||||
<html lang="zh">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>压测曲线</title>
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js@4"></script>
|
||||
<style>
|
||||
body { font-family: -apple-system, sans-serif; margin: 40px; background: #f5f5f5; }
|
||||
.container { max-width: 960px; margin: 0 auto; background: #fff; padding: 30px; border-radius: 12px; box-shadow: 0 2px 12px rgba(0,0,0,0.08); }
|
||||
h2 { margin: 0 0 20px; color: #333; }
|
||||
canvas { max-height: 400px; }
|
||||
.legend { display: flex; gap: 24px; margin-top: 16px; font-size: 13px; color: #666; }
|
||||
.legend span { display: flex; align-items: center; gap: 6px; }
|
||||
.legend .dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h2 id="title"></h2>
|
||||
<canvas id="chart"></canvas>
|
||||
<div class="legend">
|
||||
<span><span class="dot" style="background:#f97316"></span> CPU 使用率 (%)</span>
|
||||
<span><span class="dot" style="background:#ef4444"></span> 温度 (°C)</span>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
const data = __DATA__;
|
||||
document.getElementById('title').textContent = data.title;
|
||||
new Chart(document.getElementById('chart'), {
|
||||
type: 'line',
|
||||
data: {
|
||||
labels: data.labels,
|
||||
datasets: [
|
||||
{
|
||||
label: 'CPU 使用率 (%)',
|
||||
data: data.cpu,
|
||||
borderColor: '#f97316',
|
||||
backgroundColor: 'rgba(249,115,22,0.08)',
|
||||
fill: true,
|
||||
tension: 0.3,
|
||||
yAxisID: 'y'
|
||||
},
|
||||
{
|
||||
label: '温度 (°C)',
|
||||
data: data.temp,
|
||||
borderColor: '#ef4444',
|
||||
backgroundColor: 'rgba(239,68,68,0.05)',
|
||||
fill: true,
|
||||
tension: 0.3,
|
||||
yAxisID: 'y1'
|
||||
}
|
||||
]
|
||||
},
|
||||
options: {
|
||||
responsive: true,
|
||||
interaction: { intersect: false, mode: 'index' },
|
||||
plugins: { legend: { display: false } },
|
||||
scales: {
|
||||
y: {
|
||||
type: 'linear',
|
||||
position: 'left',
|
||||
min: 0,
|
||||
max: 100,
|
||||
title: { display: true, text: 'CPU (%)' },
|
||||
grid: { color: '#f0f0f0' }
|
||||
},
|
||||
y1: {
|
||||
type: 'linear',
|
||||
position: 'right',
|
||||
title: { display: true, text: '温度 (°C)' },
|
||||
grid: { drawOnChartArea: false }
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>`
|
||||
@@ -2,11 +2,14 @@ package stress
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"auto-check/pkg/config"
|
||||
"auto-check/pkg/discovery"
|
||||
"auto-check/pkg/sshclient"
|
||||
|
||||
"golang.org/x/crypto/ssh"
|
||||
@@ -56,11 +59,11 @@ func (r *Runner) Run(ip string) *Report {
|
||||
}
|
||||
fmt.Println()
|
||||
|
||||
// 生成脚本
|
||||
script := BuildScript(r.metrics, r.cfg)
|
||||
// 按需读取各测试脚本,拼装成完整脚本
|
||||
script := r.assembleScript()
|
||||
fmt.Printf(" [脚本] 拼装完成,%d 字节\n", len(script))
|
||||
|
||||
// 远程执行脚本(通过 stdin 传入)
|
||||
fmt.Printf(" [执行] 生成脚本 %d 字节,开始远程执行...\n", len(script))
|
||||
// 通过 heredoc 传到远程执行
|
||||
scriptCmd := fmt.Sprintf("cat <<'AUTOCHECKSCRIPT' > /tmp/auto-check.sh\n%s\nAUTOCHECKSCRIPT\nchmod +x /tmp/auto-check.sh && bash /tmp/auto-check.sh 2>&1", script)
|
||||
output, err := sshclient.RunCommand(r.client, scriptCmd)
|
||||
|
||||
@@ -73,6 +76,18 @@ func (r *Runner) Run(ip string) *Report {
|
||||
r.parseResults(report, output)
|
||||
}
|
||||
|
||||
// 生成采样折线图
|
||||
for _, res := range report.Results {
|
||||
if len(res.Samples) > 0 {
|
||||
chartPath, err := WriteChartHTML(ip, res, "reports")
|
||||
if err != nil {
|
||||
fmt.Printf(" [图表] 生成失败: %v\n", err)
|
||||
} else {
|
||||
fmt.Printf(" [图表] %s\n", chartPath)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
report.EndTime = time.Now()
|
||||
report.Duration = report.EndTime.Sub(report.StartTime)
|
||||
fmt.Printf("\n════════ [%s] 压力测试完成 ════════\n", ip)
|
||||
@@ -87,6 +102,8 @@ func (r *Runner) parseResults(report *Report, output string) {
|
||||
var currentStatus string
|
||||
var currentDuration string
|
||||
var currentOutput []string
|
||||
var currentSamples []Sample
|
||||
inSamples := false
|
||||
|
||||
flush := func() {
|
||||
if currentTest == "" {
|
||||
@@ -107,16 +124,41 @@ func (r *Runner) parseResults(report *Report, output string) {
|
||||
Status: status,
|
||||
Output: strings.Join(currentOutput, "\n"),
|
||||
Duration: duration,
|
||||
Samples: currentSamples,
|
||||
})
|
||||
currentTest = ""
|
||||
currentStatus = ""
|
||||
currentDuration = ""
|
||||
currentOutput = nil
|
||||
currentSamples = nil
|
||||
}
|
||||
|
||||
for _, line := range lines {
|
||||
line = strings.TrimSpace(line)
|
||||
|
||||
// 采样数据块
|
||||
if line == "===SAMPLES===" {
|
||||
inSamples = true
|
||||
continue
|
||||
}
|
||||
if line == "===END_SAMPLES===" {
|
||||
inSamples = false
|
||||
continue
|
||||
}
|
||||
if inSamples {
|
||||
parts := strings.Split(line, ",")
|
||||
if len(parts) >= 3 {
|
||||
cpu, _ := strconv.ParseFloat(strings.TrimSpace(parts[1]), 64)
|
||||
temp, _ := strconv.ParseFloat(strings.TrimSpace(parts[2]), 64)
|
||||
currentSamples = append(currentSamples, Sample{
|
||||
Time: strings.TrimSpace(parts[0]),
|
||||
CPU: cpu,
|
||||
Temp: temp,
|
||||
})
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
if strings.HasPrefix(line, "===TEST:") {
|
||||
flush()
|
||||
currentTest = strings.TrimSuffix(strings.TrimPrefix(line, "===TEST:"), "===")
|
||||
@@ -169,6 +211,81 @@ func (r *Runner) parseResults(report *Report, output string) {
|
||||
}
|
||||
}
|
||||
|
||||
// assembleScript 根据 metrics 读取对应的独立脚本文件,拼装成完整脚本
|
||||
func (r *Runner) assembleScript() string {
|
||||
var sb strings.Builder
|
||||
|
||||
// shebang + 环境变量导出
|
||||
sb.WriteString("#!/bin/bash\n")
|
||||
sb.WriteString("set -e\n\n")
|
||||
|
||||
// 导出参数变量
|
||||
sb.WriteString(fmt.Sprintf("export AUTOCHECK_DURATION=%d\n", int(r.cfg.Duration.Seconds())))
|
||||
sb.WriteString(fmt.Sprintf("export AUTOCHECK_THREADS=%d\n", r.cfg.Threads))
|
||||
sb.WriteString(fmt.Sprintf("export AUTOCHECK_DISK_SIZE_MB=%d\n", r.cfg.DiskSizeMB))
|
||||
sb.WriteString(fmt.Sprintf("export AUTOCHECK_MEM_SIZE_MB=%d\n", r.cfg.MemSizeMB))
|
||||
sb.WriteString(fmt.Sprintf("export AUTOCHECK_TEMP_INTERVAL=%d\n", int(r.cfg.TempLogInt.Seconds())))
|
||||
sb.WriteString("export AUTOCHECK_SAMPLE_INTERVAL=2\n")
|
||||
if r.cfg.DiskDir != "" {
|
||||
sb.WriteString(fmt.Sprintf("export AUTOCHECK_DISK_DIR=%s\n", r.cfg.DiskDir))
|
||||
}
|
||||
sb.WriteString("\n")
|
||||
|
||||
// 系统信息
|
||||
sb.Write(r.readScript("sysinfo"))
|
||||
sb.WriteString("\n")
|
||||
|
||||
// 温度监控启动
|
||||
hasTemp := false
|
||||
for _, m := range r.metrics {
|
||||
if m.Name == "temp" && m.Enabled {
|
||||
hasTemp = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if hasTemp {
|
||||
sb.Write(r.readScript("temp_start"))
|
||||
sb.WriteString("\n")
|
||||
}
|
||||
|
||||
// 逐个测试脚本
|
||||
for _, m := range r.metrics {
|
||||
if m.IsMonitor || !m.Enabled {
|
||||
continue
|
||||
}
|
||||
data := r.readScript(m.Name)
|
||||
if data == nil {
|
||||
sb.WriteString(fmt.Sprintf("echo '===TEST:%s==='\n", m.Name))
|
||||
sb.WriteString("echo 'status:skip'\n")
|
||||
sb.WriteString(fmt.Sprintf("echo 'output:脚本文件 scripts/%s.sh 不存在'\n", m.Name))
|
||||
sb.WriteString("echo ''\n")
|
||||
continue
|
||||
}
|
||||
sb.Write(data)
|
||||
sb.WriteString("\n")
|
||||
}
|
||||
|
||||
// 温度监控收尾
|
||||
if hasTemp {
|
||||
sb.Write(r.readScript("temp_end"))
|
||||
sb.WriteString("\n")
|
||||
}
|
||||
|
||||
// dmesg + 结束标记
|
||||
sb.Write(r.readScript("dmesg"))
|
||||
|
||||
return sb.String()
|
||||
}
|
||||
|
||||
// readScript 读取 scripts/ 目录下的脚本文件
|
||||
func (r *Runner) readScript(name string) []byte {
|
||||
data, err := os.ReadFile(fmt.Sprintf("scripts/%s.sh", name))
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
// ============================
|
||||
// 业务入口(workflow 调用)
|
||||
// ============================
|
||||
@@ -184,6 +301,15 @@ func TestDevice(ip string, cfg config.Config) *Report {
|
||||
}
|
||||
defer conn.Close()
|
||||
|
||||
// SSH 登录成功后回填远端 MAC(发现阶段只做了 ping,暂无 MAC)
|
||||
if mac := queryRemoteMAC(conn); mac != "" {
|
||||
if dev, ok := discovery.Devices[ip]; ok {
|
||||
dev.MAC = mac
|
||||
discovery.Devices[ip] = dev
|
||||
}
|
||||
fmt.Printf(" [MAC] %s -> %s\n", ip, mac)
|
||||
}
|
||||
|
||||
stressCfg := Config{
|
||||
Duration: cfg.Stress.Duration,
|
||||
Threads: cfg.Stress.Threads,
|
||||
@@ -203,6 +329,34 @@ func NewSSHFailReport(ip string, err error) *Report {
|
||||
}
|
||||
}
|
||||
|
||||
// queryRemoteMAC 查询远端主机的 MAC 地址(取第一个有效的单播地址)。
|
||||
// 失败或无有效地址时返回空字符串,不阻断主流程。
|
||||
func queryRemoteMAC(client *ssh.Client) string {
|
||||
out, err := sshclient.RunCommand(client, "cat /sys/class/net/*/address 2>/dev/null")
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
for _, line := range strings.Split(out, "\n") {
|
||||
mac := strings.TrimSpace(line)
|
||||
if mac == "" {
|
||||
continue
|
||||
}
|
||||
hw, e := net.ParseMAC(mac)
|
||||
if e != nil || len(hw) != 6 {
|
||||
continue
|
||||
}
|
||||
// 排除零地址、广播、组播
|
||||
if hw[0] == 0 && hw[1] == 0 && hw[2] == 0 && hw[3] == 0 && hw[4] == 0 && hw[5] == 0 {
|
||||
continue
|
||||
}
|
||||
if hw[0]&0x01 != 0 {
|
||||
continue
|
||||
}
|
||||
return hw.String()
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// ============================
|
||||
// 工具函数
|
||||
// ============================
|
||||
|
||||
@@ -1,156 +0,0 @@
|
||||
package stress
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// ============================
|
||||
// 脚本生成(根据指标生成远程执行的 shell 脚本)
|
||||
// ============================
|
||||
|
||||
// BuildScript 根据指标列表和配置生成 self-contained shell 脚本
|
||||
// 脚本输出结构化文本,便于 ParseResults 解析
|
||||
func BuildScript(metrics []Metric, cfg Config) string {
|
||||
var sb strings.Builder
|
||||
|
||||
// 脚本头部
|
||||
sb.WriteString("#!/bin/bash\n")
|
||||
sb.WriteString("set -e\n\n")
|
||||
|
||||
// 系统信息探测
|
||||
sb.WriteString("echo '===SYSTEM_INFO==='\n")
|
||||
sb.WriteString("echo hostname:$(hostname)\n")
|
||||
sb.WriteString("echo cpu:$(lscpu 2>/dev/null | grep 'Model name' | sed 's/Model name:\\s*//' || echo unknown)\n")
|
||||
sb.WriteString("echo cores:$(nproc 2>/dev/null || echo 0)\n")
|
||||
sb.WriteString("echo memory:$(free -h 2>/dev/null | awk '/Mem:/{print $2}' || echo unknown)\n")
|
||||
sb.WriteString("echo kernel:$(uname -r 2>/dev/null || echo unknown)\n")
|
||||
sb.WriteString("echo disk:$(lsblk -d -o NAME,SIZE 2>/dev/null | head -3 | tr '\\n' ' ')\n")
|
||||
sb.WriteString("echo ''\n\n")
|
||||
|
||||
// 启动温度监控(后台)
|
||||
hasTemp := false
|
||||
for _, m := range metrics {
|
||||
if m.Name == "temp" && m.Enabled {
|
||||
hasTemp = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if hasTemp {
|
||||
tempInterval := int(cfg.TempLogInt.Seconds())
|
||||
if tempInterval <= 0 {
|
||||
tempInterval = 10
|
||||
}
|
||||
sb.WriteString(fmt.Sprintf("# 温度监控(后台)\n"))
|
||||
sb.WriteString("TEMP_LOG=/tmp/auto-check-temp.log\n")
|
||||
sb.WriteString("> $TEMP_LOG\n")
|
||||
sb.WriteString(fmt.Sprintf("(while true; do sensors 2>/dev/null | grep -i 'temp\\|core\\|cpu' | head -5 >> $TEMP_LOG; sleep %d; done) &\n", tempInterval))
|
||||
sb.WriteString("TEMP_PID=$!\n\n")
|
||||
}
|
||||
|
||||
// 逐项执行测试
|
||||
for _, m := range metrics {
|
||||
if m.IsMonitor || !m.Enabled {
|
||||
continue
|
||||
}
|
||||
sb.WriteString(fmt.Sprintf("echo '===TEST:%s==='\n", m.Name))
|
||||
sb.WriteString("START_TIME=$(date +%%s%%N)\n")
|
||||
sb.WriteString("set +e\n")
|
||||
|
||||
cmd := buildTestCommand(m, cfg)
|
||||
sb.WriteString(fmt.Sprintf("OUTPUT=$(%s 2>&1)\n", cmd))
|
||||
sb.WriteString("EXIT_CODE=$?\n")
|
||||
sb.WriteString("set -e\n")
|
||||
sb.WriteString("END_TIME=$(date +%%s%%N)\n")
|
||||
sb.WriteString("DURATION=$(( (END_TIME - START_TIME) / 1000000 ))\n")
|
||||
|
||||
// 判定结果
|
||||
sb.WriteString("if [ $EXIT_CODE -eq 0 ]; then\n")
|
||||
sb.WriteString(" echo 'status:pass'\n")
|
||||
sb.WriteString("else\n")
|
||||
sb.WriteString(" echo 'status:fail'\n")
|
||||
sb.WriteString("fi\n")
|
||||
sb.WriteString("echo \"duration:${DURATION}ms\"\n")
|
||||
sb.WriteString("echo \"output:${OUTPUT}\"\n")
|
||||
sb.WriteString("echo ''\n\n")
|
||||
}
|
||||
|
||||
// 收集温度监控结果
|
||||
if hasTemp {
|
||||
sb.WriteString("echo '===MONITOR:temp==='\n")
|
||||
sb.WriteString("if [ -f $TEMP_LOG ] && [ -s $TEMP_LOG ]; then\n")
|
||||
sb.WriteString(" echo 'status:pass'\n")
|
||||
sb.WriteString(" TEMP_MAX=$(grep -oP '\\d+\\.?\\d*°C' $TEMP_LOG | sort -t. -k1 -n | tail -1 || echo 'unknown')\n")
|
||||
sb.WriteString(" echo \"samples:$(wc -l < $TEMP_LOG)\"\n")
|
||||
sb.WriteString(" echo \"max:$TEMP_MAX\"\n")
|
||||
sb.WriteString(" echo \"output:$(tail -10 $TEMP_LOG)\"\n")
|
||||
sb.WriteString("else\n")
|
||||
sb.WriteString(" echo 'status:skip'\n")
|
||||
sb.WriteString("fi\n")
|
||||
sb.WriteString("echo ''\n")
|
||||
sb.WriteString("kill $TEMP_PID 2>/dev/null || true\n\n")
|
||||
}
|
||||
|
||||
// 收集 dmesg 结果
|
||||
sb.WriteString("echo '===MONITOR:dmesg==='\n")
|
||||
sb.WriteString("DMESG_ERR=$(dmesg --level=err,crit,alert,emerg 2>/dev/null | tail -30 || true)\n")
|
||||
sb.WriteString("if [ -n \"$DMESG_ERR\" ]; then\n")
|
||||
sb.WriteString(" echo 'status:fail'\n")
|
||||
sb.WriteString(" echo \"output:$DMESG_ERR\"\n")
|
||||
sb.WriteString("else\n")
|
||||
sb.WriteString(" echo 'status:pass'\n")
|
||||
sb.WriteString(" echo 'output:无硬件相关内核报错'\n")
|
||||
sb.WriteString("fi\n")
|
||||
sb.WriteString("echo ''\n")
|
||||
sb.WriteString("echo '===END==='\n")
|
||||
|
||||
return sb.String()
|
||||
}
|
||||
|
||||
// buildTestCommand 根据指标生成测试命令
|
||||
func buildTestCommand(m Metric, cfg Config) string {
|
||||
sec := int(cfg.Duration.Seconds())
|
||||
threads := cfg.Threads
|
||||
|
||||
switch m.Name {
|
||||
case "cpu":
|
||||
return fmt.Sprintf("stress-ng --cpu %d --cpu-method all --timeout %ds --metrics-brief --temp-path /tmp", threads, sec)
|
||||
|
||||
case "memory":
|
||||
workers := threads
|
||||
if workers > 4 {
|
||||
workers = 4
|
||||
}
|
||||
return fmt.Sprintf("stress-ng --vm %d --vm-bytes 256M --vm-method all --timeout %ds --metrics-brief", workers, sec)
|
||||
|
||||
case "disk":
|
||||
testDir := cfg.DiskDir
|
||||
if testDir == "" {
|
||||
testDir = "/tmp/stress-disk-test"
|
||||
}
|
||||
diskMB := cfg.DiskSizeMB
|
||||
if diskMB <= 0 {
|
||||
diskMB = 1024
|
||||
}
|
||||
return fmt.Sprintf("mkdir -p %s && stress-ng --iomix 2 --iomix-bytes %dM --timeout %ds --metrics-brief && rm -rf %s",
|
||||
testDir, diskMB, sec, testDir)
|
||||
|
||||
case "memnative":
|
||||
memMB := cfg.MemSizeMB
|
||||
if memMB <= 0 {
|
||||
memMB = 0 // 脚本内自动计算
|
||||
}
|
||||
if memMB > 0 {
|
||||
return fmt.Sprintf("stressapptest -s %d -M %d -f 0 -v", sec, memMB)
|
||||
}
|
||||
// 自动计算可用内存的 60%
|
||||
return fmt.Sprintf("M=$(free -m 2>/dev/null | awk '/Mem:/{print int($7*0.6)}' || echo 512) && stressapptest -s %d -M $M -f 0 -v", sec)
|
||||
|
||||
case "full":
|
||||
return fmt.Sprintf("stress-ng --cpu %d --vm 2 --vm-bytes 128M --iomix 1 --iomix-bytes 256M --timeout %ds --metrics-brief",
|
||||
threads, sec)
|
||||
|
||||
default:
|
||||
return "echo '未知测试类型'"
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,14 @@ type Result struct {
|
||||
Output string
|
||||
Error string
|
||||
Duration time.Duration
|
||||
Samples []Sample // 时序采样数据(cpu 等测试采集)
|
||||
}
|
||||
|
||||
// Sample 单次采样点
|
||||
type Sample struct {
|
||||
Time string // HH:MM:SS
|
||||
CPU float64 // CPU 使用率 %
|
||||
Temp float64 // 温度 °C
|
||||
}
|
||||
|
||||
// Report 完整压测报告
|
||||
|
||||
Reference in New Issue
Block a user