Skip to content

Commit

Permalink
Resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
mtds committed Mar 8, 2022
2 parents c27c1db + 3c868b1 commit 3b3f2da
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 35 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
bin/
go/
*.snap
33 changes: 12 additions & 21 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Development

Setup the development environment on a node with access to the Slurm user
command-line interface, in particular with the `sinfo`, `squeue`, and `sdiag`
commands.

### Install Go from source
## Install Go from source

```bash
export VERSION=1.15 OS=linux ARCH=amd64
Expand All @@ -13,51 +15,40 @@ export PATH=$PWD/go/bin:$PATH

_Alternatively install Go using the packaging system of your Linux distribution._

Use Git to clone the source code of the exporter, and download all Go dependency
modules:
## Clone this repository and build

Use Git to clone the source code of the exporter, run all the tests and build the binary:

```bash
# clone the source code
git clone https://github.com/vpenso/prometheus-slurm-exporter.git
cd prometheus-slurm-exporter
# download dependencies
export GOPATH=$PWD/go/modules
go mod download
```

### Build

Build the exporter:

```bash
go build -o bin/prometheus-slurm-exporter {main,accounts,cpus,gpus,partitions,node,nodes,queue,scheduler,sshare,users}.go
make
```

Run all tests included in `_test.go` files:
To just run the tests:

```bash
go test -v *.go
make test
```

Start the exporter (foreground), and query all metrics:

```bash
bin/prometheus-slurm-exporter
./bin/prometheus-slurm-exporter
```

If you wish to run the exporter on a different port, or the default port (8080) is already in use, run with the following argument:

```bash
bin/prometheus-slurm-exporter --listen-address="0.0.0.0:<port>"
./bin/prometheus-slurm-exporter --listen-address="0.0.0.0:<port>"
...

# query all metrics (default port)
curl http://localhost:8080/metrics
```

### Development

References:
## References

* [GOlang Package Documentation](https://godoc.org/github.com/prometheus/client_golang/prometheus)
* [Metric Types](https://prometheus.io/docs/concepts/metric_types/)
Expand Down
36 changes: 22 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
PROJECT_NAME = prometheus-slurm-exporter
ifndef GOPATH
GOPATH=$(shell pwd):/usr/share/gocode
endif
GOFILES=accounts.go cpus.go gpus.go main.go node.go nodes.go partitions.go queue.go scheduler.go sshare.go users.go
GOBIN=bin/$(PROJECT_NAME)
SHELL := $(shell which bash) -eu -o pipefail

build:
mkdir -p $(shell pwd)/bin
@echo "Build $(GOFILES) to $(GOBIN)"
@GOPATH=$(GOPATH) go build -o $(GOBIN) $(GOFILES)
GOPATH := $(shell pwd)/go/modules
GOBIN := bin/$(PROJECT_NAME)
GOFILES := $(shell ls *.go)

test:
@GOPATH=$(GOPATH) go test -v *.go
.PHONY: build
build: test $(GOBIN)

run:
@GOPATH=$(GOPATH) go run $(GOFILES)
$(GOBIN): go/modules/pkg/mod $(GOFILES)
mkdir -p bin
@echo "Building $(GOBIN)"
go build -v -o $(GOBIN)

go/modules/pkg/mod: go.mod
go mod download

.PHONY: test
test: go/modules/pkg/mod $(GOFILES)
go test -v

run: $(GOBIN)
$(GOBIN)

clean:
if [ -f ${GOBIN} ] ; then rm -f ${GOBIN} ; fi
go clean -modcache
rm -fr bin/ go/

0 comments on commit 3b3f2da

Please sign in to comment.