@cryptotaxi247 / netdata-1 / commits / 591b39e79

nice can be both user and system time - this means user and system cannot have different fix ratios

Costa Tsaousis (ktsaou) committed Jul 9, 2016 at 06:55 UTC 591b39e79ae34d094009686b6098d694cdab7869
1 file changed +29 -39
src/apps_plugin.c
+29 -39
@@ -2234,66 +2234,56 @@ void normalize_data(struct target *root) {
2234 if(w->target || (!w->processes && !w->exposed)) continue;
2235
2236 utime += w->utime;
2237 - cutime += w->cutime;
2237 stime += w->stime;
2238 + cutime += w->cutime;
2239 cstime += w->cstime;
2240 +
2241 minflt += w->minflt;
2241 - cminflt += w->cminflt;
2242 majflt += w->majflt;
2243 + cminflt += w->cminflt;
2244 cmajflt += w->cmajflt;
2245 }
2246
2246 - if(global_utime && utime) {
2247 - if(global_utime > utime + cutime) {
2248 - // everything we collected is short
2247 + if((global_utime || global_stime) && (utime || stime)) {
2248 + if(global_utime + global_stime > utime + cutime + stime + cstime) {
2249 + // everything we collected fits
2250 + utime_fix_ratio =
2251 + stime_fix_ratio =
2252 cutime_fix_ratio =
2250 - utime_fix_ratio = (double)global_utime / (double)(utime + cutime);
2251 - }
2252 - else if(global_utime > utime) {
2253 - // cutime seems unrealistic
2254 - cutime_fix_ratio = (double)(global_utime - utime) / (double)cutime;
2255 - utime_fix_ratio = 1.0;
2253 + cstime_fix_ratio = 1.0; //(double)(global_utime + global_stime) / (double)(utime + cutime + stime + cstime);
2254 }
2257 - else {
2258 - // even utime is unrealistic
2259 - cutime_fix_ratio = 0.0;
2260 - utime_fix_ratio = (double)global_utime / (double)utime;
2261 - }
2262 - }
2263 - else {
2264 - cutime_fix_ratio = 0.0;
2265 - utime_fix_ratio = 0.0;
2266 - }
2267 -
2268 - if(utime_fix_ratio > 1.0) utime_fix_ratio = 1.0;
2269 - if(cutime_fix_ratio > 1.0) cutime_fix_ratio = 1.0;
2270 - // if(utime_fix_ratio < 0.0) utime_fix_ratio = 0.0;
2271 - // if(cutime_fix_ratio < 0.0) cutime_fix_ratio = 0.0;
2272 -
2273 - if(global_stime && stime) {
2274 - if(global_stime > stime + cstime) {
2275 - // everything we collected is short
2276 - cstime_fix_ratio =
2277 - stime_fix_ratio = (double)global_stime / (double)(stime + cstime);
2278 - }
2279 - else if(global_stime > stime) {
2280 - // cstime seems unrealistic
2281 - cstime_fix_ratio = (double)(global_stime - stime) / (double)cstime;
2255 + else if(global_utime + global_stime > utime + stime) {
2256 + // childrens resources are too high
2257 + // lower only the children resources
2258 + utime_fix_ratio =
2259 stime_fix_ratio = 1.0;
2260 + cutime_fix_ratio =
2261 + cstime_fix_ratio = (double)((global_utime + global_stime) - (utime + stime)) / (double)(cutime + cstime);
2262 }
2263 else {
2285 - // even stime is unrealistic
2264 + // even running processes are unrealistic
2265 + // zero the children resources
2266 + // lower the running processes resources
2267 + utime_fix_ratio =
2268 + stime_fix_ratio = (double)(global_utime + global_stime) / (double)(utime + stime);
2269 + cutime_fix_ratio =
2270 cstime_fix_ratio = 0.0;
2287 - stime_fix_ratio = (double)global_stime / (double)stime;
2271 }
2272 }
2273 else {
2274 + utime_fix_ratio =
2275 + stime_fix_ratio =
2276 + cutime_fix_ratio =
2277 cstime_fix_ratio = 0.0;
2292 - stime_fix_ratio = 0.0;
2278 }
2279
2280 + if(utime_fix_ratio > 1.0) utime_fix_ratio = 1.0;
2281 + if(cutime_fix_ratio > 1.0) cutime_fix_ratio = 1.0;
2282 if(stime_fix_ratio > 1.0) stime_fix_ratio = 1.0;
2283 if(cstime_fix_ratio > 1.0) cstime_fix_ratio = 1.0;
2284 +
2285 + // if(utime_fix_ratio < 0.0) utime_fix_ratio = 0.0;
2286 + // if(cutime_fix_ratio < 0.0) cutime_fix_ratio = 0.0;
2287 // if(stime_fix_ratio < 0.0) stime_fix_ratio = 0.0;
2288 // if(cstime_fix_ratio < 0.0) cstime_fix_ratio = 0.0;
2289