Made the removal of non numeric values more robust.
This commit is contained in:
parent
b7d5827374
commit
e69c565871
@ -45,6 +45,11 @@ func metrics(response http.ResponseWriter, request *http.Request) {
|
||||
name := fmt.Sprintf("%s[%s]", row[0], row[1])
|
||||
for idx, value := range row[2:] {
|
||||
metric := strings.Replace(metricList[idx], ".", "_", -1)
|
||||
// Non numerical values like [N/A] wil break prometeus when a number is expected.
|
||||
_, err := strconv.Atoi(value)
|
||||
if err != nil {
|
||||
value = "-1"
|
||||
}
|
||||
result = fmt.Sprintf(
|
||||
"%s%s{gpu=\"%s\"} %s\n", result,
|
||||
metric, name, value)
|
||||
@ -54,7 +59,6 @@ func metrics(response http.ResponseWriter, request *http.Request) {
|
||||
deviceCount, err = strconv.Atoi(max_id)
|
||||
result = fmt.Sprintf(
|
||||
"%sdeviceCount %d\n", result, deviceCount+1)
|
||||
result = strings.Replace(result, "[Not Supported]", "-1", -1)
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user