From d3bb26b67ab25f46819ad624096f7bf90d7af530 Mon Sep 17 00:00:00 2001
From: zhangzengfei <zhangzengfei@iotlink.com>
Date: 星期三, 30 十月 2019 15:19:23 +0800
Subject: [PATCH] feat: add system info thresholds at config

---
 controllers/syssetcont.go |   11 +++++++++++
 config/test.yaml          |   15 +++++++++++++++
 extend/config/config.go   |    7 ++++++-
 router/router.go          |    1 +
 4 files changed, 33 insertions(+), 1 deletions(-)

diff --git a/config/test.yaml b/config/test.yaml
index b75ad1b..2fa49df 100644
--- a/config/test.yaml
+++ b/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
diff --git a/controllers/syssetcont.go b/controllers/syssetcont.go
index 3be8a7a..1ba05ba 100644
--- a/controllers/syssetcont.go
+++ b/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)
+}
diff --git a/extend/config/config.go b/extend/config/config.go
index 4dd7ec8..605482a 100644
--- a/extend/config/config.go
+++ b/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{}
diff --git a/router/router.go b/router/router.go
index 440edef..154fd75 100644
--- a/router/router.go
+++ b/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)
 	}
 
 	//绠楁硶搴撴搷浣�

--
Gitblit v1.8.0