Skip to content

Commit b94df45

Browse files
committed
Enable GPUs accounting only via cmd line option (see vpenso#45)
1 parent 45f58f7 commit b94df45

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

main.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ func init() {
2727
// Metrics have to be registered to be exposed
2828
prometheus.MustRegister(NewAccountsCollector()) // from accounts.go
2929
prometheus.MustRegister(NewCPUsCollector()) // from cpus.go
30-
prometheus.MustRegister(NewGPUsCollector()) // from gpus.go
3130
prometheus.MustRegister(NewNodesCollector()) // from nodes.go
3231
prometheus.MustRegister(NewPartitionsCollector()) // from partitions.go
3332
prometheus.MustRegister(NewQueueCollector()) // from queue.go
@@ -41,8 +40,19 @@ var listenAddress = flag.String(
4140
":8080",
4241
"The address to listen on for HTTP requests.")
4342

43+
var gpuAcct = flag.Bool(
44+
"gpus-acct",
45+
false,
46+
"Enable GPUs accounting")
47+
4448
func main() {
4549
flag.Parse()
50+
51+
// Turn on GPUs accounting only if the corresponding command line option is set to true.
52+
if *gpuAcct {
53+
prometheus.MustRegister(NewGPUsCollector()) // from gpus.go
54+
}
55+
4656
// The Handler function provides a default handler to expose metrics
4757
// via an HTTP server. "/metrics" is the usual endpoint for that.
4858
log.Infof("Starting Server: %s", *listenAddress)

0 commit comments

Comments
 (0)