forked from ccfos/nightingale
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* bugfix: whiteList list return empty * support multi-dict for i18n && add mongodb for monapi as a plugin * use 10day as max lifetime for extra mode auth * bugfix: ignore i18n with default value * Spelling mistakes
- Loading branch information
Showing
25 changed files
with
3,547 additions
and
137 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
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
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
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
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
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
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
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 |
---|---|---|
@@ -1,38 +1,71 @@ | ||
package redis | ||
package mongodb | ||
|
||
import ( | ||
"github.com/didi/nightingale/src/modules/monapi/collector" | ||
"github.com/didi/nightingale/src/modules/monapi/plugins/mongodb/mongodb" | ||
"github.com/didi/nightingale/src/toolkits/i18n" | ||
"github.com/influxdata/telegraf" | ||
"github.com/influxdata/telegraf/plugins/inputs/redis" | ||
) | ||
|
||
func init() { | ||
collector.CollectorRegister(NewRedisCollector()) // for monapi | ||
collector.CollectorRegister(NewMongodbCollector()) // for monapi | ||
i18n.DictRegister(langDict) | ||
} | ||
|
||
type RedisCollector struct { | ||
var ( | ||
langDict = map[string]map[string]string{ | ||
"zh": map[string]string{ | ||
"Servers": "服务", | ||
"An array of URLs of the form": "服务地址", | ||
"Cluster status": "采集集群", | ||
"When true, collect cluster status.": "采集集群统计信息", | ||
"Per DB stats": "采集单个数据库(db)统计信息", | ||
"When true, collect per database stats": "采集一个数据库的统计信息", | ||
"Col stats": "采集集合(Collection)统计信息", | ||
"When true, collect per collection stats": "采集一个集合的统计信息", | ||
"Col stats dbs": "采集集合的列表", | ||
"List of db where collections stats are collected, If empty, all db are concerned": "如果设置为空,则采集数据库里所有集合的统计信息", | ||
}, | ||
} | ||
) | ||
|
||
type MongodbCollector struct { | ||
*collector.BaseCollector | ||
} | ||
|
||
func NewRedisCollector() *RedisCollector { | ||
return &RedisCollector{BaseCollector: collector.NewBaseCollector( | ||
"redis", | ||
func NewMongodbCollector() *MongodbCollector { | ||
return &MongodbCollector{BaseCollector: collector.NewBaseCollector( | ||
"mongodb", | ||
collector.RemoteCategory, | ||
func() interface{} { return &RedisRule{} }, | ||
func() interface{} { return &MongodbRule{} }, | ||
)} | ||
} | ||
|
||
type RedisRule struct { | ||
type MongodbRule struct { | ||
Servers []string `label:"Servers" json:"servers,required" description:"An array of URLs of the form" example:"mongodb://user:[email protected]:27017"` | ||
GatherClusterStatus bool `label:"Cluster status" json:"gather_cluster_status" description:"When true, collect cluster status." default:"true"` | ||
GatherPerdbStats bool `label:"Per DB stats" json:"gather_perdb_stats" description:"When true, collect per database stats" default:"false"` | ||
GatherColStats bool `label:"Col stats" json:"gather_col_stats" description:"When true, collect per collection stats" default:"false"` | ||
ColStatsDbs []string `label:"Col stats dbs" json:"col_stats_dbs" description:"List of db where collections stats are collected, If empty, all db are concerned" example:"local" default:"[\"local\"]"` | ||
// tlsint.ClientConfig | ||
// Ssl Ssl | ||
} | ||
|
||
func (p *RedisRule) Validate() error { | ||
func (p *MongodbRule) Validate() error { | ||
return nil | ||
} | ||
|
||
func (p *RedisRule) TelegrafInput() (telegraf.Input, error) { | ||
func (p *MongodbRule) TelegrafInput() (telegraf.Input, error) { | ||
if err := p.Validate(); err != nil { | ||
return nil, err | ||
} | ||
|
||
return &redis.Redis{}, nil | ||
return &mongodb.MongoDB{ | ||
Servers: p.Servers, | ||
Mongos: make(map[string]*mongodb.Server), | ||
GatherClusterStatus: p.GatherClusterStatus, | ||
GatherPerdbStats: p.GatherPerdbStats, | ||
GatherColStats: p.GatherColStats, | ||
ColStatsDbs: p.ColStatsDbs, | ||
}, nil | ||
} |
Oops, something went wrong.