collect config sys enable,default true (#272)

Co-authored-by: wangzhiguo04 <wangzhiguo04@meicai.cn>
This commit is contained in:
xingren23 2020-07-26 12:31:31 +08:00 committed by GitHub
parent 66421ae557
commit a72fa5b8dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 44 additions and 25 deletions

View File

@ -14,6 +14,7 @@ stra:
logPath: ./etc/log
sys:
enable: true
# timeout in ms
# interval in second
timeout: 1000

View File

@ -3,6 +3,7 @@ package config
import (
"bytes"
"fmt"
"github.com/didi/nightingale/src/modules/collector/log/worker"
"github.com/didi/nightingale/src/modules/collector/stra"
"github.com/didi/nightingale/src/modules/collector/sys"
@ -61,6 +62,7 @@ func Parse(conf string) error {
})
viper.SetDefault("sys", map[string]interface{}{
"enable": true,
"timeout": 1000, //请求超时时间
"interval": 10, //基础指标上报周期
"pluginRemote": true, //从monapi获取插件采集配置

View File

@ -1,6 +1,7 @@
package sys
type SysSection struct {
Enable bool `yaml:"enable"`
IfacePrefix []string `yaml:"ifacePrefix"`
MountIgnore MountIgnoreSection `yaml:"mountIgnore"`
IgnoreMetrics []string `yaml:"ignoreMetrics"`

View File

@ -1,6 +1,8 @@
package funcs
import (
"log"
"github.com/didi/nightingale/src/dataobj"
"github.com/didi/nightingale/src/modules/collector/sys"
)
@ -14,32 +16,45 @@ var Mappers []FuncsAndInterval
func BuildMappers() {
interval := sys.Config.Interval
Mappers = []FuncsAndInterval{
{
Fs: []func() []*dataobj.MetricValue{
CollectorMetrics,
CpuMetrics,
MemMetrics,
NetMetrics,
LoadAvgMetrics,
IOStatsMetrics,
NfMetrics,
FsKernelMetrics,
FsRWMetrics,
ProcsNumMetrics,
EntityNumMetrics,
NtpOffsetMetrics,
SocketStatSummaryMetrics,
UdpMetrics,
TcpMetrics,
if sys.Config.Enable {
log.Println("sys collect enable is true.")
Mappers = []FuncsAndInterval{
{
Fs: []func() []*dataobj.MetricValue{
CollectorMetrics,
CpuMetrics,
MemMetrics,
NetMetrics,
LoadAvgMetrics,
IOStatsMetrics,
NfMetrics,
FsKernelMetrics,
FsRWMetrics,
ProcsNumMetrics,
EntityNumMetrics,
NtpOffsetMetrics,
SocketStatSummaryMetrics,
UdpMetrics,
TcpMetrics,
},
Interval: interval,
},
Interval: interval,
},
{
Fs: []func() []*dataobj.MetricValue{
DeviceMetrics,
{
Fs: []func() []*dataobj.MetricValue{
DeviceMetrics,
},
Interval: interval,
},
Interval: interval,
},
}
} else {
log.Println("sys collect enable is false.")
Mappers = []FuncsAndInterval{
{
Fs: []func() []*dataobj.MetricValue{
CollectorMetrics,
},
Interval: interval,
},
}
}
}