forked from ccfos/nightingale
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrouter_status.go
42 lines (31 loc) · 966 Bytes
/
router_status.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package http
import (
"time"
"github.com/didi/nightingale/v5/models"
"github.com/gin-gonic/gin"
)
func Status(c *gin.Context) {
var err error
data := make(map[string]int64)
data["user_total"], err = models.UserTotal("")
dangerous(err)
data["user_group_total"], err = models.UserGroupTotal("")
dangerous(err)
data["resource_total"], err = models.ResourceTotal("")
dangerous(err)
data["alert_rule_total"], err = models.AlertRuleTotal("")
dangerous(err)
data["dashboard_total"], err = models.DashboardCount("")
dangerous(err)
now := time.Now().Unix()
stime := now - 24*3600
data["event_total_day"], err = models.AlertEventTotal(stime, now, "", -1, -1)
dangerous(err)
stime = now - 7*24*3600
data["event_total_week"], err = models.AlertEventTotal(stime, now, "", -1, -1)
dangerous(err)
stime = now - 30*24*3600
data["event_total_month"], err = models.AlertEventTotal(stime, now, "", -1, -1)
dangerous(err)
renderData(c, data, nil)
}