Skip to content

Commit

Permalink
Utilization interface to supplement disk information
Browse files Browse the repository at this point in the history
  • Loading branch information
LinkLeong committed Oct 13, 2022
1 parent be80d0c commit 6ea3cdb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 4 additions & 2 deletions route/v1/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ func GetSystemHardwareInfo(c *gin.Context) {
// @Success 200 {string} string "ok"
// @Router /sys/utilization [get]
func GetSystemUtilization(c *gin.Context) {
var data = make(map[string]interface{}, 6)
var data = make(map[string]interface{})
cpu := service.MyService.System().GetCpuPercent()
num := service.MyService.System().GetCpuCoreNum()
cpuData := make(map[string]interface{})
Expand Down Expand Up @@ -299,7 +299,9 @@ func GetSystemUtilization(c *gin.Context) {
}

data["net"] = newNet

for k, v := range service.MyService.Notify().GetSystemTempMap() {
data[k] = v
}
c.JSON(common_err.SUCCESS, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: data})
}

Expand Down
5 changes: 5 additions & 0 deletions service/notify.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type NotifyServer interface {
SendStorageBySocket(message notify.StorageMessage)
SendNotify(path string, message map[string]interface{})
SettingSystemTempData(message map[string]interface{})
GetSystemTempMap() map[string]interface{}
}

type notifyServer struct {
Expand Down Expand Up @@ -442,7 +443,11 @@ func SendMeg() {
// }

// }
func (i *notifyServer) GetSystemTempMap() map[string]interface{} {

return i.SystemTempMap

}
func NewNotifyService(db *gorm.DB) NotifyServer {
return &notifyServer{db: db, SystemTempMap: make(map[string]interface{})}
}

0 comments on commit 6ea3cdb

Please sign in to comment.