]> arthur.barton.de Git - netdata.git/commitdiff
nice can be both user and system time - this means user and system cannot have differ...
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Sat, 9 Jul 2016 03:55:51 +0000 (06:55 +0300)
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Sat, 9 Jul 2016 03:55:51 +0000 (06:55 +0300)
src/apps_plugin.c

index a7eea6cdfe358ab6b3748913d536f71f825ecc50..8cd2ef122d4c04566076590a3882c1f510550dd0 100644 (file)
@@ -2234,66 +2234,56 @@ void normalize_data(struct target *root) {
                if(w->target || (!w->processes && !w->exposed)) continue;
 
                utime   += w->utime;
-               cutime  += w->cutime;
                stime   += w->stime;
+               cutime  += w->cutime;
                cstime  += w->cstime;
+
                minflt  += w->minflt;
-               cminflt += w->cminflt;
                majflt  += w->majflt;
+               cminflt += w->cminflt;
                cmajflt += w->cmajflt;
        }
 
-       if(global_utime && utime) {
-               if(global_utime > utime + cutime) {
-                       // everything we collected is short
+       if((global_utime || global_stime) && (utime || stime)) {
+               if(global_utime + global_stime > utime + cutime + stime + cstime) {
+                       // everything we collected fits
+                       utime_fix_ratio  =
+                       stime_fix_ratio  =
                        cutime_fix_ratio =
-                       utime_fix_ratio = (double)global_utime / (double)(utime + cutime);
-               }
-               else if(global_utime > utime) {
-                       // cutime seems unrealistic
-                       cutime_fix_ratio = (double)(global_utime - utime) / (double)cutime;
-                       utime_fix_ratio  = 1.0;
+                       cstime_fix_ratio = 1.0; //(double)(global_utime + global_stime) / (double)(utime + cutime + stime + cstime);
                }
-               else {
-                       // even utime is unrealistic
-                       cutime_fix_ratio = 0.0;
-                       utime_fix_ratio = (double)global_utime / (double)utime;
-               }
-       }
-       else {
-               cutime_fix_ratio = 0.0;
-               utime_fix_ratio = 0.0;
-       }
-
-       if(utime_fix_ratio > 1.0) utime_fix_ratio = 1.0;
-       if(cutime_fix_ratio > 1.0) cutime_fix_ratio = 1.0;
-       // if(utime_fix_ratio < 0.0) utime_fix_ratio = 0.0;
-       // if(cutime_fix_ratio < 0.0) cutime_fix_ratio = 0.0;
-
-       if(global_stime && stime) {
-               if(global_stime > stime + cstime) {
-                       // everything we collected is short
-                       cstime_fix_ratio =
-                       stime_fix_ratio = (double)global_stime / (double)(stime + cstime);
-               }
-               else if(global_stime > stime) {
-                       // cstime seems unrealistic
-                       cstime_fix_ratio = (double)(global_stime - stime) / (double)cstime;
+               else if(global_utime + global_stime > utime + stime) {
+                       // childrens resources are too high
+                       // lower only the children resources
+                       utime_fix_ratio  =
                        stime_fix_ratio  = 1.0;
+                       cutime_fix_ratio =
+                       cstime_fix_ratio = (double)((global_utime + global_stime) - (utime + stime)) / (double)(cutime + cstime);
                }
                else {
-                       // even stime is unrealistic
+                       // even running processes are unrealistic
+                       // zero the children resources
+                       // lower the running processes resources
+                       utime_fix_ratio  =
+                       stime_fix_ratio  = (double)(global_utime + global_stime) / (double)(utime + stime);
+                       cutime_fix_ratio =
                        cstime_fix_ratio = 0.0;
-                       stime_fix_ratio = (double)global_stime / (double)stime;
                }
        }
        else {
+               utime_fix_ratio  =
+               stime_fix_ratio  =
+               cutime_fix_ratio =
                cstime_fix_ratio = 0.0;
-               stime_fix_ratio = 0.0;
        }
 
+       if(utime_fix_ratio  > 1.0) utime_fix_ratio  = 1.0;
+       if(cutime_fix_ratio > 1.0) cutime_fix_ratio = 1.0;
        if(stime_fix_ratio  > 1.0) stime_fix_ratio  = 1.0;
        if(cstime_fix_ratio > 1.0) cstime_fix_ratio = 1.0;
+
+       // if(utime_fix_ratio  < 0.0) utime_fix_ratio  = 0.0;
+       // if(cutime_fix_ratio < 0.0) cutime_fix_ratio = 0.0;
        // if(stime_fix_ratio  < 0.0) stime_fix_ratio  = 0.0;
        // if(cstime_fix_ratio < 0.0) cstime_fix_ratio = 0.0;