Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update node.go #107

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions node.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"sort"
"strconv"
"strings"
"regexp"

"github.com/prometheus/client_golang/prometheus"
)
Expand Down Expand Up @@ -82,12 +83,17 @@ func ParseNodeMetrics(input []byte) map[string]*NodeMetrics {
// NodeData executes the sinfo command to get data for each node
// It returns the output of the sinfo command
func NodeData() []byte {
cmd := exec.Command("sinfo", "-h", "-N", "-O", "NodeList,AllocMem,Memory,CPUsState,StateLong")
// we make sure the long node names will not be truncated and will print nicely (here is 30 chars limit, if You need more -> change 30 to something bigger)
cmd := exec.Command("sinfo", "-h", "-N", "-O", "NodeList:30,AllocMem,Memory,CPUsState,StateLong")
out, err := cmd.Output()
if err != nil {
log.Fatal(err)
}
return out

// let's do a regexp and then crush all spaces into single one to ease the parsing process
re := regexp.MustCompile(`\s+`)
cleanedOutput := re.ReplaceAllString(string(out), " ")
return []byte(cleanedOutput)
}

type NodeCollector struct {
Expand Down