From 2735985e83dc916639740f821f77789a9b9feabe Mon Sep 17 00:00:00 2001 From: Kenshi Muto Date: Thu, 21 Dec 2023 18:24:59 +0900 Subject: [PATCH] use smarter err --- checkmackerelmetric/checkmackerelmetric.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/checkmackerelmetric/checkmackerelmetric.go b/checkmackerelmetric/checkmackerelmetric.go index 4c419af..81f87f2 100644 --- a/checkmackerelmetric/checkmackerelmetric.go +++ b/checkmackerelmetric/checkmackerelmetric.go @@ -91,12 +91,12 @@ func (opts *mackerelMetricOpts) run() *checkers.Checker { newpath := filepath.Join(config.DefaultConfig.Conffile, "../../../mackerel-agent.conf") conf, err = config.LoadConfig(newpath) if err != nil { - return checkers.Unknown(fmt.Sprintf("%v", err)) + return checkers.Unknown(err.Error()) } conf.Conffile = newpath conf.Root = filepath.Dir(newpath) } else { - return checkers.Unknown(fmt.Sprintf("%v", err)) + return checkers.Unknown(err.Error()) } } apibase := conf.Apibase @@ -113,7 +113,7 @@ func (opts *mackerelMetricOpts) run() *checkers.Checker { client, err := mackerel.NewClientWithOptions(apikey, apibase, false) if err != nil { - return checkers.Unknown(fmt.Sprintf("%v", err)) + return checkers.Unknown(err.Error()) } return checkMetric(client, opts, criticalFrom, warningFrom, to) @@ -125,7 +125,7 @@ func checkMetric(client *mackerel.Client, opts *mackerelMetricOpts, criticalFrom // CRITICAL check metricValue, err := fetchMetricValues(client, opts.Host, opts.Service, opts.Metric, criticalFrom, to) if err != nil { - return checkers.Unknown(fmt.Sprintf("%v", err)) + return checkers.Unknown(err.Error()) } if len(metricValue) == 0 { return checkers.Critical(fmt.Sprintf("no metric for %s has been posted since at least %d minutes ago", opts.Metric, opts.Critical))