Skip to content

Commit

Permalink
assignments vpenso#82
Browse files Browse the repository at this point in the history
  • Loading branch information
Pim Witlox committed Sep 9, 2022
1 parent 2538d51 commit 4617f54
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions node.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,11 @@ func ParseNodeMetrics(input []byte) map[string]*NodeMetrics {
nodeName := node[0]

if len(node) >= 5 {
nodes[nodeName].nodeStatus = node[4]
nodeStatus := node[4]
nodes[nodeName].nodeStatus = nodeStatus
} else {
nodes[nodeName].nodeStatus = "unknown"
nodeStatus := "unknown"
nodes[nodeName].nodeStatus = nodeStatus
}

nodes[nodeName] = &NodeMetrics{0, 0, 0, 0, 0, 0, ""}
Expand All @@ -73,8 +75,10 @@ func ParseNodeMetrics(input []byte) map[string]*NodeMetrics {
nodes[nodeName].memAlloc = memAlloc
nodes[nodeName].memTotal = memTotal
} else {
nodes[nodeName].memAlloc = 0
nodes[nodeName].memTotal = 0
memAlloc := uint64(0)
memTotal := uint64(0)
nodes[nodeName].memAlloc = memAlloc
nodes[nodeName].memTotal = memTotal
}

if len(node) >= 4 {
Expand All @@ -83,15 +87,19 @@ func ParseNodeMetrics(input []byte) map[string]*NodeMetrics {
cpuIdle, _ := strconv.ParseUint(cpuInfo[1], 10, 64)
cpuOther, _ := strconv.ParseUint(cpuInfo[2], 10, 64)
cpuTotal, _ := strconv.ParseUint(cpuInfo[3], 10, 64)
nodes[nodeName].cpuAlloc = cpuAlloc
nodes[nodeName].cpuIdle = cpuIdle
nodes[nodeName].cpuAlloc = cpuAlloc
nodes[nodeName].cpuIdle = cpuIdle
nodes[nodeName].cpuOther = cpuOther
nodes[nodeName].cpuTotal = cpuTotal
} else {
nodes[nodeName].cpuAlloc = 0
nodes[nodeName].cpuIdle = 0
nodes[nodeName].cpuOther = 0
nodes[nodeName].cpuTotal = 0
cpuAlloc := uint64(0)
cpuIdle := uint64(0)
cpuOther := uint64(0)
cpuTotal := uint64(0)
nodes[nodeName].cpuAlloc = cpuAlloc
nodes[nodeName].cpuIdle = cpuIdle
nodes[nodeName].cpuOther = cpuOther
nodes[nodeName].cpuTotal = cpuTotal
}
}

Expand Down

0 comments on commit 4617f54

Please sign in to comment.