zhangzengfei
2019-10-29 d3bb26b67ab25f46819ad624096f7bf90d7af530
feat: add system info thresholds at config
4个文件已修改
34 ■■■■■ 已修改文件
config/test.yaml 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/syssetcont.go 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
extend/config/config.go 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
router/router.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
config/test.yaml
@@ -19,6 +19,21 @@
  channelCount: 0
  #硬盘个数
  diskCount: 2
  #Exec root command
  sysServerPort: 18081
  sysThresholds:
  -
    value: 60
    color: #13ce66
  -
    value: 80
    color: #FF9C4A
  -
    value: 95
    color: #f53d3d
  -
    value: 100
    color: #5d0000
database:
  driver: sqlite
  name: sqlite3
controllers/syssetcont.go
@@ -356,3 +356,14 @@
    info := sys.GetSysInfo()
    util.ResponseFormat(c, code.UpdateSuccess, info)
}
// @Summary 查询系统状态阈值设置
// @Description 获取当前系统的运行状态,CPU, GPU, 内存的阈值配置
// @Produce json
// @Tags sysset
// @Success 200 {string} json "{"code":200, msg:"目录结构数据", success:true}"
// @Failure 500 {string} json "{"code":500,  msg:"返回错误信息", success:false}"
// @Router /data/api-v/sysset/sysThresholds [GET]
func (sset SysSetController) GetSysThresholds(c *gin.Context) {
    util.ResponseFormat(c, code.UpdateSuccess, config.Server.SysThresholds)
}
extend/config/config.go
@@ -6,6 +6,10 @@
    "github.com/spf13/viper"
)
type threshold struct {
    Value int    `mapstructure: "value"`
    Color string `mapstructure: "color"`
}
type server struct {
    Runmode        string `mapstructure: "runmode"`
    JwtSecret      string `mapstructure: "jwtSecret"`
@@ -22,7 +26,8 @@
    ChannelCount    string `mapstructure: "channelCount"`    //通道个数
    DiskCount       string `mapstructure: "diskCount"`       //硬盘个数
    SysServerPort string `mapstructure: "SysServerPort"`
    SysServerPort string      `mapstructure: "sysServerPort"`
    SysThresholds []threshold `mapstructure: "sysThresholds"`
}
var Server = &server{}
router/router.go
@@ -203,6 +203,7 @@
        vsset.POST("/updateClock", ssController.SetSysClock)
        vsset.GET("/ntpTest", ssController.TestNTPServer)
        vsset.GET("/sysinfo", ssController.GetSysInfo)
        vsset.GET("/sysThresholds", ssController.GetSysThresholds)
    }
    //算法库操作