Skip to content

Commit 4440740

Browse files
committed
add new collector for fairshare data
1 parent ff97e67 commit 4440740

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

DEVELOPMENT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ go mod download
3030
Build the exporter:
3131

3232
```bash
33-
go build -o bin/prometheus-slurm-exporter {main,accounts,cpus,gpus,partitions,nodes,queue,scheduler,users}.go
33+
go build -o bin/prometheus-slurm-exporter {main,accounts,cpus,gpus,partitions,nodes,queue,scheduler,sshare,users}.go
3434
```
3535

3636
Run all tests included in `_test.go` files:

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ PROJECT_NAME = prometheus-slurm-exporter
22
ifndef GOPATH
33
GOPATH=$(shell pwd):/usr/share/gocode
44
endif
5-
GOFILES=accounts.go cpus.go gpus.go main.go nodes.go partitions.go queue.go scheduler.go users.go
5+
GOFILES=accounts.go cpus.go gpus.go main.go nodes.go partitions.go queue.go scheduler.go sshare.go users.go
66
GOBIN=bin/$(PROJECT_NAME)
77

88
build:

sshare.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/* Copyright 2021 Victor Penso
2+
3+
This program is free software: you can redistribute it and/or modify
4+
it under the terms of the GNU General Public License as published by
5+
the Free Software Foundation, either version 3 of the License, or
6+
(at your option) any later version.
7+
8+
This program is distributed in the hope that it will be useful,
9+
but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
GNU General Public License for more details.
12+
13+
You should have received a copy of the GNU General Public License
14+
along with this program. If not, see <http://www.gnu.org/licenses/>. */
15+
16+
package main
17+
18+
import (
19+
"io/ioutil"
20+
"os/exec"
21+
"log"
22+
)
23+
24+
func FairShareData() []byte {
25+
cmd := exec.Command("sshare", "-o account,fairshare")
26+
stdout, err := cmd.StdoutPipe()
27+
if err != nil {
28+
log.Fatal(err)
29+
}
30+
if err := cmd.Start(); err != nil {
31+
log.Fatal(err)
32+
}
33+
out, _ := ioutil.ReadAll(stdout)
34+
if err := cmd.Wait(); err != nil {
35+
log.Fatal(err)
36+
}
37+
return out
38+
}

0 commit comments

Comments
 (0)