@@ -95,12 +95,14 @@ func main() {
95
95
var flagTimeout int
96
96
var flagVerbose bool
97
97
var flagInsecure bool
98
+ var flagFloatround int
98
99
99
100
flag .StringVar (& flagURL , "u" , "" , "NSCLient++ URL, for example https://10.1.2.3:8443." )
100
101
flag .StringVar (& flagPassword , "p" , "" , "NSClient++ webserver password." )
101
102
flag .IntVar (& flagTimeout , "t" , 10 , "Connection timeout in seconds, defaults to 10." )
102
103
flag .BoolVar (& flagVerbose , "v" , false , "Enable verbose output." )
103
104
flag .BoolVar (& flagInsecure , "k" , false , "Insecure mode - skip TLS verification." )
105
+ flag .IntVar (& flagFloatround , "f" , - 1 , "Round performance data float values to this number of digits." )
104
106
105
107
ReturncodeMap := map [string ]int {
106
108
"OK" : 0 ,
@@ -232,24 +234,24 @@ func main() {
232
234
// REFERENCE 'label'=value[UOM];[warn];[crit];[min];[max]
233
235
if p .FloatValue != nil {
234
236
if p .FloatValue .Value != nil {
235
- val = strconv .FormatFloat (* (p .FloatValue .Value ), 'f' , - 1 , 64 )
237
+ val = strconv .FormatFloat (* (p .FloatValue .Value ), 'f' , flagFloatround , 64 )
236
238
} else {
237
239
continue
238
240
}
239
241
if p .FloatValue .Unit != nil {
240
242
uni = (* (p .FloatValue .Unit ))
241
243
}
242
244
if p .FloatValue .Warning != nil {
243
- war = strconv .FormatFloat (* (p .FloatValue .Warning ), 'f' , - 1 , 64 )
245
+ war = strconv .FormatFloat (* (p .FloatValue .Warning ), 'f' , flagFloatround , 64 )
244
246
}
245
247
if p .FloatValue .Critical != nil {
246
- cri = strconv .FormatFloat (* (p .FloatValue .Critical ), 'f' , - 1 , 64 )
248
+ cri = strconv .FormatFloat (* (p .FloatValue .Critical ), 'f' , flagFloatround , 64 )
247
249
}
248
250
if p .FloatValue .Minimum != nil {
249
- min = strconv .FormatFloat (* (p .FloatValue .Minimum ), 'f' , - 1 , 64 )
251
+ min = strconv .FormatFloat (* (p .FloatValue .Minimum ), 'f' , flagFloatround , 64 )
250
252
}
251
253
if p .FloatValue .Maximum != nil {
252
- max = strconv .FormatFloat (* (p .FloatValue .Maximum ), 'f' , - 1 , 64 )
254
+ max = strconv .FormatFloat (* (p .FloatValue .Maximum ), 'f' , flagFloatround , 64 )
253
255
}
254
256
}
255
257
if p .IntValue != nil {
0 commit comments