@@ -401,24 +401,26 @@ private function commandsStats(): string {
401401 private function slabs (): string {
402402 $ slabs_stats = $ this ->memcached ->getSlabsStats ();
403403
404- $ slabs = array_map (static function ($ slab ) {
405- return [
406- 'Chunk Size ' => Format:: bytes ( $ slab [ ' chunk_size ' ]) ,
407- 'Chunks per Page ' => Format:: number ( $ slab [ ' chunks_per_page ' ]) ,
408- 'Total Pages ' => Format:: number ( $ slab [ ' total_pages ' ]) ,
409- 'Total Chunks ' => Format:: number ( $ slab [ ' total_chunks ' ]) ,
410- 'Used Chunks ' => Format:: number ( $ slab [ ' used_chunks ' ]) ,
411- 'Free Chunks ' => Format:: number ( $ slab [ ' free_chunks ' ]) ,
412- 'Free Chunks (End) ' => Format:: number ( $ slab [ ' free_chunks_end ' ]) ,
413- 'GET Hits ' => Format:: number ( $ slab [ ' get_hits ' ]) ,
414- 'SET Commands ' => Format:: number ( $ slab [ ' cmd_set ' ]) ,
415- 'DELETE Hits ' => Format:: number ( $ slab [ ' delete_hits ' ]) ,
416- 'INCREMENT Hits ' => Format:: number ( $ slab [ ' incr_hits ' ]) ,
417- 'DECREMENT Hits ' => Format:: number ( $ slab [ ' decr_hits ' ]) ,
418- 'CAS Hits ' => Format:: number ( $ slab [ ' cas_hits ' ]) ,
419- 'CAS Bad Value ' => Format:: number ( $ slab [ ' cas_badval ' ]) ,
420- 'TOUCH Hits ' => Format:: number ( $ slab [ ' touch_hits ' ]) ,
404+ $ slabs = array_map (function (array $ slab ): array {
405+ $ fields = [
406+ 'chunk_size ' => [ ' Chunk Size ' , ' bytes ' ] ,
407+ 'chunks_per_page ' => [ ' Chunks per Page ', ' number ' ] ,
408+ 'total_pages ' => [ ' Total Pages ' , ' number ' ] ,
409+ 'total_chunks ' => [ ' Total Chunks ' , ' number ' ] ,
410+ 'used_chunks ' => [ ' Used Chunks ' , ' number ' ] ,
411+ 'free_chunks ' => [ ' Free Chunks ' , ' number ' ] ,
412+ 'free_chunks_end ' => [ ' Free Chunks (End) ', ' number ' ] ,
413+ 'get_hits ' => [ ' GET Hits ' , ' number ' ] ,
414+ 'cmd_set ' => [ ' SET Commands ' , ' number ' ] ,
415+ 'delete_hits ' => [ ' DELETE Hits ' , ' number ' ] ,
416+ 'incr_hits ' => [ ' INCREMENT Hits ' , ' number ' ] ,
417+ 'decr_hits ' => [ ' DECREMENT Hits ' , ' number ' ] ,
418+ 'cas_hits ' => [ ' CAS Hits ' , ' number ' ] ,
419+ 'cas_badval ' => [ ' CAS Bad Value ' , ' number ' ] ,
420+ 'touch_hits ' => [ ' TOUCH Hits ' , ' number ' ] ,
421421 ];
422+
423+ return $ this ->formatField ($ fields , $ slab );
422424 }, $ slabs_stats ['slabs ' ]);
423425
424426 return $ this ->template ->render ('dashboards/memcached ' , [
@@ -427,6 +429,69 @@ private function slabs(): string {
427429 ]);
428430 }
429431
432+ /**
433+ * @throws MemcachedException
434+ */
435+ private function items (): string {
436+ $ stats = $ this ->memcached ->getItemsStats ();
437+
438+ $ items = array_map (function (array $ item ): array {
439+ $ fields = [
440+ 'number ' => ['Items ' , 'number ' ],
441+ 'number_hot ' => ['HOT LRU ' , 'number ' ],
442+ 'number_warm ' => ['WARM LRU ' , 'number ' ],
443+ 'number_cold ' => ['COLD LRU ' , 'number ' ],
444+ 'number_temp ' => ['TEMP LRU ' , 'number ' ],
445+ 'age_hot ' => ['Age (HOT) ' , 'seconds ' ],
446+ 'age_warm ' => ['Age (WARM) ' , 'seconds ' ],
447+ 'age ' => ['Age (LRU) ' , 'seconds ' ],
448+ 'mem_requested ' => ['Memory Requested ' , 'bytes ' ],
449+ 'evicted ' => ['Evicted ' , 'number ' ],
450+ 'evicted_nonzero ' => ['Evicted Non-Zero ' , 'number ' ],
451+ 'evicted_time ' => ['Evicted Time ' , 'number ' ],
452+ 'outofmemory ' => ['Out of Memory ' , 'number ' ],
453+ 'tailrepairs ' => ['Tail Repairs ' , 'number ' ],
454+ 'reclaimed ' => ['Reclaimed ' , 'number ' ],
455+ 'expired_unfetched ' => ['Expired Unfetched ' , 'number ' ],
456+ 'evicted_unfetched ' => ['Evicted Unfetched ' , 'number ' ],
457+ 'evicted_active ' => ['Evicted Active ' , 'number ' ],
458+ 'crawler_reclaimed ' => ['Crawler Reclaimed ' , 'number ' ],
459+ 'crawler_items_checked ' => ['Crawler Items Checked ' , 'number ' ],
460+ 'lrutail_reflocked ' => ['LRU Tail Reflocked ' , 'number ' ],
461+ 'moves_to_cold ' => ['Moves to COLD ' , 'number ' ],
462+ 'moves_to_warm ' => ['Moves to WARM ' , 'number ' ],
463+ 'moves_within_lru ' => ['Moves within LRU ' , 'number ' ],
464+ 'direct_reclaims ' => ['Direct Reclaims ' , 'number ' ],
465+ 'hits_to_hot ' => ['Hits to HOT ' , 'number ' ],
466+ 'hits_to_warm ' => ['Hits to WARM ' , 'number ' ],
467+ 'hits_to_cold ' => ['Hits to COLD ' , 'number ' ],
468+ 'hits_to_temp ' => ['Hits to TEMP ' , 'number ' ],
469+ ];
470+
471+ return $ this ->formatField ($ fields , $ item );
472+ }, $ stats );
473+
474+ return $ this ->template ->render ('dashboards/memcached ' , ['items ' => $ items ]);
475+ }
476+
477+ /**
478+ * @param array<string, mixed> $fields
479+ * @param array<string, mixed> $item
480+ *
481+ * @return array<string, mixed>
482+ */
483+ private function formatField (array $ fields , array $ item ): array {
484+ $ formatted = [];
485+
486+ foreach ($ fields as $ key => [$ label , $ type ]) {
487+ $ value = $ item [$ key ] ?? 0 ;
488+ jdump ([$ label , $ value , $ type ]);
489+ $ formatted [$ label ] = Format::{$ type }($ value );
490+ }
491+
492+ return $ formatted ;
493+ }
494+
430495 /**
431496 * @throws MemcachedException
432497 */
@@ -446,6 +511,10 @@ private function mainDashboard(): string {
446511 return $ this ->slabs ();
447512 }
448513
514+ if (Http::get ('tab ' ) === 'items ' ) {
515+ return $ this ->items ();
516+ }
517+
449518 $ keys = $ this ->getAllKeys ();
450519
451520 if (isset ($ _GET ['export_btn ' ])) {
0 commit comments