1313// limitations under the License.
1414use rabbitmq_http_client:: blocking_api:: HttpClientError ;
1515use rabbitmq_http_client:: responses:: {
16- ClusterAlarmCheckDetails , HealthCheckFailureDetails , Overview , QuorumCriticalityCheckDetails ,
16+ ClusterAlarmCheckDetails , HealthCheckFailureDetails , NodeMemoryBreakdown , Overview ,
17+ QuorumCriticalityCheckDetails ,
1718} ;
1819use reqwest:: StatusCode ;
1920use tabled:: settings:: Panel ;
@@ -27,9 +28,9 @@ struct OverviewRow<'a> {
2728}
2829
2930#[ derive( Debug , Tabled ) ]
30- struct RowOfTwoStrings < ' a > {
31+ struct RowOfTwoStrings < ' a , T : ? Sized + std :: fmt :: Display > {
3132 key : & ' a str ,
32- value : & ' a str ,
33+ value : & ' a T ,
3334}
3435
3536pub fn overview ( ov : Overview ) -> Table {
@@ -336,3 +337,138 @@ pub fn health_check_failure(
336337
337338 tb. build ( )
338339}
340+
341+ pub ( crate ) fn memory_breakdown ( breakdown : NodeMemoryBreakdown ) -> Table {
342+ // There is no easy way to transpose an existing table in Tabled, so…
343+ let atom_table_val = breakdown. atom_table ;
344+ let allocated_but_unused_val = breakdown. allocated_but_unused ;
345+ let binary_heap_val = breakdown. binary_heap ;
346+ let classic_queue_procs_val = breakdown. classic_queue_procs ;
347+ let code_val = breakdown. code ;
348+ let connection_channels_val = breakdown. connection_channels ;
349+ let connection_readers_val = breakdown. connection_readers ;
350+ let connection_writers_val = breakdown. connection_writers ;
351+ let connection_other_val = breakdown. connection_other ;
352+ let management_db_val = breakdown. management_db ;
353+ let message_indices_val = breakdown. message_indices ;
354+ let metadata_store_val = breakdown. metadata_store ;
355+ let metadata_store_ets_tables_val = breakdown. metadata_store_ets_tables ;
356+ let metrics_val = breakdown. metrics ;
357+ let mnesia_val = breakdown. mnesia ;
358+ let other_ets_tables_val = breakdown. other_ets_tables ;
359+ let other_system_val = breakdown. other_system ;
360+ let other_procs_val = breakdown. other_procs ;
361+ let quorum_queue_procs_val = breakdown. quorum_queue_procs ;
362+ let quorum_queue_ets_tables_val = breakdown. quorum_queue_ets_tables ;
363+ let plugins_val = breakdown. plugins ;
364+ let reserved_but_unallocated_val = breakdown. reserved_but_unallocated ;
365+ let stream_queue_procs_val = breakdown. stream_queue_procs ;
366+ let stream_queue_replica_reader_procs_val = breakdown. stream_queue_replica_reader_procs ;
367+ let stream_queue_coordinator_procs_val = breakdown. stream_queue_coordinator_procs ;
368+ let mut data: Vec < RowOfTwoStrings < u64 > > = vec ! [
369+ RowOfTwoStrings {
370+ key: "Atom table" ,
371+ value: & atom_table_val,
372+ } ,
373+ RowOfTwoStrings {
374+ key: "Allocated but unused" ,
375+ value: & allocated_but_unused_val,
376+ } ,
377+ RowOfTwoStrings {
378+ key: "Binary heap" ,
379+ value: & binary_heap_val,
380+ } ,
381+ RowOfTwoStrings {
382+ key: "Classic queue processes" ,
383+ value: & classic_queue_procs_val,
384+ } ,
385+ RowOfTwoStrings {
386+ key: "Code " ,
387+ value: & code_val,
388+ } ,
389+ RowOfTwoStrings {
390+ key: "AMQP 0-9-1 channels" ,
391+ value: & connection_channels_val,
392+ } ,
393+ RowOfTwoStrings {
394+ key: "Client connections: reader processes" ,
395+ value: & connection_readers_val,
396+ } ,
397+ RowOfTwoStrings {
398+ key: "Client connections: writer processes" ,
399+ value: & connection_writers_val,
400+ } ,
401+ RowOfTwoStrings {
402+ key: "Client connections: others processes" ,
403+ value: & connection_other_val,
404+ } ,
405+ RowOfTwoStrings {
406+ key: "Management stats database" ,
407+ value: & management_db_val,
408+ } ,
409+ RowOfTwoStrings {
410+ key: "Message store indices" ,
411+ value: & message_indices_val,
412+ } ,
413+ RowOfTwoStrings {
414+ key: "Metadata store" ,
415+ value: & metadata_store_val,
416+ } ,
417+ RowOfTwoStrings {
418+ key: "Metadata store ETS tables" ,
419+ value: & metadata_store_ets_tables_val,
420+ } ,
421+ RowOfTwoStrings {
422+ key: "Metrics data" ,
423+ value: & metrics_val,
424+ } ,
425+ RowOfTwoStrings {
426+ key: "Mnesia" ,
427+ value: & mnesia_val,
428+ } ,
429+ RowOfTwoStrings {
430+ key: "Other (ETS tables)" ,
431+ value: & other_ets_tables_val,
432+ } ,
433+ RowOfTwoStrings {
434+ key: "Other (used by the runtime)" ,
435+ value: & other_system_val,
436+ } ,
437+ RowOfTwoStrings {
438+ key: "Other processes" ,
439+ value: & other_procs_val,
440+ } ,
441+ RowOfTwoStrings {
442+ key: "Quorum queue replica processes" ,
443+ value: & quorum_queue_procs_val,
444+ } ,
445+ RowOfTwoStrings {
446+ key: "Quorum queue ETS tables" ,
447+ value: & quorum_queue_ets_tables_val,
448+ } ,
449+ RowOfTwoStrings {
450+ key: "Plugins and their data" ,
451+ value: & plugins_val,
452+ } ,
453+ RowOfTwoStrings {
454+ key: "Reserved by the kernel but unallocated" ,
455+ value: & reserved_but_unallocated_val,
456+ } ,
457+ RowOfTwoStrings {
458+ key: "Stream replica processes" ,
459+ value: & stream_queue_procs_val,
460+ } ,
461+ RowOfTwoStrings {
462+ key: "Stream replica reader processes" ,
463+ value: & stream_queue_replica_reader_procs_val,
464+ } ,
465+ RowOfTwoStrings {
466+ key: "Stream coordinator processes" ,
467+ value: & stream_queue_coordinator_procs_val,
468+ } ,
469+ ] ;
470+ // Note: this is descending ordering
471+ data. sort_by ( |a, b| b. value . cmp ( a. value ) ) ;
472+ let tb = Table :: builder ( data) ;
473+ tb. build ( )
474+ }
0 commit comments