From 659357c1d0e893f7e83b2e03464e6dc419d0f339 Mon Sep 17 00:00:00 2001 From: Cameron Sparr Date: Fri, 19 Feb 2016 11:56:33 -0700 Subject: [PATCH] Provide default args: percpu=true and totalcpu=true for cpu plugin Also if outputs.file is empty, write to stdout closes #720 --- plugins/inputs/system/cpu.go | 6 +++++- plugins/outputs/file/file.go | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/plugins/inputs/system/cpu.go b/plugins/inputs/system/cpu.go index bef2a28f4..333339458 100644 --- a/plugins/inputs/system/cpu.go +++ b/plugins/inputs/system/cpu.go @@ -113,6 +113,10 @@ func totalCpuTime(t cpu.CPUTimesStat) float64 { func init() { inputs.Add("cpu", func() telegraf.Input { - return &CPUStats{ps: &systemPS{}} + return &CPUStats{ + PerCPU: true, + TotalCPU: true, + ps: &systemPS{}, + } }) } diff --git a/plugins/outputs/file/file.go b/plugins/outputs/file/file.go index e593e3cea..743c0f03f 100644 --- a/plugins/outputs/file/file.go +++ b/plugins/outputs/file/file.go @@ -36,6 +36,11 @@ func (f *File) SetSerializer(serializer serializers.Serializer) { func (f *File) Connect() error { writers := []io.Writer{} + + if len(f.Files) == 0 { + f.Files = []string{"stdout"} + } + for _, file := range f.Files { if file == "stdout" { writers = append(writers, os.Stdout)