diff --git a/maxctrl/lib/common.js b/maxctrl/lib/common.js index fce630d67..bcadc6aad 100644 --- a/maxctrl/lib/common.js +++ b/maxctrl/lib/common.js @@ -412,6 +412,24 @@ module.exports = function() { this.error = function(err) { return Promise.reject(colors.red('Error: ') + err) } + + this.fieldDescriptions = function(fields) { + var t = new Table({chars: { + 'top' : '', 'top-mid': '', 'top-left': '', 'top-right': '', 'left': ' ', 'right': '', + 'left-mid': '' , 'mid': '' , 'mid-mid': '', 'right-mid': '' , 'middle': '', + 'bottom' : '', 'bottom-mid': '', 'bottom-left': '', 'bottom-right': '', + }}) + + t.push(['Field', 'Description']) + t.push(['-----', '-----------']) + + + for (f of fields) { + t.push([f.name, f.description]) + } + + return '\n\n' + t.toString() + } } @@ -431,8 +449,6 @@ var tsvopts = { 'padding-right': 0, compact: true }, - - } function getList() { diff --git a/maxctrl/lib/list.js b/maxctrl/lib/list.js index 8789cd257..72124ab40 100644 --- a/maxctrl/lib/list.js +++ b/maxctrl/lib/list.js @@ -17,26 +17,32 @@ const list_servers_fields = [ { name: 'Server', path: 'id', + description: 'Server name' }, { name: 'Address', path: 'attributes.parameters.address', + description: 'Address where the server listens' }, { name: 'Port', path: 'attributes.parameters.port', + description: 'The port on which the server listens' }, { name: 'Connections', path: 'attributes.statistics.connections', + description: 'Current connection count' }, { name: 'State', path: 'attributes.state', + description: 'Server state' }, { name: 'GTID', path: 'attributes.gtid_current_pos', + description: 'Current value of @@gtid_current_pos' } ] @@ -44,22 +50,27 @@ const list_services_fields = [ { name: 'Service', path: 'id', + description: 'Service name' }, { name: 'Router', path: 'attributes.router', + description: 'Router used by the service' }, { name: 'Connections', path: 'attributes.connections', + description: 'Current connection count' }, { name: 'Total Connections', path: 'attributes.total_connections', + description: 'Total connection count' }, { name: 'Servers', path: 'relationships.servers.data[].id', + description: 'Servers that the service uses' } ] @@ -67,18 +78,22 @@ const list_listeners_fields = [ { name: 'Name', path: 'id', + description: 'Listener name' }, { name: 'Port', path: 'attributes.parameters.port', + description: 'The port where the listener listens' }, { name: 'Host', path: 'attributes.parameters.host', + description: 'The address or socket where the listener listens' }, { name: 'State', path: 'attributes.state', + description: 'Listener state' } ] @@ -86,14 +101,17 @@ const list_monitors_fields = [ { name: 'Monitor', path: 'id', + description: 'Monitor name' }, { name: 'State', path: 'attributes.state', + description: 'Monitor state' }, { name: 'Servers', path: 'relationships.servers.data[].id', + description: 'The servers that this monitor monitors' } ] @@ -101,26 +119,32 @@ const list_sessions_fields = [ { name: 'Id', path: 'id', + description: 'Session ID' }, { name: 'User', path: 'attributes.user', + description: 'Username' }, { name: 'Host', path: 'attributes.remote', + description: 'Client host address' }, { name: 'Connected', path: 'attributes.connected', + description: 'Time when the session started' }, { name: 'Idle', path: 'attributes.idle', + description: 'How long the session has been idle, in seconds' }, { name: 'Service', path: 'relationships.services.data[].id', + description: 'The service where the session connected' } ] @@ -128,14 +152,17 @@ const list_filters_fields = [ { name: 'Filter', path: 'id', + description: 'Filter name' }, { name: 'Service', path: 'relationships.services.data[].id', + description: 'Services that use the filter' }, { name: 'Module', path: 'attributes.module', + description: 'The module that the filter uses' } ] @@ -143,14 +170,17 @@ const list_modules_fields = [ { name: 'Module', path: 'id', + description: 'Module name' }, { name: 'Type', path: 'attributes.module_type', + description: 'Module type' }, { name: 'Version', path: 'attributes.version', + description: 'Module version' } ] @@ -158,26 +188,32 @@ const list_threads_fields = [ { name: 'Id', path: 'id', + description: 'Thread ID' }, { name: 'Current FDs', path: 'attributes.stats.current_descriptors', + description: 'Current number of managed file descriptors' }, { name: 'Total FDs', path: 'attributes.stats.total_descriptors', + description: 'Total number of managed file descriptors' }, { name: 'Load (1s)', path: 'attributes.stats.load.last_second', + description: 'Load percentage over the last second' }, { name: 'Load (1m)', path: 'attributes.stats.load.last_minute', + description: 'Load percentage over the last minute' }, { name: 'Load (1h)', path: 'attributes.stats.load.last_hour', + description: 'Load percentage over the last hour' } ] @@ -185,14 +221,17 @@ const list_users_fields = [ { name: 'Name', path: 'id', + description: 'User name' }, { name: 'Type', path: 'type', + description: 'User type' }, { name: 'Privileges', path: 'attributes.account', + description: 'User privileges' }, ] @@ -200,10 +239,12 @@ const list_commands_fields = [ { name: 'Module', path: 'id', + description: 'Module name' }, { name: 'Commands', path: 'attributes.commands[].id', + description: 'Available commands' } ] @@ -213,7 +254,8 @@ exports.handler = function() {} exports.builder = function(yargs) { yargs .command('servers', 'List servers', function(yargs) { - return yargs.epilog('List all servers in MaxScale.') + return yargs.epilog('List all servers in MaxScale.' + + fieldDescriptions(list_servers_fields)) .usage('Usage: list servers') }, function(argv) { maxctrl(argv, function(host) { @@ -260,7 +302,8 @@ exports.builder = function(yargs) { }) }) .command('services', 'List services', function(yargs) { - return yargs.epilog('List all services and the servers they use.') + return yargs.epilog('List all services and the servers they use.' + + fieldDescriptions(list_services_fields)) .usage('Usage: list services') }, function(argv) { maxctrl(argv, function(host) { @@ -268,7 +311,8 @@ exports.builder = function(yargs) { }) }) .command('listeners ', 'List listeners of a service', function(yargs) { - return yargs.epilog('List listeners for a service.') + return yargs.epilog('List listeners for a service.' + + fieldDescriptions(list_listeners_fields)) .usage('Usage: list listeners ') }, function(argv) { maxctrl(argv, function(host) { @@ -276,7 +320,8 @@ exports.builder = function(yargs) { }) }) .command('monitors', 'List monitors', function(yargs) { - return yargs.epilog('List all monitors in MaxScale.') + return yargs.epilog('List all monitors in MaxScale.' + + fieldDescriptions(list_monitors_fields)) .usage('Usage: list monitors') }, function(argv) { maxctrl(argv, function(host) { @@ -284,7 +329,8 @@ exports.builder = function(yargs) { }) }) .command('sessions', 'List sessions', function(yargs) { - return yargs.epilog('List all client sessions.') + return yargs.epilog('List all client sessions.' + + fieldDescriptions(list_sessions_fields)) .usage('Usage: list sessions') }, function(argv) { maxctrl(argv, function(host) { @@ -292,7 +338,8 @@ exports.builder = function(yargs) { }) }) .command('filters', 'List filters', function(yargs) { - return yargs.epilog('List all filters in MaxScale.') + return yargs.epilog('List all filters in MaxScale.' + + fieldDescriptions(list_filters_fields)) .usage('Usage: list filters') }, function(argv) { maxctrl(argv, function(host) { @@ -300,7 +347,8 @@ exports.builder = function(yargs) { }) }) .command('modules', 'List loaded modules', function(yargs) { - return yargs.epilog('List all currently loaded modules.') + return yargs.epilog('List all currently loaded modules.' + + fieldDescriptions(list_modules_fields)) .usage('Usage: list modules') }, function(argv) { maxctrl(argv, function(host) { @@ -308,7 +356,8 @@ exports.builder = function(yargs) { }) }) .command('threads', 'List threads', function(yargs) { - return yargs.epilog('List all worker threads.') + return yargs.epilog('List all worker threads.' + + fieldDescriptions(list_threads_fields)) .usage('Usage: list threads') }, function(argv) { maxctrl(argv, function(host) { @@ -317,7 +366,8 @@ exports.builder = function(yargs) { }) .command('users', 'List created users', function(yargs) { return yargs.epilog('List network the users that can be used to connect to the MaxScale REST API' + - ' as well as enabled local accounts.') + ' as well as enabled local accounts.' + + fieldDescriptions(list_users_fields)) .usage('Usage: list users') }, function(argv) { maxctrl(argv, function(host) { @@ -325,7 +375,8 @@ exports.builder = function(yargs) { }) }) .command('commands', 'List module commands', function(yargs) { - return yargs.epilog('List all available module commands.') + return yargs.epilog('List all available module commands.' + + fieldDescriptions(list_commands_fields)) .usage('Usage: list commands') }, function(argv) { maxctrl(argv, function(host) { diff --git a/maxctrl/lib/show.js b/maxctrl/lib/show.js index f72e190f7..15a26d2bf 100644 --- a/maxctrl/lib/show.js +++ b/maxctrl/lib/show.js @@ -17,93 +17,115 @@ const server_fields = [ { name: 'Server', path: 'id', + description: 'Server name' }, { name: 'Address', path: 'attributes.parameters.address', + description: 'Address where the server listens' }, { name: 'Port', path: 'attributes.parameters.port', + description: 'The port on which the server listens' }, { name: 'State', path: 'attributes.state', + description: 'Server state' }, { name: 'Last Event', path: 'attributes.last_event', + description: 'The type of the latest event' }, { name: 'Triggered At', path: 'attributes.triggered_at', + description: 'Time when the latest event was triggered at' }, { name: 'Services', path: 'relationships.services.data[].id', + description: 'Services that use this server' }, { name: 'Monitors', path: 'relationships.monitors.data[].id', + description: 'Monitors that monitor this server' }, { name: 'Master ID', path: 'attributes.master_id', + description: 'The server ID of the master' }, { name: 'Node ID', path: 'attributes.node_id', + description: 'The node ID of this server' }, { name: 'Slave Server IDs', path: 'attributes.slaves', + description: 'List of slave server IDs' }, { name: 'Statistics', path: 'attributes.statistics', + description: 'Server statistics' }, { name: 'Parameters', path: 'attributes.parameters', -} + description: 'Server parameters' + } ] const service_fields = [ { name: 'Service', path: 'id', + description: 'Service name' }, { name: 'Router', path: 'attributes.router', + description: 'Router that the service uses' }, { name: 'State', path: 'attributes.state', + description: 'Service state' }, { name: 'Started At', path: 'attributes.started', + description: 'When the service was started' }, { name: 'Current Connections', path: 'attributes.connections', + description: 'Current connection count' }, { name: 'Total Connections', path: 'attributes.total_connections', + description: 'Total connection count' }, { name: 'Servers', path: 'relationships.servers.data[].id', + description: 'Servers that the service uses' }, { name: 'Parameters', path: 'attributes.parameters', + description: 'Service parameter' }, { name: 'Router Diagnostics', path: 'attributes.router_diagnostics', + description: 'Diagnostics provided by the router module' } ] @@ -111,87 +133,108 @@ const monitor_fields = [ { name: 'Monitor', path: 'id', + description: 'Monitor name' }, { name: 'State', path: 'attributes.state', + description: 'Monitor state' }, { name: 'Servers', path: 'relationships.servers.data[].id', + description: 'The servers that this monitor monitors' }, { name: 'Parameters', path: 'attributes.parameters', + description: 'Monitor parameters' }, { name: 'Monitor Diagnostics', - path: 'attributes.monitor_diagnostics',} + path: 'attributes.monitor_diagnostics', + description: 'Diagnostics provided by the monitor module' + } ] const session_fields = [ { name: 'Id', path: 'id', + description: 'Session ID' }, { name: 'Service', path: 'relationships.services.data[].id', + description: 'The service where the session connected' }, { name: 'State', path: 'attributes.state', + description: 'Session state' }, { name: 'User', path: 'attributes.user', + description: 'Username' }, { name: 'Host', path: 'attributes.remote', + description: 'Client host address' }, { name: 'Connected', path: 'attributes.connected', + description: 'Time when the session started' }, { name: 'Idle', path: 'attributes.idle', + description: 'How long the session has been idle, in seconds' }, { name: 'Connections', path: 'attributes.connections[].server', + description: 'Ordered list of backend connections' }, { name: 'Connection IDs', path: 'attributes.connections[].protocol_diagnostics.connection_id', + description: 'Thread IDs for the backend connections' }, { name: 'Queries', path: 'attributes.queries[].statement', + description: 'Query history' }, { name: 'Log', path: 'attributes.log', -} + description: 'Per-session log messages' + } ] const filter_fields = [ { name: 'Filter', path: 'id', + description: 'Filter name' }, { name: 'Module', path: 'attributes.module', + description: 'The module that the filter uses' }, { name: 'Services', path: 'relationships.services.data[].id', + description: 'Services that use the filter' }, { name: 'Parameters', path: 'attributes.parameters', + description: 'Filter parameters' } ] @@ -199,30 +242,37 @@ const module_fields = [ { name: 'Module', path: 'id', + description: 'Module name' }, { name: 'Type', path: 'attributes.module_type', + description: 'Module type' }, { name: 'Version', path: 'attributes.version', + description: 'Module version' }, { name: 'Maturity', path: 'attributes.maturity', + description: 'Module maturity' }, { name: 'Description', path: 'attributes.description', + description: 'Short description about the module' }, { name: 'Parameters', path: 'attributes.parameters', + description: 'All the parameters that the module accepts' }, { name: 'Commands', path: 'attributes.commands', + description: 'Commands that the module provides' } ] @@ -230,82 +280,102 @@ const thread_fields = [ { name: 'Id', path: 'id', + description: 'Thread ID' }, { name: 'Accepts', path: 'attributes.stats.accepts', + description: 'Number of TCP accepts done by this thread' }, { name: 'Reads', path: 'attributes.stats.reads', + description: 'Number of EPOLLIN events' }, { name: 'Writes', path: 'attributes.stats.writes', + description: 'Number of EPOLLOUT events' }, { name: 'Hangups', path: 'attributes.stats.hangups', + description: 'Number of EPOLLHUP and EPOLLRDUP events' }, { name: 'Errors', path: 'attributes.stats.errors', + description: 'Number of EPOLLERR events' }, { name: 'Avg event queue length', path: 'attributes.stats.avg_event_queue_length', + description: 'Average number of events returned by one epoll_wait call' }, { name: 'Max event queue length', path: 'attributes.stats.max_event_queue_length', + description: 'Maximum number of events returned by one epoll_wait call' }, { name: 'Max exec time', path: 'attributes.stats.max_exec_time', + description: 'The longest time spent processing events returned by a epoll_wait call' }, { name: 'Max queue time', path: 'attributes.stats.max_queue_time', + description: 'The longest time an event had to wait before it was processed' }, { name: 'Current FDs', path: 'attributes.stats.current_descriptors', + description: 'Current number of managed file descriptors' }, { name: 'Total FDs', path: 'attributes.stats.total_descriptors', + description: 'Total number of managed file descriptors' }, { name: 'Load (1s)', path: 'attributes.stats.load.last_second', + description: 'Load percentage over the last second' }, { name: 'Load (1m)', path: 'attributes.stats.load.last_minute', + description: 'Load percentage over the last minute' }, { name: 'Load (1h)', path: 'attributes.stats.load.last_hour', + description: 'Load percentage over the last hour' }, { name: 'QC cache size', path: 'attributes.stats.query_classifier_cache.size', + description: 'Query classifier size' }, { name: 'QC cache inserts', path: 'attributes.stats.query_classifier_cache.inserts', + description: 'Number of times a new query was added into the query classification cache' }, { name: 'QC cache hits', path: 'attributes.stats.query_classifier_cache.hits', + description: 'How many times a query classification was found in the query classification cache' }, { name: 'QC cache misses', path: 'attributes.stats.query_classifier_cache.misses', + description: 'How many times a query classification was not found in the query classification cache' }, { name: 'QC cache evictions', path: 'attributes.stats.query_classifier_cache.evictions', + description: 'How many times a query classification result was evicted from the query classification cache' }, ] @@ -313,26 +383,32 @@ const show_maxscale_fields = [ { name: 'Version', path: 'attributes.version', + description: 'MaxScale version' }, { name: 'Commit', path: 'attributes.commit', + description: 'MaxScale commit ID' }, { name: 'Started At', path: 'attributes.started_at', + description: 'Time when MaxScale was started' }, { name: 'Activated At', path: 'attributes.activated_at', + description: 'Time when MaxScale left passive mode' }, { name: 'Uptime', path: 'attributes.uptime', + description: 'Time MaxScale has been running' }, { name: 'Parameters', path: 'attributes.parameters', + description: 'Global MaxScale parameters' } ] @@ -340,14 +416,17 @@ const show_logging_fields = [ { name: 'Current Log File', path: 'attributes.log_file', + description: 'The current log file MaxScale is logging into' }, { name: 'Enabled Log Levels', path: 'attributes.log_priorities', + description: 'List of log levels enabled in MaxScale' }, { name: 'Parameters', path: 'attributes.parameters', + description: 'Logging parameters' } ] @@ -355,14 +434,17 @@ const show_commands_fields = [ { name: 'Command', path: 'id', + description: 'Command name' }, { name: 'Parameters', path: 'attributes.parameters[].type', + description: 'Parameters the command supports' }, { name: 'Descriptions', path: 'attributes.parameters[].description', + description: 'Parameter descriptions' } ] @@ -375,7 +457,7 @@ exports.builder = function(yargs) { return yargs.epilog('Show detailed information about a server. The `Parameters` ' + 'field contains the currently configured parameters for this ' + 'server. See `help alter server` for more details about altering ' + - 'server parameters.') + 'server parameters.' + fieldDescriptions(server_fields)) .usage('Usage: show server ') }, function(argv) { maxctrl(argv, function(host) { @@ -383,7 +465,8 @@ exports.builder = function(yargs) { }) }) .command('servers', 'Show all servers', function(yargs) { - return yargs.epilog('Show detailed information about all servers.') + return yargs.epilog('Show detailed information about all servers.' + + fieldDescriptions(server_fields)) .usage('Usage: show servers') }, function(argv) { maxctrl(argv, function(host) { @@ -394,7 +477,7 @@ exports.builder = function(yargs) { return yargs.epilog('Show detailed information about a service. The `Parameters` ' + 'field contains the currently configured parameters for this ' + 'service. See `help alter service` for more details about altering ' + - 'service parameters.') + 'service parameters.' + fieldDescriptions(service_fields)) .usage('Usage: show service ') }, function(argv) { maxctrl(argv, function(host) { @@ -402,7 +485,8 @@ exports.builder = function(yargs) { }) }) .command('services', 'Show all services', function(yargs) { - return yargs.epilog('Show detailed information about all services.') + return yargs.epilog('Show detailed information about all services.' + + fieldDescriptions(service_fields)) .usage('Usage: show services') }, function(argv) { maxctrl(argv, function(host) { @@ -413,7 +497,7 @@ exports.builder = function(yargs) { return yargs.epilog('Show detailed information about a monitor. The `Parameters` ' + 'field contains the currently configured parameters for this ' + 'monitor. See `help alter monitor` for more details about altering ' + - 'monitor parameters.') + 'monitor parameters.' + fieldDescriptions(monitor_fields)) .usage('Usage: show monitor ') }, function(argv) { maxctrl(argv, function(host) { @@ -421,7 +505,8 @@ exports.builder = function(yargs) { }) }) .command('monitors', 'Show all monitors', function(yargs) { - return yargs.epilog('Show detailed information about all monitors.') + return yargs.epilog('Show detailed information about all monitors.' + + fieldDescriptions(monitor_fields)) .usage('Usage: show monitors') }, function(argv) { maxctrl(argv, function(host) { @@ -435,7 +520,8 @@ exports.builder = function(yargs) { 'ID of a particular session.\n\n' + 'The `Connections` field lists the servers to which ' + 'the session is connected and the `Connection IDs` ' + - 'field lists the IDs for those connections.') + 'field lists the IDs for those connections.' + + fieldDescriptions(session_fields)) .usage('Usage: show session ') }, function(argv) { maxctrl(argv, function(host) { @@ -444,7 +530,8 @@ exports.builder = function(yargs) { }) .command('sessions', 'Show all sessions', function(yargs) { return yargs.epilog('Show detailed information about all sessions. ' + - 'See `help show session` for more details.') + 'See `help show session` for more details.' + + fieldDescriptions(session_fields)) .usage('Usage: show sessions') }, function(argv) { maxctrl(argv, function(host) { @@ -452,7 +539,8 @@ exports.builder = function(yargs) { }) }) .command('filter ', 'Show filter', function(yargs) { - return yargs.epilog('The list of services that use this filter is show in the `Services` field.') + return yargs.epilog('The list of services that use this filter is show in the `Services` field.' + + fieldDescriptions(filter_fields)) .usage('Usage: show filter ') }, function(argv) { maxctrl(argv, function(host) { @@ -460,7 +548,8 @@ exports.builder = function(yargs) { }) }) .command('filters', 'Show all filters', function(yargs) { - return yargs.epilog('Show detailed information of all filters.') + return yargs.epilog('Show detailed information of all filters.' + + fieldDescriptions(filter_fields)) .usage('Usage: show filters') }, function(argv) { maxctrl(argv, function(host) { @@ -469,7 +558,8 @@ exports.builder = function(yargs) { }) .command('module ', 'Show loaded module', function(yargs) { return yargs.epilog('This command shows all available parameters as well as ' + - 'detailed version information of a loaded module.') + 'detailed version information of a loaded module.' + + fieldDescriptions(module_fields)) .usage('Usage: show module ') }, function(argv) { maxctrl(argv, function(host) { @@ -477,7 +567,8 @@ exports.builder = function(yargs) { }) }) .command('modules', 'Show all loaded modules', function(yargs) { - return yargs.epilog('Displays detailed information about all modules.') + return yargs.epilog('Displays detailed information about all modules.' + + fieldDescriptions(module_fields)) .usage('Usage: show modules') }, function(argv) { maxctrl(argv, function(host) { @@ -486,7 +577,7 @@ exports.builder = function(yargs) { }) .command('maxscale', 'Show MaxScale information', function(yargs) { return yargs.epilog('See `help alter maxscale` for more details about altering ' + - 'MaxScale parameters.') + 'MaxScale parameters.' + fieldDescriptions(show_maxscale_fields)) .usage('Usage: show maxscale') }, function(argv) { maxctrl(argv, function(host) { @@ -494,7 +585,8 @@ exports.builder = function(yargs) { }) }) .command('thread ', 'Show thread', function(yargs) { - return yargs.epilog('Show detailed information about a worker thread.') + return yargs.epilog('Show detailed information about a worker thread.' + + fieldDescriptions(thread_fields)) .usage('Usage: show thread ') }, function(argv) { maxctrl(argv, function(host) { @@ -502,7 +594,8 @@ exports.builder = function(yargs) { }) }) .command('threads', 'Show all threads', function(yargs) { - return yargs.epilog('Show detailed information about all worker threads.') + return yargs.epilog('Show detailed information about all worker threads.' + + fieldDescriptions(thread_fields)) .usage('Usage: show threads') }, function(argv) { maxctrl(argv, function(host) { @@ -511,7 +604,7 @@ exports.builder = function(yargs) { }) .command('logging', 'Show MaxScale logging information', function(yargs) { return yargs.epilog('See `help alter logging` for more details about altering ' + - 'logging parameters.') + 'logging parameters.' + fieldDescriptions(show_logging_fields)) .usage('Usage: show logging') }, function(argv) { maxctrl(argv, function(host) { @@ -520,7 +613,7 @@ exports.builder = function(yargs) { }) .command('commands ', 'Show module commands of a module', function(yargs) { return yargs.epilog('This command shows the parameters the command expects with ' + - 'the parameter descriptions.') + 'the parameter descriptions.' + fieldDescriptions(show_commands_fields)) .usage('Usage: show commands ') }, function(argv) { maxctrl(argv, function(host) {