Provide default args: percpu=true and totalcpu=true for cpu plugin

Also if outputs.file is empty, write to stdout

closes #720
This commit is contained in:
Cameron Sparr 2016-02-19 11:56:33 -07:00 committed by Michele Fadda
parent 7d8e883307
commit 659357c1d0
2 changed files with 10 additions and 1 deletions

View File

@ -113,6 +113,10 @@ func totalCpuTime(t cpu.CPUTimesStat) float64 {
func init() { func init() {
inputs.Add("cpu", func() telegraf.Input { inputs.Add("cpu", func() telegraf.Input {
return &CPUStats{ps: &systemPS{}} return &CPUStats{
PerCPU: true,
TotalCPU: true,
ps: &systemPS{},
}
}) })
} }

View File

@ -36,6 +36,11 @@ func (f *File) SetSerializer(serializer serializers.Serializer) {
func (f *File) Connect() error { func (f *File) Connect() error {
writers := []io.Writer{} writers := []io.Writer{}
if len(f.Files) == 0 {
f.Files = []string{"stdout"}
}
for _, file := range f.Files { for _, file := range f.Files {
if file == "stdout" { if file == "stdout" {
writers = append(writers, os.Stdout) writers = append(writers, os.Stdout)