From b26ba8e89ef91dc8f526c6dfcb96a72ecd991a79 Mon Sep 17 00:00:00 2001 From: Lorenz Herzberger Date: Mon, 2 Sep 2024 10:12:21 +0200 Subject: [PATCH 1/3] fix: add nil check for dbus connection on error case Signed-off-by: Lorenz Herzberger --- system/unit.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/system/unit.go b/system/unit.go index 2f16711..df033e9 100644 --- a/system/unit.go +++ b/system/unit.go @@ -14,7 +14,9 @@ func CheckUnitActiveState(ctx context.Context, unit string) float64 { conn, err := dbus.NewWithContext(ctx) if err != nil { logger.Print(err) - conn.Close() + if conn != nil { + conn.Close() + } return 0 } defer conn.Close() From a694a9a2ed2dc48f7eb5dd68150b6baee948939d Mon Sep 17 00:00:00 2001 From: Lorenz Herzberger Date: Mon, 2 Sep 2024 10:47:46 +0200 Subject: [PATCH 2/3] chore: update planetmint dependency Signed-off-by: Lorenz Herzberger --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 21b90c8..9f64fb0 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,6 @@ go 1.21.5 require ( github.com/coreos/go-systemd/v22 v22.3.2 github.com/cosmos/cosmos-sdk v0.47.8 - github.com/planetmint/planetmint-go v0.11.0 github.com/prometheus/client_golang v1.14.0 github.com/rddl-network/elements-rpc v1.1.0 github.com/spf13/viper v1.16.0 @@ -89,6 +88,7 @@ require ( github.com/pelletier/go-toml/v2 v2.1.0 // indirect github.com/petermattis/goid v0.0.0-20230317030725-371a4b8eda08 // indirect github.com/pkg/errors v0.9.1 // indirect + github.com/planetmint/planetmint-go v0.11.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/prometheus/client_model v0.3.0 // indirect github.com/prometheus/common v0.42.0 // indirect diff --git a/go.sum b/go.sum index 8ce2557..d3fbdd6 100644 --- a/go.sum +++ b/go.sum @@ -345,8 +345,8 @@ github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/planetmint/planetmint-go v0.11.0 h1:d7G2mNl49f6zUCvAJNRWyXTdFLEdpTjslNY1TRMJDc4= -github.com/planetmint/planetmint-go v0.11.0/go.mod h1:hhLYp/3EAP4ruiMLY1hZIjIz/0lrfut1ZuhxKlEt7QM= +github.com/planetmint/planetmint-go v0.11.1 h1:9gxa2W4BZCFXfP5uclcmkOOFNCVkC23T7F25U8mFY0w= +github.com/planetmint/planetmint-go v0.11.1/go.mod h1:hhLYp/3EAP4ruiMLY1hZIjIz/0lrfut1ZuhxKlEt7QM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= From c6a97723f81efc69bcf7af5429d08dece7c1c14d Mon Sep 17 00:00:00 2001 From: Lorenz Herzberger Date: Mon, 2 Sep 2024 10:51:43 +0200 Subject: [PATCH 3/3] fix: linter error Signed-off-by: Lorenz Herzberger --- cmd/rddl-prometheus-exporter/gauges.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/rddl-prometheus-exporter/gauges.go b/cmd/rddl-prometheus-exporter/gauges.go index 8bca112..f849329 100644 --- a/cmd/rddl-prometheus-exporter/gauges.go +++ b/cmd/rddl-prometheus-exporter/gauges.go @@ -43,7 +43,7 @@ func registerGauges(ctx context.Context, logger *log.Logger, cfg *config.Config) for _, wallet := range wallets { wallet := strings.TrimSpace(wallet) sanitizedWallet := strings.ReplaceAll(wallet, "-", "_") - logger.Printf("registering gauge for wallet: " + wallet) + logger.Print("registering gauge for wallet: " + wallet) setGauge("balance_"+sanitizedWallet, "Bitcoin balance for network relevant wallet: "+wallet, "elementsd", "wallets", func() float64 { url := cfg.GetElementsURL(wallet) balance, err := elements.GetWalletBalance(url, wallet)