virt plugin: Submit `ps_cputime' only when data exists
authorPavel Rochnyack <pavel2000@ngs.ru>
Thu, 25 Oct 2018 08:37:20 +0000 (15:37 +0700)
committerPavel Rochnyack <pavel2000@ngs.ru>
Thu, 25 Oct 2018 08:37:26 +0000 (15:37 +0700)
src/virt.c

index 21df2d6..e7f11fc 100644 (file)
@@ -511,8 +511,9 @@ static int get_pcpu_stats(virDomainPtr dom) {
       total_syst_cpu_time = param[i].value.ul;
   }
 
-  submit_derive2("ps_cputime", total_user_cpu_time, total_syst_cpu_time, dom,
-                 NULL);
+  if (total_user_cpu_time > 0 || total_syst_cpu_time > 0)
+    submit_derive2("ps_cputime", total_user_cpu_time, total_syst_cpu_time, dom,
+                   NULL);
 
   virTypedParamsClear(param, nparams);
   sfree(param);