chore: 更新升级gopsutil/v3到gopsutil/v4
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"runtime"
|
||||
@@ -10,11 +11,11 @@ import (
|
||||
"be.ems/src/framework/config"
|
||||
"be.ems/src/framework/utils/parse"
|
||||
|
||||
"github.com/shirou/gopsutil/v3/cpu"
|
||||
"github.com/shirou/gopsutil/v3/disk"
|
||||
"github.com/shirou/gopsutil/v3/host"
|
||||
"github.com/shirou/gopsutil/v3/mem"
|
||||
"github.com/shirou/gopsutil/v3/net"
|
||||
"github.com/shirou/gopsutil/v4/cpu"
|
||||
"github.com/shirou/gopsutil/v4/disk"
|
||||
"github.com/shirou/gopsutil/v4/host"
|
||||
"github.com/shirou/gopsutil/v4/mem"
|
||||
"github.com/shirou/gopsutil/v4/net"
|
||||
)
|
||||
|
||||
// 实例化服务层 SystemInfoImpl 结构体
|
||||
@@ -150,9 +151,12 @@ func (s *SystemInfoImpl) NetworkInfo() map[string]string {
|
||||
// DiskInfo 磁盘信息
|
||||
func (s *SystemInfoImpl) DiskInfo() []map[string]string {
|
||||
disks := make([]map[string]string, 0)
|
||||
ctx := context.Background()
|
||||
ctx, cancel := context.WithTimeout(ctx, 1*time.Second)
|
||||
defer cancel()
|
||||
|
||||
partitions, err := disk.Partitions(false)
|
||||
if err != nil {
|
||||
partitions, err := disk.PartitionsWithContext(ctx, false)
|
||||
if err != context.DeadlineExceeded {
|
||||
return disks
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user