Skip to content

Commit

Permalink
Merge pull request #50 from vpenso/gpus_acct
Browse files Browse the repository at this point in the history
Enable GPUs accounting only via cmd line option (see #45)
  • Loading branch information
mtds authored Apr 16, 2021
2 parents b50fdb7 + b94df45 commit 836ca2e
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ func init() {
// Metrics have to be registered to be exposed
prometheus.MustRegister(NewAccountsCollector()) // from accounts.go
prometheus.MustRegister(NewCPUsCollector()) // from cpus.go
prometheus.MustRegister(NewGPUsCollector()) // from gpus.go
prometheus.MustRegister(NewNodesCollector()) // from nodes.go
prometheus.MustRegister(NewNodeCollector()) // from node.go
prometheus.MustRegister(NewPartitionsCollector()) // from partitions.go
Expand All @@ -42,8 +41,19 @@ var listenAddress = flag.String(
":8080",
"The address to listen on for HTTP requests.")

var gpuAcct = flag.Bool(
"gpus-acct",
false,
"Enable GPUs accounting")

func main() {
flag.Parse()

// Turn on GPUs accounting only if the corresponding command line option is set to true.
if *gpuAcct {
prometheus.MustRegister(NewGPUsCollector()) // from gpus.go
}

// The Handler function provides a default handler to expose metrics
// via an HTTP server. "/metrics" is the usual endpoint for that.
log.Infof("Starting Server: %s", *listenAddress)
Expand Down

0 comments on commit 836ca2e

Please sign in to comment.