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

Add decimal point support #3

Open
ytooyama opened this issue Mar 28, 2018 · 0 comments
Open

Add decimal point support #3

ytooyama opened this issue Mar 28, 2018 · 0 comments

Comments

@ytooyama
Copy link

ytooyama commented Mar 28, 2018

--- nvidia_smi_exporter.go	2018-03-28 18:33:36.000000000 +0900
+++ edit-nvidia_smi_exporter.go	2018-03-28 17:56:25.000000000 +0900
@@ -13,12 +13,12 @@

 func metrics(response http.ResponseWriter, request *http.Request) {
     out, err := exec.Command(
         "nvidia-smi",
-        "--query-gpu=name,index,temperature.gpu,utilization.gpu,utilization.memory,memory.total,memory.free,memory.used",
+        "--query-gpu=name,index,temperature.gpu,utilization.gpu,utilization.memory,memory.total,memory.free,memory.used,power.draw",
         "--format=csv,noheader,nounits").Output()

     if err != nil {
@@ -37,19 +37,22 @@

     metricList := []string {
         "temperature.gpu", "utilization.gpu",
-        "utilization.memory", "memory.total", "memory.free", "memory.used"}
+        "utilization.memory", "memory.total", "memory.free", "memory.used", "power.draw" }

     result := ""
     for _, row := range records {
         name := fmt.Sprintf("%s[%s]", row[0], row[1])
         for idx, value := range row[2:] {
+            mydata := strings.Replace(metricList[idx], ".", "_", -1)
             result = fmt.Sprintf(
                 "%s%s{gpu=\"%s\"} %s\n", result,
-                metricList[idx], name, value)
+                //metricList[idx], name, value)
+                mydata, name, value)
         }
     }

-    fmt.Fprintf(response, strings.Replace(result, ".", "_", -1))
+    //fmt.Fprintf(response, strings.Replace(result, ".", "_", -1))
+    fmt.Fprintf(response, result)
 }

 func main() {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant