From d179b86ac22b6afaad0fd7cdeb36a08ea0e4eac0 Mon Sep 17 00:00:00 2001 From: Grzegorz Bialas Date: Fri, 3 Jan 2025 14:28:30 +0100 Subject: [PATCH 1/2] add logout --- collector/redfish_collector.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/collector/redfish_collector.go b/collector/redfish_collector.go index 0dc5f9c..a64463e 100755 --- a/collector/redfish_collector.go +++ b/collector/redfish_collector.go @@ -99,6 +99,8 @@ func (r *RedfishCollector) Collect(ch chan<- prometheus.Metric) { ch <- r.redfishUp ch <- prometheus.MustNewConstMetric(totalScrapeDurationDesc, prometheus.GaugeValue, time.Since(scrapeTime).Seconds()) + defer r.redfishClient.Logout() + log.Info("Loging out") } func newRedfishClient(host string, username string, password string) (*gofish.APIClient, error) { From a508e052b970f14e3e0924b687201d4173465a6a Mon Sep 17 00:00:00 2001 From: Grzegorz Bialas Date: Fri, 10 Jan 2025 15:09:49 +0100 Subject: [PATCH 2/2] add if to logout --- collector/redfish_collector.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/collector/redfish_collector.go b/collector/redfish_collector.go index a64463e..bf8fb84 100755 --- a/collector/redfish_collector.go +++ b/collector/redfish_collector.go @@ -99,8 +99,12 @@ func (r *RedfishCollector) Collect(ch chan<- prometheus.Metric) { ch <- r.redfishUp ch <- prometheus.MustNewConstMetric(totalScrapeDurationDesc, prometheus.GaugeValue, time.Since(scrapeTime).Seconds()) - defer r.redfishClient.Logout() - log.Info("Loging out") + if r.redfishClient == nil { + + } else { + defer r.redfishClient.Logout() + log.Info("Loging out") + } } func newRedfishClient(host string, username string, password string) (*gofish.APIClient, error) {