mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2026-01-05 11:29:00 +08:00
🐛 fix(#95): aifalse error unckeck
This commit is contained in:
parent
9f6e361e6e
commit
560df5cade
@ -43,20 +43,33 @@ func init() { // 插件主体
|
|||||||
}
|
}
|
||||||
|
|
||||||
func cpuPercent() float64 {
|
func cpuPercent() float64 {
|
||||||
percent, _ := cpu.Percent(time.Second, false)
|
percent, err := cpu.Percent(time.Second, false)
|
||||||
|
if err != nil {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
return math.Round(percent[0])
|
return math.Round(percent[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
func memPercent() float64 {
|
func memPercent() float64 {
|
||||||
memInfo, _ := mem.VirtualMemory()
|
memInfo, err := mem.VirtualMemory()
|
||||||
|
if err != nil {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
return math.Round(memInfo.UsedPercent)
|
return math.Round(memInfo.UsedPercent)
|
||||||
}
|
}
|
||||||
|
|
||||||
func diskPercent() string {
|
func diskPercent() string {
|
||||||
parts, _ := disk.Partitions(true)
|
parts, err := disk.Partitions(true)
|
||||||
|
if err != nil {
|
||||||
|
return err.Error()
|
||||||
|
}
|
||||||
msg := ""
|
msg := ""
|
||||||
for _, p := range parts {
|
for _, p := range parts {
|
||||||
diskInfo, _ := disk.Usage(p.Mountpoint)
|
diskInfo, err := disk.Usage(p.Mountpoint)
|
||||||
|
if err != nil {
|
||||||
|
msg += "\n - " + err.Error()
|
||||||
|
continue
|
||||||
|
}
|
||||||
pc := uint(math.Round(diskInfo.UsedPercent))
|
pc := uint(math.Round(diskInfo.UsedPercent))
|
||||||
if pc > 0 {
|
if pc > 0 {
|
||||||
msg += fmt.Sprintf("\n - %s(%dM) %d%%", p.Mountpoint, diskInfo.Total/1024/1024, pc)
|
msg += fmt.Sprintf("\n - %s(%dM) %d%%", p.Mountpoint, diskInfo.Total/1024/1024, pc)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user