This repository has been archived by the owner on Mar 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move collection funcs to a separate file + minor (#224)
- Loading branch information
Showing
8 changed files
with
66 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package wmi | ||
|
||
import "github.com/netdata/go.d.plugin/pkg/prometheus" | ||
|
||
const ( | ||
metricCollectorDuration = "wmi_exporter_collector_duration_seconds" | ||
metricCollectorSuccess = "wmi_exporter_collector_success" | ||
) | ||
|
||
func collectCollection(mx *metrics, pms prometheus.Metrics) { | ||
mx.Collectors = &collectors{} | ||
collectCollectionDuration(mx, pms) | ||
collectCollectionSuccess(mx, pms) | ||
} | ||
|
||
func collectCollectionDuration(mx *metrics, pms prometheus.Metrics) { | ||
cr := newCollector("") | ||
for _, pm := range pms.FindByName(metricCollectorDuration) { | ||
name := pm.Labels.Get("collector") | ||
if name == "" { | ||
continue | ||
} | ||
if cr.ID != name { | ||
cr = mx.Collectors.get(name, true) | ||
} | ||
cr.Duration = pm.Value | ||
} | ||
} | ||
|
||
func collectCollectionSuccess(mx *metrics, pms prometheus.Metrics) { | ||
cr := newCollector("") | ||
for _, pm := range pms.FindByName(metricCollectorSuccess) { | ||
name := pm.Labels.Get("collector") | ||
if name == "" { | ||
continue | ||
} | ||
if cr.ID != name { | ||
cr = mx.Collectors.get(name, true) | ||
} | ||
cr.Success = pm.Value == 1 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters