From f285f601eec8b74cc2345f8050f4c364ef0d9cc1 Mon Sep 17 00:00:00 2001 From: Sebastien Baguet Date: Mon, 1 Sep 2025 11:33:28 +0200 Subject: [PATCH 1/3] fix: Support for maintenance & Unmounted drive --- main.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/main.go b/main.go index 5b3d57e..b81c3dc 100644 --- a/main.go +++ b/main.go @@ -604,6 +604,8 @@ func (e *Exporter) getDatastoreMetric(datastore Datastore, ch chan<- prometheus. if resp.StatusCode == 400 { // check if datastore is being deleted isBeingDeleted, err := regexp.MatchString("(?i)datastore is being deleted", string(body[:])) + isMaintenance, err := regexp.MatchString("offline maintenance mode", string(body[:])) + isUnmounted, err := regexp.MatchString("is not mounted", string(body[:])) if err != nil { return err } @@ -611,6 +613,14 @@ func (e *Exporter) getDatastoreMetric(datastore Datastore, ch chan<- prometheus. log.Printf("INFO: Datastore: %s is being deleted, Skip scrape datastore metric", datastore.Store) return nil } + if isMaintenance { + log.Printf("INFO: Datastore: %s is in maintenance mode, Skip scrape datastore metric", datastore.Store) + return nil + } + if isUnmounted { + log.Printf("INFO: Datastore: %s is unmounted, Skip scrape datastore metric", datastore.Store) + return nil + } } return fmt.Errorf("ERROR: --Status code %d returned from endpoint: %s", resp.StatusCode, e.endpoint) } From 99726fbff00249e9390e87754a08cd854e2f087c Mon Sep 17 00:00:00 2001 From: Sebastien Baguet Date: Thu, 11 Sep 2025 15:17:52 +0200 Subject: [PATCH 2/3] fix: linter errors --- main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index b81c3dc..b5e3110 100644 --- a/main.go +++ b/main.go @@ -604,8 +604,6 @@ func (e *Exporter) getDatastoreMetric(datastore Datastore, ch chan<- prometheus. if resp.StatusCode == 400 { // check if datastore is being deleted isBeingDeleted, err := regexp.MatchString("(?i)datastore is being deleted", string(body[:])) - isMaintenance, err := regexp.MatchString("offline maintenance mode", string(body[:])) - isUnmounted, err := regexp.MatchString("is not mounted", string(body[:])) if err != nil { return err } @@ -613,10 +611,12 @@ func (e *Exporter) getDatastoreMetric(datastore Datastore, ch chan<- prometheus. log.Printf("INFO: Datastore: %s is being deleted, Skip scrape datastore metric", datastore.Store) return nil } + isMaintenance, err := regexp.MatchString("(?i)offline maintenance mode", string(body[:])) if isMaintenance { log.Printf("INFO: Datastore: %s is in maintenance mode, Skip scrape datastore metric", datastore.Store) return nil } + isUnmounted, err := regexp.MatchString("(?i)is not mounted", string(body[:])) if isUnmounted { log.Printf("INFO: Datastore: %s is unmounted, Skip scrape datastore metric", datastore.Store) return nil From 91f6d7f7a68ec80da287437f001a442ba9a43217 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolo=20L=C3=BCscher?= Date: Mon, 3 Aug 2026 11:37:19 +0200 Subject: [PATCH 3/3] fix: check regexp errors in maintenance/unmounted datastore handling --- main.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/main.go b/main.go index b5e3110..60b1295 100644 --- a/main.go +++ b/main.go @@ -612,11 +612,17 @@ func (e *Exporter) getDatastoreMetric(datastore Datastore, ch chan<- prometheus. return nil } isMaintenance, err := regexp.MatchString("(?i)offline maintenance mode", string(body[:])) + if err != nil { + return err + } if isMaintenance { log.Printf("INFO: Datastore: %s is in maintenance mode, Skip scrape datastore metric", datastore.Store) return nil } isUnmounted, err := regexp.MatchString("(?i)is not mounted", string(body[:])) + if err != nil { + return err + } if isUnmounted { log.Printf("INFO: Datastore: %s is unmounted, Skip scrape datastore metric", datastore.Store) return nil