-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fd464ea
commit 2c3f21b
Showing
29 changed files
with
1,408 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package monitor | ||
|
||
import ( | ||
"hboat/api/common" | ||
"hboat/pkg/basic/mongo" | ||
"time" | ||
|
||
"github.com/gin-gonic/gin" | ||
"go.mongodb.org/mongo-driver/bson" | ||
) | ||
|
||
func MetricPerformance(c *gin.Context) { | ||
startTime := c.Query("start") | ||
endTime := c.Query("end") | ||
agentID := c.Query("agent_id") | ||
|
||
// 解析开始时间 | ||
start, err := time.Parse(time.RFC3339, startTime) | ||
if err != nil { | ||
common.Response(c, common.ErrorCode, "Invalid start time") | ||
return | ||
} | ||
|
||
// 解析结束时间 | ||
end, err := time.Parse(time.RFC3339, endTime) | ||
if err != nil { | ||
common.Response(c, common.ErrorCode, "Invalid end time") | ||
return | ||
} | ||
|
||
// 设置查询过滤条件 | ||
filter := bson.M{ | ||
"timestamp": bson.M{ | ||
"$gte": start, | ||
"$lte": end, | ||
}, | ||
"agent_id": agentID, | ||
} | ||
|
||
// 从 MongoDB 获取数据 | ||
cur, err := mongo.MongoProxyImpl.MetricC.Find(c, filter) | ||
if err != nil { | ||
common.Response(c, common.ErrorCode, "Error fetching metrics") | ||
return | ||
} | ||
defer cur.Close(c) | ||
|
||
var metricsList []bson.M | ||
for cur.Next(c) { | ||
var metric bson.M | ||
if err := cur.Decode(&metric); err != nil { | ||
common.Response(c, common.ErrorCode, "Error decoding metrics") | ||
return | ||
} | ||
metricsList = append(metricsList, metric) | ||
} | ||
|
||
if err := cur.Err(); err != nil { | ||
common.Response(c, common.ErrorCode, "Cursor error") | ||
return | ||
} | ||
|
||
common.Response(c, common.SuccessCode, metricsList) | ||
} |
289 changes: 289 additions & 0 deletions
289
server/webconsole/api/static/frontend/110.dbbf8584.async.js
Large diffs are not rendered by default.
Oops, something went wrong.
127 changes: 127 additions & 0 deletions
127
server/webconsole/api/static/frontend/314.ecca4367.async.js
Large diffs are not rendered by default.
Oops, something went wrong.
69 changes: 69 additions & 0 deletions
69
server/webconsole/api/static/frontend/334.d42d58e4.async.js
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.