diff --git a/.gitignore b/.gitignore index 5137776..70942a3 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,4 @@ tmp* coverage.html coverage.out .DS_Store +dist diff --git a/.goreleaser.yaml b/.goreleaser.yaml index e7d72f2..c0590f8 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -2,11 +2,17 @@ # # SPDX-License-Identifier: Apache-2.0 +version: 2 builds: - - - goos: + - goos: - linux goarch: - amd64 - arm - arm64 + +archives: + - name_template: '{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}' + files: + - src: ./exporter/templates/* + dst: templates diff --git a/README.md b/README.md index f0854c9..6d197c4 100644 --- a/README.md +++ b/README.md @@ -147,12 +147,13 @@ $ curl localhost:9092/metrics | grep "# HELP" ### Exporter Env Var Docs Env vars can be sepcified in a `.env` file, while using the `just` -| Var | Default Value | Purpose | -|---------------|---------------|-----------------------------------------------------------------------------| -| POLL_LIMIT | 10 | # of seconds to wait before polling slurmctl again (client-side throttling) | -| LOGLEVEL | info | Log Level: debug, info, warn, error | -| CLI_TIMEOUT | 10. | # seconds before the exporter terminates command. | +| Var | Default Value | Purpose | +|-----------------|---------------|-----------------------------------------------------------------------------| +| POLL_LIMIT | 10 | # of seconds to wait before polling slurmctl again (client-side throttling) | +| LOGLEVEL | info | Log Level: debug, info, warn, error | +| CLI_TIMEOUT | 10. | # seconds before the exporter terminates command. | +| TRACE_ROOT_PATH | "cwd" | path to ./templates directory where html files are located | ### Future work -Add scheduler info, slurmrestd support, package binary into apt, rpm packages, and docker +slurmrestd support diff --git a/exporter/trace.go b/exporter/trace.go index 642acaa..227b8b3 100644 --- a/exporter/trace.go +++ b/exporter/trace.go @@ -11,6 +11,7 @@ import ( "io/fs" "log" "net/http" + "os" "path/filepath" "sync" "text/template" @@ -106,8 +107,13 @@ type TraceCollector struct { func NewTraceCollector(config *Config) *TraceCollector { traceConfig := config.TraceConf + templateRootDir := "." + // path to look for the /templates directory. Defaults to cwd + if path, ok := os.LookupEnv("TRACE_ROOT_PATH"); ok { + templateRootDir = path + } traceDir := "" - err := filepath.WalkDir(".", func(path string, d fs.DirEntry, err error) error { + err := filepath.WalkDir(templateRootDir, func(path string, d fs.DirEntry, err error) error { if err == nil && d.IsDir() && d.Name() == templateDirName { traceDir = path return nil