Categories
SysOps

How to align simple MariaDB output

Use column utility to align simple MariaDB output like variable list.

Display variables like wsrep%.

$ sudo mariadb --skip-column-names --batch --execute "show variables like 'wsrep%'"
wsrep_osu_method        TOI
wsrep_sr_store  table
wsrep_auto_increment_control    ON
wsrep_causal_reads      OFF
wsrep_certification_rules       strict
wsrep_certify_nonpk     ON
wsrep_cluster_address
wsrep_cluster_name      my_wsrep_cluster
wsrep_convert_lock_to_trx       OFF
wsrep_data_home_dir     /var/lib/mysql/
wsrep_dbug_option
wsrep_debug     NONE
wsrep_desync    OFF
wsrep_dirty_reads       OFF
wsrep_drupal_282555_workaround  OFF
wsrep_forced_binlog_format      NONE
wsrep_gtid_domain_id    0
wsrep_gtid_mode OFF
wsrep_gtid_seq_no       0
wsrep_ignore_apply_errors       7
wsrep_load_data_splitting       OFF
wsrep_log_conflicts     OFF
wsrep_max_ws_rows       0
wsrep_max_ws_size       2147483647
wsrep_mysql_replication_bundle  0
wsrep_node_address
wsrep_node_incoming_address     AUTO
wsrep_node_name bullseye
wsrep_notify_cmd
wsrep_on        OFF
wsrep_patch_version     wsrep_26.22
wsrep_provider  none
wsrep_provider_options
wsrep_recover   OFF
wsrep_reject_queries    NONE
wsrep_replicate_myisam  OFF
wsrep_restart_slave     OFF
wsrep_retry_autocommit  1
wsrep_slave_fk_checks   ON
wsrep_slave_uk_checks   OFF
wsrep_slave_threads     1
wsrep_sst_auth
wsrep_sst_donor
wsrep_sst_donor_rejects_queries OFF
wsrep_sst_method        rsync
wsrep_sst_receive_address       AUTO
wsrep_start_position    00000000-0000-0000-0000-000000000000:-1
wsrep_strict_ddl        OFF
wsrep_sync_wait 0
wsrep_trx_fragment_size 0
wsrep_trx_fragment_unit bytes

Display variables like wsrep% and pretty-print output as a table.

$ sudo mariadb --skip-column-names --batch --execute "show variables like 'wsrep%'" | column --table
wsrep_osu_method                 TOI
wsrep_sr_store                   table
wsrep_auto_increment_control     ON
wsrep_causal_reads               OFF
wsrep_certification_rules        strict
wsrep_certify_nonpk              ON
wsrep_cluster_address            
wsrep_cluster_name               my_wsrep_cluster
wsrep_convert_lock_to_trx        OFF
wsrep_data_home_dir              /var/lib/mysql/
wsrep_dbug_option                
wsrep_debug                      NONE
wsrep_desync                     OFF
wsrep_dirty_reads                OFF
wsrep_drupal_282555_workaround   OFF
wsrep_forced_binlog_format       NONE
wsrep_gtid_domain_id             0
wsrep_gtid_mode                  OFF
wsrep_gtid_seq_no                0
wsrep_ignore_apply_errors        7
wsrep_load_data_splitting        OFF
wsrep_log_conflicts              OFF
wsrep_max_ws_rows                0
wsrep_max_ws_size                2147483647
wsrep_mysql_replication_bundle   0
wsrep_node_address               
wsrep_node_incoming_address      AUTO
wsrep_node_name                  bullseye
wsrep_notify_cmd                 
wsrep_on                         OFF
wsrep_patch_version              wsrep_26.22
wsrep_provider                   none
wsrep_provider_options           
wsrep_recover                    OFF
wsrep_reject_queries             NONE
wsrep_replicate_myisam           OFF
wsrep_restart_slave              OFF
wsrep_retry_autocommit           1
wsrep_slave_fk_checks            ON
wsrep_slave_uk_checks            OFF
wsrep_slave_threads              1
wsrep_sst_auth                   
wsrep_sst_donor                  
wsrep_sst_donor_rejects_queries  OFF
wsrep_sst_method                 rsync
wsrep_sst_receive_address        AUTO
wsrep_start_position             00000000-0000-0000-0000-000000000000:-1
wsrep_strict_ddl                 OFF
wsrep_sync_wait                  0
wsrep_trx_fragment_size          0
wsrep_trx_fragment_unit          bytes

Display variables like wsrep%, pretty-print output as a table, and set output width.

$ sudo mariadb --skip-column-names --batch --execute "show variables like 'wsrep%'" | column --table | column --output-width 240
wsrep_osu_method                 TOI                                            wsrep_gtid_mode                  OFF                                            wsrep_reject_queries             NONE
wsrep_sr_store                   table                                          wsrep_gtid_seq_no                0                                              wsrep_replicate_myisam           OFF
wsrep_auto_increment_control     ON                                             wsrep_ignore_apply_errors        7                                              wsrep_restart_slave              OFF
wsrep_causal_reads               OFF                                            wsrep_load_data_splitting        OFF                                            wsrep_retry_autocommit           1
wsrep_certification_rules        strict                                         wsrep_log_conflicts              OFF                                            wsrep_slave_fk_checks            ON
wsrep_certify_nonpk              ON                                             wsrep_max_ws_rows                0                                              wsrep_slave_uk_checks            OFF
wsrep_cluster_address                                                           wsrep_max_ws_size                2147483647                                     wsrep_slave_threads              1
wsrep_cluster_name               my_wsrep_cluster                               wsrep_mysql_replication_bundle   0                                              wsrep_sst_auth                   
wsrep_convert_lock_to_trx        OFF                                            wsrep_node_address                                                              wsrep_sst_donor                  
wsrep_data_home_dir              /var/lib/mysql/                                wsrep_node_incoming_address      AUTO                                           wsrep_sst_donor_rejects_queries  OFF
wsrep_dbug_option                                                               wsrep_node_name                  bullseye                                       wsrep_sst_method                 rsync
wsrep_debug                      NONE                                           wsrep_notify_cmd                                                                wsrep_sst_receive_address        AUTO
wsrep_desync                     OFF                                            wsrep_on                         OFF                                            wsrep_start_position             00000000-0000-0000-0000-000000000000:-1
wsrep_dirty_reads                OFF                                            wsrep_patch_version              wsrep_26.22                                    wsrep_strict_ddl                 OFF
wsrep_drupal_282555_workaround   OFF                                            wsrep_provider                   none                                           wsrep_sync_wait                  0
wsrep_forced_binlog_format       NONE                                           wsrep_provider_options                                                          wsrep_trx_fragment_size          0
wsrep_gtid_domain_id             0                                              wsrep_recover                    OFF                                            wsrep_trx_fragment_unit          bytes