@@ -10,6 +10,7 @@ import (
10
10
"github.com/spf13/cobra"
11
11
"net/http"
12
12
"net/url"
13
+ "strings"
13
14
)
14
15
15
16
// To store the CLI parameters
@@ -64,7 +65,6 @@ var pipelineCmd = &cobra.Command{
64
65
Run : func (cmd * cobra.Command , args []string ) {
65
66
var (
66
67
output string
67
- summary string
68
68
rc int
69
69
pp logstash.Pipeline
70
70
thresholds PipelineThreshold
@@ -102,19 +102,21 @@ var pipelineCmd = &cobra.Command{
102
102
states := make ([]int , 0 , len (pp .Pipelines ))
103
103
104
104
// Check status for each pipeline
105
+ var summary strings.Builder
106
+
105
107
for name , pipe := range pp .Pipelines {
106
108
inflightEvents := pipe .Events .In - pipe .Events .Out
107
109
108
- summary += "\n \\ _"
110
+ summary . WriteString ( "\n \\ _" )
109
111
if thresholds .inflightEventsCrit .DoesViolate (float64 (inflightEvents )) {
110
112
states = append (states , check .Critical )
111
- summary += fmt .Sprintf ("[CRITICAL] inflight_events_%s:%d;" , name , inflightEvents )
113
+ summary . WriteString ( fmt .Sprintf ("[CRITICAL] inflight_events_%s:%d;" , name , inflightEvents ) )
112
114
} else if thresholds .inflightEventsWarn .DoesViolate (float64 (inflightEvents )) {
113
115
states = append (states , check .Warning )
114
- summary += fmt .Sprintf ("[WARNING] inflight_events_%s:%d;" , name , inflightEvents )
116
+ summary . WriteString ( fmt .Sprintf ("[WARNING] inflight_events_%s:%d;" , name , inflightEvents ) )
115
117
} else {
116
118
states = append (states , check .OK )
117
- summary += fmt .Sprintf ("[OK] inflight_events_%s:%d;" , name , inflightEvents )
119
+ summary . WriteString ( fmt .Sprintf ("[OK] inflight_events_%s:%d;" , name , inflightEvents ) )
118
120
}
119
121
120
122
// Generate perfdata for each event
@@ -155,7 +157,7 @@ var pipelineCmd = &cobra.Command{
155
157
output = "Inflight events status unknown"
156
158
}
157
159
158
- check .ExitRaw (rc , output , summary , "|" , perfList .String ())
160
+ check .ExitRaw (rc , output , summary . String () , "|" , perfList .String ())
159
161
},
160
162
}
161
163
0 commit comments