File tree Expand file tree Collapse file tree 2 files changed +6
-14
lines changed
Expand file tree Collapse file tree 2 files changed +6
-14
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import (
1212 "time"
1313
1414 "github.com/NVIDIA/go-nvml/pkg/nvml"
15+ "github.com/coroot/coroot-node-agent/flags"
1516 "github.com/coroot/coroot-node-agent/proc"
1617 "github.com/prometheus/client_golang/prometheus"
1718 "k8s.io/klog/v2"
@@ -87,22 +88,13 @@ type ProcessUsageSample struct {
8788 MemoryPercent uint32
8889}
8990
90- // NewDisabledCollector returns a collector that does not initialize NVML
91- // and collects no GPU metrics. Use this when GPU monitoring is disabled.
92- func NewDisabledCollector () * Collector {
93- return & Collector {
94- ProcessUsageSampleCh : nil ,
95- }
96- }
97-
98- func NewCollector (isDisabled bool ) (* Collector , error ) {
99- if isDisabled {
100- return NewDisabledCollector (), nil
101- }
91+ func NewCollector () (* Collector , error ) {
10292 c := & Collector {
10393 ProcessUsageSampleCh : make (chan ProcessUsageSample , 100 ),
10494 }
105-
95+ if * flags .DisableGPUMonitoring {
96+ return c , nil
97+ }
10698 libPath , err := findNvidiaMLLib ()
10799 if err != nil {
108100 klog .Infoln (err )
Original file line number Diff line number Diff line change @@ -143,7 +143,7 @@ func main() {
143143 klog .Exitln (err )
144144 }
145145
146- gpuCollector , err := gpu .NewCollector (* flags . DisableGPUMonitoring )
146+ gpuCollector , err := gpu .NewCollector ()
147147 if err != nil {
148148 klog .Warningln ("failed to initialize GPU collector:" , err )
149149 }
You can’t perform that action at this time.
0 commit comments