Added deviceCount
Removed Unsupported messages as prometheus fails on that.
This commit is contained in:
parent
9e786b3456
commit
9c3d7cfd77
@ -8,6 +8,7 @@ import (
|
||||
"net/http"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@ -39,13 +40,21 @@ func metrics(response http.ResponseWriter, request *http.Request) {
|
||||
"utilization.memory", "memory.total", "memory.free", "memory.used", "eccerrorsaggregate.total", "eccuncorrectedvolatile.total"}
|
||||
|
||||
result := ""
|
||||
max_id := ""
|
||||
for _, row := range records {
|
||||
name := fmt.Sprintf("%s[%s]", row[0], row[1])
|
||||
for idx, value := range row[2:] {
|
||||
result = fmt.Sprintf(
|
||||
"%s%s{gpu=\"%s\"} %s\n", result,
|
||||
metricList[idx], name, value)
|
||||
max_id = row[1]
|
||||
}
|
||||
deviceCount := 0
|
||||
deviceCount, err = strconv.Atoi(max_id)
|
||||
result = fmt.Sprintf(
|
||||
"%sdeviceCount %d\n", result, deviceCount+1)
|
||||
result = strings.Replace(result, "[Not Supported]", "-1", -1)
|
||||
|
||||
}
|
||||
|
||||
fmt.Fprintf(response, strings.Replace(result, ".", "_", -1))
|
||||
|
Loading…
Reference in New Issue
Block a user