|
|
|
@ -12,16 +12,18 @@ import (
|
|
|
|
|
|
|
|
|
|
type Collect struct {
|
|
|
|
|
sync.RWMutex
|
|
|
|
|
Ports map[int]*PortCollect `json:"ports"`
|
|
|
|
|
Procs map[string]*ProcCollect `json:"procs"`
|
|
|
|
|
Logs map[string]*LogCollect `json:"logs"`
|
|
|
|
|
Ports map[int]*PortCollect `json:"ports"`
|
|
|
|
|
Procs map[string]*ProcCollect `json:"procs"`
|
|
|
|
|
Logs map[string]*LogCollect `json:"logs"`
|
|
|
|
|
Plugins map[string]*PluginCollect `json:"plugins"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func NewCollect() *Collect {
|
|
|
|
|
return &Collect{
|
|
|
|
|
Ports: make(map[int]*PortCollect),
|
|
|
|
|
Procs: make(map[string]*ProcCollect),
|
|
|
|
|
Logs: make(map[string]*LogCollect),
|
|
|
|
|
Ports: make(map[int]*PortCollect),
|
|
|
|
|
Procs: make(map[string]*ProcCollect),
|
|
|
|
|
Logs: make(map[string]*LogCollect),
|
|
|
|
|
Plugins: make(map[string]*PluginCollect),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -45,6 +47,12 @@ func (c *Collect) Update(cc *Collect) {
|
|
|
|
|
for k, v := range cc.Logs {
|
|
|
|
|
c.Logs[k] = v
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//更新plugin采集配置
|
|
|
|
|
c.Plugins = make(map[string]*PluginCollect)
|
|
|
|
|
for k, v := range cc.Plugins {
|
|
|
|
|
c.Plugins[k] = v
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *Collect) GetPorts() map[int]*PortCollect {
|
|
|
|
@ -80,6 +88,17 @@ func (c *Collect) GetLogConfig() map[string]*LogCollect {
|
|
|
|
|
return tmp
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *Collect) GetPlugin() map[string]*PluginCollect {
|
|
|
|
|
c.RLock()
|
|
|
|
|
defer c.RUnlock()
|
|
|
|
|
|
|
|
|
|
tmp := make(map[string]*PluginCollect)
|
|
|
|
|
for k, v := range c.Plugins {
|
|
|
|
|
tmp[k] = v
|
|
|
|
|
}
|
|
|
|
|
return tmp
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type PortCollect struct {
|
|
|
|
|
Id int64 `json:"id"`
|
|
|
|
|
Nid int64 `json:"nid"`
|
|
|
|
@ -114,6 +133,21 @@ type ProcCollect struct {
|
|
|
|
|
CollectMethod string `json:"collect_method"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type PluginCollect struct {
|
|
|
|
|
Id int64 `json:"id"`
|
|
|
|
|
Nid int64 `json:"nid"`
|
|
|
|
|
CollectType string `json:"collect_type"`
|
|
|
|
|
Name string `json:"name"`
|
|
|
|
|
Step int `json:"step"`
|
|
|
|
|
FilePath string `json:"file_path"`
|
|
|
|
|
Params string `json:"params"`
|
|
|
|
|
Comment string `json:"comment"`
|
|
|
|
|
Creator string `json:"creator"`
|
|
|
|
|
Created time.Time `xorm:"updated" json:"created"`
|
|
|
|
|
LastUpdator string `xorm:"last_updator" json:"last_updator"`
|
|
|
|
|
LastUpdated time.Time `xorm:"updated" json:"last_updated"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type LogCollect struct {
|
|
|
|
|
Id int64 `json:"id"`
|
|
|
|
|
Nid int64 `json:"nid"`
|
|
|
|
|