@@ -2,13 +2,14 @@ package cmd
22
33import (
44 "fmt"
5+ "strings"
6+ "time"
7+
58 "github.com/NETWAYS/go-check"
69 "github.com/NETWAYS/go-check/perfdata"
710 goresult "github.com/NETWAYS/go-check/result"
811 "github.com/prometheus/common/model"
912 "github.com/spf13/cobra"
10- "strings"
11- "time"
1213)
1314
1415type QueryConfig struct {
@@ -54,7 +55,7 @@ Note: Time range values e.G. 'go_memstats_alloc_bytes_total[0s]' only the latest
5455 | value_go_gc_duration_seconds_count_localhost:9090_prometheus=1599 value_go_gc_duration_seconds_count_node-exporter:9100_node-exporter=79610` ,
5556 PreRun : func (cmd * cobra.Command , args []string ) {
5657 if cliQueryConfig .Warning == "" || cliQueryConfig .Critical == "" {
57- check .ExitError (fmt .Errorf ("Please specify warning and critical thresholds" ))
58+ check .ExitError (fmt .Errorf ("please specify warning and critical thresholds" ))
5859 }
5960 },
6061 Run : func (cmd * cobra.Command , args []string ) {
@@ -89,26 +90,26 @@ Note: Time range values e.G. 'go_memstats_alloc_bytes_total[0s]' only the latest
8990 ctx , cancel := cliConfig .timeoutContext ()
9091 defer cancel ()
9192
92- result , warnings , err := c .Api .Query (ctx , cliQueryConfig .RawQuery , time .Now ())
93+ result , warnings , err := c .API .Query (ctx , cliQueryConfig .RawQuery , time .Now ())
9394
9495 if err != nil {
9596 if strings .Contains (err .Error (), "unmarshalerDecoder: unexpected value type \" string\" " ) {
96- err = fmt .Errorf ("String value results are not supported" )
97+ err = fmt .Errorf ("string value results are not supported" )
9798 }
9899 check .ExitError (err )
99100 }
100101
101102 switch result .Type () {
102103 default :
103- check .ExitError (fmt .Errorf ("None value results are not supported" ))
104+ check .ExitError (fmt .Errorf ("none value results are not supported" ))
104105 // Scalar - a simple numeric floating point value
105106 case model .ValScalar :
106- check .ExitError (fmt .Errorf ("Scalar value results are not supported" ))
107+ check .ExitError (fmt .Errorf ("scalar value results are not supported" ))
107108 case model .ValNone :
108- check .ExitError (fmt .Errorf ("None value results are not supported" ))
109+ check .ExitError (fmt .Errorf ("none value results are not supported" ))
109110 case model .ValString :
110111 // String - a simple string value; currently unused
111- check .ExitError (fmt .Errorf ("String value results are not supported" ))
112+ check .ExitError (fmt .Errorf ("string value results are not supported" ))
112113 case model .ValVector :
113114 // Instant vector - a set of time series containing a single sample for each time series, all sharing the same timestamp
114115 vectorVal := result .(model.Vector )
@@ -175,9 +176,7 @@ Note: Time range values e.G. 'go_memstats_alloc_bytes_total[0s]' only the latest
175176 states = mStates
176177 }
177178
178- // The worst state of all metrics determines the final return state. Example:
179- // OK, OK, OK > OK
180- // Critical, OK, OK > Critical
179+ // The worst state of all metrics determines the final return state.
181180 worstState := goresult .WorstState (states ... )
182181 if worstState == check .OK {
183182 summary .WriteString (fmt .Sprintf ("%d Metrics OK" , metricsCounter ))
0 commit comments