@@ -35,42 +35,33 @@ private function getPanelsData(bool $command_stats = false): array {
3535
3636 $ info = $ this ->memcached ->getServerStats ();
3737
38- $ memory_usage = ($ info ['limit_maxbytes ' ] > 0 ) ? round (($ info ['bytes ' ] / $ info ['limit_maxbytes ' ]) * 100 , 2 ) : 0 ;
39-
4038 $ stats = [
4139 [
4240 'title ' => $ title ,
4341 'moreinfo ' => true ,
4442 'data ' => [
4543 'Version ' => $ info ['version ' ],
46- 'Uptime ' => Format::seconds ($ info ['uptime ' ]),
47- ],
48- ],
49- [
50- 'title ' => 'Memory ' ,
51- 'data ' => [
52- 'Total ' => Format::bytes ($ info ['limit_maxbytes ' ], 0 ),
53- ['Used ' , Format::bytes ($ info ['bytes ' ]).' ( ' .$ memory_usage .'%) ' , $ memory_usage ],
54- 'Free ' => Format::bytes ($ info ['limit_maxbytes ' ] - $ info ['bytes ' ]),
44+ 'Uptime ' => Format::seconds ($ info ['uptime ' ] ?? 0 ),
5545 ],
5646 ],
47+ $ this ->memoryPanel ($ info ),
5748 [
5849 'title ' => 'Keys ' ,
5950 'data ' => [
60- 'Current ' => Format::number ($ info ['curr_items ' ]),
61- 'Total (since start) ' => Format::number ($ info ['total_items ' ]),
62- 'Evictions ' => Format::number ($ info ['evictions ' ]),
63- 'Reclaimed ' => Format::number ($ info ['reclaimed ' ]),
64- 'Expired Unfetched ' => Format::number ($ info ['expired_unfetched ' ]),
65- 'Evicted Unfetched ' => Format::number ($ info ['evicted_unfetched ' ]),
51+ 'Current ' => Format::number ($ info ['curr_items ' ] ?? 0 ),
52+ 'Total (since start) ' => Format::number ($ info ['total_items ' ] ?? 0 ),
53+ 'Evictions ' => Format::number ($ info ['evictions ' ] ?? 0 ),
54+ 'Reclaimed ' => Format::number ($ info ['reclaimed ' ] ?? 0 ),
55+ 'Expired Unfetched ' => Format::number ($ info ['expired_unfetched ' ] ?? 0 ),
56+ 'Evicted Unfetched ' => Format::number ($ info ['evicted_unfetched ' ] ?? 0 ),
6657 ],
6758 ],
6859 [
6960 'title ' => 'Connections ' ,
7061 'data ' => [
71- 'Current ' => Format::number ($ info ['curr_connections ' ]).' / ' .Format::number ($ info ['max_connections ' ]).' max ' ,
72- 'Total ' => Format::number ($ info ['total_connections ' ]),
73- 'Rejected ' => Format::number ($ info ['rejected_connections ' ]),
62+ 'Current ' => Format::number ($ info ['curr_connections ' ] ?? 0 ).' / ' .Format::number ($ info ['max_connections ' ] ?? 0 ).' max ' ,
63+ 'Total ' => Format::number ($ info ['total_connections ' ] ?? 0 ),
64+ 'Rejected ' => Format::number ($ info ['rejected_connections ' ] ?? 0 ),
7465 ],
7566 ],
7667 ];
@@ -85,6 +76,26 @@ private function getPanelsData(bool $command_stats = false): array {
8576 }
8677 }
8778
79+ /**
80+ * @param array<string, mixed> $info
81+ *
82+ * @return array{title: string, data: array<int|string, mixed>}
83+ */
84+ private function memoryPanel (array $ info ): array {
85+ $ limit_maxbytes = $ info ['limit_maxbytes ' ] ?? 0 ;
86+ $ bytes = $ info ['bytes ' ] ?? 0 ;
87+ $ memory_usage = ($ limit_maxbytes > 0 ) ? round (($ bytes / $ limit_maxbytes ) * 100 , 2 ) : 0 ;
88+
89+ return [
90+ 'title ' => 'Memory ' ,
91+ 'data ' => [
92+ 'Total ' => Format::bytes ($ limit_maxbytes , 0 ),
93+ ['Used ' , Format::bytes ($ bytes ).' ( ' .$ memory_usage .'%) ' , $ memory_usage ],
94+ 'Free ' => Format::bytes ($ limit_maxbytes - $ bytes ),
95+ ],
96+ ];
97+ }
98+
8899 /**
89100 * @throws MemcachedException
90101 */
0 commit comments