Added powerdraw

This commit is contained in:
Egon Rijpkema 2019-03-12 17:00:03 +01:00
parent 9c3d7cfd77
commit b7d5827374

View File

@ -18,7 +18,7 @@ import (
func metrics(response http.ResponseWriter, request *http.Request) { func metrics(response http.ResponseWriter, request *http.Request) {
out, err := exec.Command( out, err := exec.Command(
"nvidia-smi", "nvidia-smi",
"--query-gpu=name,index,temperature.gpu,utilization.gpu,utilization.memory,memory.total,memory.free,memory.used,ecc.errors.uncorrected.aggregate.total,ecc.errors.uncorrected.volatile.total", "--query-gpu=name,index,temperature.gpu,utilization.gpu,utilization.memory,memory.total,memory.free,memory.used,ecc.errors.uncorrected.aggregate.total,ecc.errors.uncorrected.volatile.total,power.draw",
"--format=csv,noheader,nounits").Output() "--format=csv,noheader,nounits").Output()
if err != nil { if err != nil {
@ -37,16 +37,17 @@ func metrics(response http.ResponseWriter, request *http.Request) {
metricList := []string{ metricList := []string{
"temperature.gpu", "utilization.gpu", "temperature.gpu", "utilization.gpu",
"utilization.memory", "memory.total", "memory.free", "memory.used", "eccerrorsaggregate.total", "eccuncorrectedvolatile.total"} "utilization.memory", "memory.total", "memory.free", "memory.used", "eccerrorsaggregate.total", "eccuncorrectedvolatile.total", "power.draw"}
result := "" result := ""
max_id := "" max_id := ""
for _, row := range records { for _, row := range records {
name := fmt.Sprintf("%s[%s]", row[0], row[1]) name := fmt.Sprintf("%s[%s]", row[0], row[1])
for idx, value := range row[2:] { for idx, value := range row[2:] {
metric := strings.Replace(metricList[idx], ".", "_", -1)
result = fmt.Sprintf( result = fmt.Sprintf(
"%s%s{gpu=\"%s\"} %s\n", result, "%s%s{gpu=\"%s\"} %s\n", result,
metricList[idx], name, value) metric, name, value)
max_id = row[1] max_id = row[1]
} }
deviceCount := 0 deviceCount := 0
@ -57,7 +58,7 @@ func metrics(response http.ResponseWriter, request *http.Request) {
} }
fmt.Fprintf(response, strings.Replace(result, ".", "_", -1)) fmt.Fprintf(response, result)
} }
func main() { func main() {