diff --git a/cpu.go b/cpu.go index b9abf2b..dd52bb4 100644 --- a/cpu.go +++ b/cpu.go @@ -22,7 +22,7 @@ func getCPUInfo(ip, port string) (int, float64, error) { lines := strings.Split(data, "\n") for _, line := range lines { //有两个版本的Metrics node_cpu_seconds_total and node_cpu - if strings.HasPrefix(line, "node_cpu{cpu=") || strings.HasPrefix(line, "node_cpu_seconds_total") { + if strings.HasPrefix(line, "node_cpu{cpu=") || strings.HasPrefix(line, "node_cpu_seconds_total") || strings.HasPrefix(line, "windows_cpu_time_total") { fields := strings.Fields(line) if len(fields) == 2 { cpuData, err := extractMetricValue(fields[1]) diff --git a/cpu_test.go b/cpu_test.go new file mode 100644 index 0000000..e56377b --- /dev/null +++ b/cpu_test.go @@ -0,0 +1,24 @@ +/* +* +@author: sre +@date: 2023/11/22 0022 +@desc: todo +* +*/ +package main + +import ( + "fmt" + "testing" + "time" +) + +func TestGetWinCPU(t *testing.T) { + ip, port := "127.0.0.1", "9182" + for { + fmt.Println(getCPUInfo(ip, port)) + time.Sleep(time.Second * 1) + } +} + +//windows_cs_physical_memory_bytes diff --git a/host1.csv b/host1.csv deleted file mode 100644 index 00826e7..0000000 --- a/host1.csv +++ /dev/null @@ -1,3 +0,0 @@ -ip,port -119.91.19.44,9100 -119.91.19.44,9100 \ No newline at end of file