forked from open-falcon/falcon-plus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cluster.go
52 lines (47 loc) · 2.42 KB
/
cluster.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
43
44
45
46
47
48
49
50
51
52
package falcon_portal
import (
con "github.com/open-falcon/falcon-plus/modules/api/config"
)
// +-------------+------------------+------+-----+-------------------+-----------------------------+
// | Field | Type | Null | Key | Default | Extra |
// +-------------+------------------+------+-----+-------------------+-----------------------------+
// | id | int(10) unsigned | NO | PRI | NULL | auto_increment |
// | grp_id | int(11) | NO | | NULL | |
// | numerator | varchar(10240) | NO | | NULL | |
// | denominator | varchar(10240) | NO | | NULL | |
// | endpoint | varchar(255) | NO | | NULL | |
// | metric | varchar(255) | NO | | NULL | |
// | tags | varchar(255) | NO | | NULL | |
// | ds_type | varchar(255) | NO | | NULL | |
// | step | int(11) | NO | | NULL | |
// | last_update | timestamp | NO | | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP |
// | creator | varchar(255) | NO | | NULL | |
// +-------------+------------------+------+-----+-------------------+-----------------------------+
type Cluster struct {
ID int64 `json:"id" gorm:"column:id"`
GrpId int64 `json:"grp_id" gorm:"column:grp_id"`
Numerator string `json:"numerator" gorm:"column:numerator"`
Denominator string `json:"denominator" gorm:"denominator"`
Endpoint string `json:"endpoint" gorm:"endpoint"`
Metric string `json:"metric" gorm:"metric"`
Tags string `json:"tags" gorm:"tags"`
DsType string `json:"ds_type" grom:"ds_type"`
Step int `json:"step" gorm:"step"`
Creator string `json:"creator" gorm:"creator"`
}
func (this Cluster) TableName() string {
return "cluster"
}
func (this Cluster) HostGroupName() (name string, err error) {
if this.GrpId == 0 {
return
}
db := con.Con()
var hg HostGroup
hg.ID = this.GrpId
if dt := db.Falcon.Find(&hg); dt.Error != nil {
return name, dt.Error
}
name = hg.Name
return
}