@@ -73,6 +73,7 @@ type containerData struct {
73
73
loadReader cpuload.CpuLoadReader
74
74
summaryReader * summary.StatsSummary
75
75
loadAvg float64 // smoothed load average seen so far.
76
+ loadDAvg float64 // smoothed load.d average seen so far.
76
77
housekeepingInterval time.Duration
77
78
maxHousekeepingInterval time.Duration
78
79
allowDynamicHousekeeping bool
@@ -441,6 +442,7 @@ func newContainerData(containerName string, memoryCache *memory.InMemoryCache, h
441
442
allowDynamicHousekeeping : allowDynamicHousekeeping ,
442
443
logUsage : logUsage ,
443
444
loadAvg : - 1.0 , // negative value indicates uninitialized.
445
+ loadDAvg : - 1.0 , // negative value indicates uninitialized.
444
446
stop : make (chan struct {}),
445
447
collectorManager : collectorManager ,
446
448
onDemandChan : make (chan chan struct {}, 100 ),
@@ -633,6 +635,14 @@ func (cd *containerData) updateLoad(newLoad uint64) {
633
635
}
634
636
}
635
637
638
+ func (cd * containerData ) updateLoadD (newLoad uint64 ) {
639
+ if cd .loadDAvg < 0 {
640
+ cd .loadDAvg = float64 (newLoad ) // initialize to the first seen sample for faster stabilization.
641
+ } else {
642
+ cd .loadDAvg = cd .loadDAvg * cd .loadDecay + float64 (newLoad )* (1.0 - cd .loadDecay )
643
+ }
644
+ }
645
+
636
646
func (cd * containerData ) updateStats () error {
637
647
stats , statsErr := cd .handler .GetStats ()
638
648
if statsErr != nil {
@@ -659,6 +669,10 @@ func (cd *containerData) updateStats() error {
659
669
cd .updateLoad (loadStats .NrRunning )
660
670
// convert to 'milliLoad' to avoid floats and preserve precision.
661
671
stats .Cpu .LoadAverage = int32 (cd .loadAvg * 1000 )
672
+
673
+ cd .updateLoadD (loadStats .NrUninterruptible )
674
+ // convert to 'milliLoad' to avoid floats and preserve precision.
675
+ stats .Cpu .LoadDAverage = int32 (cd .loadDAvg * 1000 )
662
676
}
663
677
}
664
678
if cd .summaryReader != nil {
0 commit comments