15
15
import org .elasticsearch .common .unit .ByteSizeValue ;
16
16
import org .elasticsearch .common .util .Maps ;
17
17
import org .elasticsearch .core .TimeValue ;
18
+ import org .elasticsearch .transport .Transports ;
18
19
19
20
import java .lang .management .ManagementFactory ;
20
21
import java .lang .management .ThreadInfo ;
@@ -313,12 +314,15 @@ String innerDetect(ThreadMXBean threadBean, SunThreadInfo sunThreadInfo, long cu
313
314
case CPU -> {
314
315
double percentCpu = getTimeSharePercentage (topThread .getCpuTime ());
315
316
double percentOther = getTimeSharePercentage (topThread .getOtherTime ());
317
+ double percentTotal = (Transports .isTransportThread (threadName )) ? percentCpu : percentOther + percentCpu ;
318
+ String otherLabel = (Transports .isTransportThread (threadName )) ? "idle" : "other" ;
316
319
sb .append (
317
320
String .format (
318
321
Locale .ROOT ,
319
- "%n%4.1f%% [cpu=%1.1f%%, other =%1.1f%%] (%s out of %s) %s usage by thread '%s'%n" ,
320
- percentOther + percentCpu ,
322
+ "%n%4.1f%% [cpu=%1.1f%%, %s =%1.1f%%] (%s out of %s) %s usage by thread '%s'%n" ,
323
+ percentTotal ,
321
324
percentCpu ,
325
+ otherLabel ,
322
326
percentOther ,
323
327
TimeValue .timeValueNanos (topThread .getCpuTime () + topThread .getOtherTime ()),
324
328
interval ,
@@ -412,8 +416,8 @@ static int similarity(ThreadInfo threadInfo, ThreadInfo threadInfo0) {
412
416
413
417
static class ThreadTimeAccumulator {
414
418
private final long threadId ;
419
+ private final String threadName ;
415
420
private final TimeValue interval ;
416
-
417
421
private long cpuTime ;
418
422
private long blockedTime ;
419
423
private long waitedTime ;
@@ -425,6 +429,7 @@ static class ThreadTimeAccumulator {
425
429
this .cpuTime = cpuTime ;
426
430
this .allocatedBytes = allocatedBytes ;
427
431
this .threadId = info .getThreadId ();
432
+ this .threadName = info .getThreadName ();
428
433
this .interval = interval ;
429
434
}
430
435
@@ -457,6 +462,8 @@ public long getRunnableTime() {
457
462
// not running, or it has been asleep forever.
458
463
if (getCpuTime () == 0 ) {
459
464
return 0 ;
465
+ } else if (Transports .isTransportThread (threadName )) {
466
+ return getCpuTime ();
460
467
}
461
468
return Math .max (interval .nanos () - getWaitedTime () - getBlockedTime (), 0 );
462
469
}
@@ -468,7 +475,7 @@ public long getOtherTime() {
468
475
return 0 ;
469
476
}
470
477
471
- return Math .max (getRunnableTime () - getCpuTime (), 0 );
478
+ return Math .max (interval . nanos () - getWaitedTime () - getBlockedTime () - getCpuTime (), 0 );
472
479
}
473
480
474
481
public long getBlockedTime () {
0 commit comments