Skip to content

Commit

Permalink
feat: 新增逻辑内核数
Browse files Browse the repository at this point in the history
  • Loading branch information
rehiy committed Feb 14, 2023
1 parent f0870f9 commit 1c4d5e1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 23 deletions.
23 changes: 12 additions & 11 deletions helper/psutil/def.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@ import (
)

type SummaryStat struct {
HostId string
HostName string
Uptime uint64
OS string
Platform string
KernelArch string
CpuCore int
CpuPercent []float64
MemoryTotal uint64
MemoryUsed uint64
IpAddress string
HostId string
HostName string
Uptime uint64
OS string
Platform string
KernelArch string
CpuCore int
CpuCoreLogic int
CpuPercent []float64
MemoryTotal uint64
MemoryUsed uint64
IpAddress string
}

type DetailStat struct {
Expand Down
26 changes: 14 additions & 12 deletions helper/psutil/systat.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,24 @@ import (
func Summary() *SummaryStat {

hi, _ := host.Info()
cc, _ := cpu.Counts(true)
cl, _ := cpu.Counts(true)
cc, _ := cpu.Counts(false)
cp, _ := cpu.Percent(time.Second, false)
mv, _ := mem.VirtualMemory()

return &SummaryStat{
HostId: hi.HostID,
HostName: hi.Hostname,
Uptime: hi.Uptime,
OS: hi.OS,
Platform: hi.Platform,
KernelArch: hi.KernelArch,
CpuCore: cc,
CpuPercent: cp,
MemoryTotal: mv.Total,
MemoryUsed: mv.Used,
IpAddress: getIpAddress(false),
HostId: hi.HostID,
HostName: hi.Hostname,
Uptime: hi.Uptime,
OS: hi.OS,
Platform: hi.Platform,
KernelArch: hi.KernelArch,
CpuCore: cc,
CpuCoreLogic: cl,
CpuPercent: cp,
MemoryTotal: mv.Total,
MemoryUsed: mv.Used,
IpAddress: getIpAddress(false),
}

}
Expand Down

0 comments on commit 1c4d5e1

Please sign in to comment.