Skip to content

Commit 836ca2e

Browse files
authored
Merge pull request vpenso#50 from vpenso/gpus_acct
Enable GPUs accounting only via cmd line option (see vpenso#45)
2 parents b50fdb7 + b94df45 commit 836ca2e

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(NewNodeCollector()) // from node.go
3332
prometheus.MustRegister(NewPartitionsCollector()) // from partitions.go
@@ -42,8 +41,19 @@ var listenAddress = flag.String(
4241
":8080",
4342
"The address to listen on for HTTP requests.")
4443

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

0 commit comments

Comments
 (0)