From 0f2f9d48b7dc5c92887ae4ecd56fb16fa64f6df1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Thu, 30 Mar 2017 20:42:17 +0300 Subject: [PATCH] Improve maxadmin help messages The help messages are now more descriptive and have usage information in them. This should help users use the commands without relying on the online documentation. --- server/modules/routing/debugcli/debugcmd.c | 623 ++++++++++++++------- 1 file changed, 418 insertions(+), 205 deletions(-) diff --git a/server/modules/routing/debugcli/debugcmd.c b/server/modules/routing/debugcli/debugcmd.c index f705679cb..abd8355a4 100644 --- a/server/modules/routing/debugcli/debugcmd.c +++ b/server/modules/routing/debugcli/debugcmd.c @@ -131,154 +131,187 @@ struct subcommand showoptions[] = "buffers", 0, dprintAllBuffers, "Show all buffers with backtrace", "Show all buffers with backtrace", - {0, 0, 0} + {0} }, #endif { "dcbs", 0, 0, dprintAllDCBs, "Show all DCBs", - "Show all descriptor control blocks (network connections)", + "Usage: show dcbs", {0} }, { "dbusers", 1, 1, service_print_users, "[deprecated] Show user statistics", - "Show statistics and user names for a service's user table.\n" - "\t\tExample : show dbusers ", - {ARG_TYPE_SERVICE, 0, 0} + "See `show authenticators`", + {ARG_TYPE_SERVICE} }, { "authenticators", 1, 1, service_print_users, - "Show authenticator diagnostics", - "Show authenticator diagnostics for a service.\n" - "\t\tExample : show authenticators ", - {ARG_TYPE_SERVICE, 0, 0} + "Show authenticator diagnostics for a service", + "Usage: show authenticators SERVICE\n" + "\n" + "Parameters:\n" + "SERVICE Service to inspect\n" + "\n" + "Example : show authenticators my-service", + {ARG_TYPE_SERVICE} }, { "epoll", 0, 0, dprintPollStats, - "Show the poll statistics", - "Show the epoll polling system statistics", - {0, 0, 0} + "Show the polling system statistics", + "Usage: show epoll", + {0} }, { "eventstats", 0, 0, dShowEventStats, "Show event queue statistics", - "Show event queue statistics", - {0, 0, 0} + "Usage: show eventstats", + {0} }, { "feedbackreport", 0, 0, moduleShowFeedbackReport, - "Show feedback report", "Show the report of MaxScale loaded modules, suitable for Notification Service", - {0, 0, 0} + "Usage: show feedbackreport", + {0} }, { "filter", 1, 1, dprintFilter, "Show filter details", - "Show details of a filter, the parameter is filter name", - {ARG_TYPE_FILTER, 0, 0} + "Usage: show filter FILTER\n" + "\n" + "Parameters:\n" + "FILTER Filter to show\n" + "\n" + "Example: show filter my-filter", + {ARG_TYPE_FILTER} }, { "filters", 0, 0, dprintAllFilters, "Show all filters", - "Show all filters that were read from the configuration file", - {0, 0, 0} + "Usage: show filters", + {0} }, { "log_throttling", 0, 0, show_log_throttling, - "Show log throttling setting", "Show the current log throttling setting (count, window (ms), suppression (ms))", - {0, 0, 0} + "Usage: show log_throttling", + {0} }, { "modules", 0, 0, dprintAllModules, - "Show loaded modules", "Show all currently loaded modules", - {0, 0, 0} + "Usage: show modules", + {0} }, { "monitor", 1, 1, monitorShow, "Show monitor details", - "Show details about a specific monitor, the parameter is monitor name", - {ARG_TYPE_MONITOR, 0, 0} + "Usage: show monitor MONITOR\n" + "\n" + "Parameters:\n" + "MONITOR Monitor to show\n" + "\n" + "Example: show monitor \"Cluster Monitor\"", + {ARG_TYPE_MONITOR} }, { "monitors", 0, 0, monitorShowAll, "Show all monitors", - "Show all the monitors", - {0, 0, 0} + "Usage: show monitors", + {0} }, { "persistent", 1, 1, dprintPersistentDCBs, - "Show persistent connection pool", - "Show persistent pool for a server, e.g. show persistent dbnode1", - {ARG_TYPE_SERVER, 0, 0} + "Show the persistent connection pool of a server", + "Usage: show persistent SERVER\n" + "\n" + "Parameters:\n" + "SERVER Server to show\n" + "\n" + "Example: show persistent db-server-1", + {ARG_TYPE_SERVER} }, { "server", 1, 1, dprintServer, "Show server details", - "Show details for a server, e.g. show server dbnode1", - {ARG_TYPE_SERVER, 0, 0} + "Usage: show server SERVER\n" + "\n" + "Parameters:\n" + "SERVER Server to show\n" + "\n" + "Example: show server db-server-1", + {ARG_TYPE_SERVER} }, { "servers", 0, 0, dprintAllServers, "Show all servers", - "Show all configured servers", - {0, 0, 0} + "Usage: show servers", + {0} }, { "serversjson", 0, 0, dprintAllServersJson, "Show all servers in JSON", - "Show all configured servers in JSON format", - {0, 0, 0} + "Usage: show serversjson", + {0} }, { "services", 0, 0, dprintAllServices, - "Show all service", "Show all configured services in MaxScale", - {0, 0, 0} + "Usage: show services", + {0} }, { "service", 1, 1, dprintService, - "Show service details", - "Show a single service in MaxScale, the parameter is the service name", - {ARG_TYPE_SERVICE, 0, 0} + "Show a single service in MaxScale", + "Usage: show service SERVICE\n" + "\n" + "Parameters:\n" + "SERVICE Service to show\n" + "\n" + "Example: show service my-service", + {ARG_TYPE_SERVICE} }, { "session", 1, 1, dprintSession, "Show session details", - "Show a single session in MaxScale, e.g. show session 5", - {ARG_TYPE_SESSION, 0, 0} + "Usage: show session SESSION\n" + "\n" + "Parameters:\n" + "SESSION Session ID of the session to show\n" + "\n" + "Example: show session 5", + {ARG_TYPE_SESSION} }, { "sessions", 0, 0, dprintAllSessions, - "Show all sessions", "Show all active sessions in MaxScale", - {0, 0, 0} + "Usage: show sessions", + {0} }, { "tasks", 0, 0, hkshow_tasks, - "Show housekeeper tasks", "Show all active housekeeper tasks in MaxScale", - {0, 0, 0} + "Usage: show tasks", + {0} }, { "threads", 0, 0, dShowThreads, - "Show workter thread status", "Show the status of the worker threads in MaxScale", - {0, 0, 0} + "Usage: show threads", + {0} }, { "users", 0, 0, telnetdShowUsers, "Show enabled Linux accounts", - "Show all maxadmin enabled Linux accounts and created maxadmin users", - {0, 0, 0} + "Usage: show users", + {0} }, { "version", 0, 0, showVersion, - "Show MaxScale version", "Show the MaxScale version number", - {0, 0, 0} + "Usage: show version", + {0} }, { EMPTY_OPTION} }; @@ -342,71 +375,74 @@ struct subcommand listoptions[] = { { "clients", 0, 0, dListClients, - "List all clients", "List all the client connections to MaxScale", - {0, 0, 0} + "Usage: list clients", + {0} }, { "dcbs", 0, 0, dListDCBs, - "List all DCBs", - "List all the DCBs active within MaxScale", - {0, 0, 0} + "List all active connections within MaxScale", + "Usage: list dcbs", + {0} }, { "filters", 0, 0, dListFilters, "List all filters", - "List all the filters defined within MaxScale", - {0, 0, 0} + "Usage: list filters", + {0} }, { "listeners", 0, 0, dListListeners, "List all listeners", - "List all the listeners defined within MaxScale", - {0, 0, 0} + "Usage: list listeners", + {0} }, { "modules", 0, 0, dprintAllModules, "List all currently loaded modules", - "List all currently loaded modules", - {0, 0, 0} + "Usage: list modules", + {0} }, { "monitors", 0, 0, monitorList, "List all monitors", - "List all monitors", - {0, 0, 0} + "Usage: list monitors", + {0} }, { "services", 0, 0, dListServices, - "List all the services", - "List all the services defined within MaxScale", - {0, 0, 0} + "List all services", + "Usage: list services", + {0} }, { "servers", 0, 0, dListServers, "List all servers", - "List all the servers defined within MaxScale", - {0, 0, 0} + "Usage: list servers", + {0} }, { "sessions", 0, 0, dListSessions, - "List all sessions", "List all the active sessions within MaxScale", - {0, 0, 0} + "Usage: list sessions", + {0} }, { "threads", 0, 0, dShowThreads, - "List polling threads", "List the status of the polling threads in MaxScale", - {0, 0, 0} + "Usage: list threads", + {0} }, { "commands", 0, 2, dListCommands, "List registered commands", - "Usage list commands [MODULE] [COMMAND]\n\n" + "Usage: list commands [MODULE] [COMMAND]\n" + "\n" "Parameters:\n" "MODULE Regular expressions for filtering module names\n" - "COMMAND Regular expressions for filtering module command names\n", + "COMMAND Regular expressions for filtering module command names\n" + "\n" + "Example: list commands my-module my-command", {ARG_TYPE_STRING, ARG_TYPE_STRING} }, { EMPTY_OPTION} @@ -442,32 +478,48 @@ struct subcommand shutdownoptions[] = "maxscale", 0, 0, shutdown_server, - "Shutdown MaxScale", "Initiate a controlled shutdown of MaxScale", - {0, 0, 0} + "Usage: shutdown maxscale", + {0} }, { "monitor", 1, 1, shutdown_monitor, - "Shutdown a monitor", - "E.g. shutdown monitor db-cluster-monitor", - {ARG_TYPE_MONITOR, 0, 0} + "Stop a monitor", + "Usage: shutdown monitor MONITOR\n" + "\n" + "Parameters:\n" + "MONITOR Monitor to stop\n" + "\n" + "Example: shutdown monitor db-cluster-monitor", + {ARG_TYPE_MONITOR} }, { "service", 1, 1, shutdown_service, "Stop a service", - "E.g. shutdown service \"Sales Database\"", - {ARG_TYPE_SERVICE, 0, 0} + "Usage: shutdown service SERVICE\n" + "\n" + "Parameters:\n" + "SERVICE Service to stop\n" + "\n" + "Example: shutdown service \"Sales Database\"", + {ARG_TYPE_SERVICE} }, { "listener", 2, 2, shutdown_listener, "Stop a listener", - "E.g. shutdown listener \"RW Service\" \"RW Listener\"", + "Usage: shutdown listener SERVICE LISTENER\n" + "\n" + "Parameters:\n" + "SERVICE Service where LISTENER points to\n" + "LISTENER The listener to stop\n" + "\n" + "Example: shutdown listener \"RW Service\" \"RW Listener\"", {ARG_TYPE_SERVICE, ARG_TYPE_STRING} }, { @@ -495,8 +547,8 @@ struct subcommand syncoptions[] = 0, 0, sync_logs, "Flush log files to disk", - "Flush log files to disk", - {0, 0, 0} + "Usage: flush logs", + {0} }, { EMPTY_OPTION @@ -527,19 +579,34 @@ struct subcommand restartoptions[] = { "monitor", 1, 1, restart_monitor, "Restart a monitor", - "E.g. restart monitor db-cluster-monitor", - {ARG_TYPE_MONITOR, 0, 0} + "Usage: restart monitor NAME\n" + "\n" + "Parameters:\n" + "NAME Monitor to restart\n" + "\n" + "Example: restart monitor db-cluster-monitor", + {ARG_TYPE_MONITOR} }, { "service", 1, 1, restart_service, "Restart a service", - "E.g. restart service \"Sales Database\"", - {ARG_TYPE_SERVICE, 0, 0} + "Usage: restart service NAME\n" + "\n" + "Parameters:\n" + "NAME Service to restart\n" + "\n" + "Example: restart service \"Sales Database\"", + {ARG_TYPE_SERVICE} }, { "listener", 2, 2, restart_listener, "Restart a listener", - "E.g. restart listener \"RW Service\" \"RW Listener\"", + "Usage: restart listener NAME\n" + "\n" + "Parameters:\n" + "NAME Listener to restart\n" + "\n" + "Example: restart listener \"RW Service\" \"RW Listener\"", {ARG_TYPE_SERVICE, ARG_TYPE_STRING} }, { EMPTY_OPTION } @@ -557,25 +624,52 @@ struct subcommand setoptions[] = { "server", 2, 2, set_server, "Set the status of a server", - "Set the status of a server. E.g. set server dbnode4 master", - {ARG_TYPE_SERVER, ARG_TYPE_STRING, 0} + "Usage: set server NAME STATUS\n" + "\n" + "Parameters:\n" + "NAME Server name\n" + "STATUS The status to set\n" + "\n" + "Example: set server dbnode4 master", + {ARG_TYPE_SERVER, ARG_TYPE_STRING} }, { "pollsleep", 1, 1, set_pollsleep, "Set poll sleep period", - "Set the maximum poll sleep period in milliseconds", - {ARG_TYPE_NUMERIC, 0, 0} + "Usage: set pollsleep VALUE\n" + "\n" + "Parameters:\n" + "VALUE Poll sleep in milliseconds\n" + "\n" + "Sets the maximum poll sleep period in milliseconds\n" + "\n" + "Example: set pollsleep 100", + {ARG_TYPE_NUMERIC} }, { "nbpolls", 1, 1, set_nbpoll, "Set non-blocking polls", - "Set the number of non-blocking polls", - {ARG_TYPE_NUMERIC, 0, 0} + "Usage: set nbpolls VALUE\n" + "\n" + "Parameters:\n" + "VALUE Number of non-blocking polls\n" + "\n" + "Sets the number of non-blocking polls\n" + "\n" + "Example: set nbpolls 5", + {ARG_TYPE_NUMERIC} }, { "log_throttling", 3, 3, set_log_throttling, - "Set log throttling", "Set the log throttling configuration", + "Usage: set log_throttling COUNT WINDOW SUPPRESS\n" + "\n" + "Parameters:\n" + "COUNT Number of messages to log before throttling\n" + "WINDOW The time window in milliseconds where COUNT messages can be logged\n" + "SUPPRESS The log suppression in milliseconds once COUNT messages have been logged\n" + "\n" + "Example: set log_throttling 5 1000 25000", {ARG_TYPE_NUMERIC, ARG_TYPE_NUMERIC, ARG_TYPE_NUMERIC} }, { EMPTY_OPTION } @@ -590,8 +684,14 @@ struct subcommand clearoptions[] = { "server", 2, 2, clear_server, "Clear server status", - "Clear the status of a server. E.g. clear server dbnode2 master", - {ARG_TYPE_SERVER, ARG_TYPE_STRING, 0} + "Usage: clear server NAME STATUS\n" + "\n" + "Parameters:\n" + "NAME Server name\n" + "STATUS The status to clear\n" + "\n" + "Example: clear server dbnode2 master", + {ARG_TYPE_SERVER, ARG_TYPE_STRING} }, { EMPTY_OPTION } }; @@ -607,14 +707,19 @@ struct subcommand reloadoptions[] = { "config", 0, 0, reload_config, "Reload the configuration", - "Reload the configuration data for MaxScale", - {0, 0, 0} + "Usage: reload config", + {0} }, { "dbusers", 1, 1, reload_dbusers, - "Reload users table", - "Reload the users for a service. E.g. reload dbusers \"splitter service\"", - {ARG_TYPE_SERVICE, 0, 0} + "Reload the database users for a service", + "Usage: reload dbusers SERVICE\n" + "\n" + "Parameters:\n" + "SERVICE Reload database users for this service\n" + "\n" + "Example: reload dbusers \"splitter service\"", + {ARG_TYPE_SERVICE} }, { EMPTY_OPTION } }; @@ -644,60 +749,71 @@ struct subcommand enableoptions[] = 1, 1, enable_log_priority, "Enable a logging priority", - "Enable a logging priority for MaxScale, parameters must be one of " - "'err', 'warning', 'notice', 'info' or 'debug'. " - "E.g.: 'enable log-priority info'.", - {ARG_TYPE_STRING, 0, 0} + "Usage: enable log-priority PRIORITY\n" + "\n" + "Parameters:" + "PRIORITY One of 'err', 'warning', 'notice','info' or 'debug'\n" + "\n" + "Example: enable log-priority info", + {ARG_TYPE_STRING} }, { "sessionlog-priority", 2, 2, enable_sess_log_priority, "[Deprecated] Enable a logging priority for a session", - "Usage: enable sessionlog-priority [err | warning | notice | info | debug] " - "\t E.g. enable sessionlog-priority info 123.", - {ARG_TYPE_STRING, ARG_TYPE_STRING, 0} + "This command is deprecated", + {ARG_TYPE_STRING, ARG_TYPE_STRING} }, { "root", 1, 1, enable_service_root, - "Enable root user access", - "Enable root access to a service, pass a service name to enable root access", - {ARG_TYPE_SERVICE, 0, 0} + "Enable root user access to a service", + "Usage: enable root SERVICE\n" + "\n" + "Parameters:\n" + "SERVICE Service where root user is enabled\n" + "\n" + "Example: enable root my-service", + {ARG_TYPE_SERVICE} }, { "feedback", 0, 0, enable_feedback_action, - "Enable MaxScale feedback", - "Enable MaxScale modules list sending via http to notification service", - {0, 0, 0} + "Enable MaxScale feedback to notification service", + "Usage: enable feedback", + {0} }, { "syslog", 0, 0, enable_syslog, - "Enable syslog", "Enable syslog logging", - {0, 0, 0} + "Usage: enable syslog", + {0} }, { "maxlog", 0, 0, enable_maxlog, "Enable MaxScale logging", - "Enable MaxScale logging", - {0, 0, 0} + "Usage: enable maxlog", + {0} }, { "account", 1, 1, enable_account, - "Activate a Linux user", - "Enable maxadmin usage for a Linux user. E.g.:\n" - " MaxScale> enable account alice", - {ARG_TYPE_STRING, 0, 0} + "Activate a Linux user account for MaxAdmin use", + "Usage: enable account USER\n" + "\n" + "Parameters:\n" + "USER The user account to enable\n" + "\n" + "Example: enable account alice", + {ARG_TYPE_STRING} }, { EMPTY_OPTION @@ -716,59 +832,71 @@ struct subcommand disableoptions[] = 1, 1, disable_log_priority, "Disable a logging priority", - "Options 'err' | 'warning' | 'notice' | 'info' | 'debug'. " - "E.g.: 'disable log-priority info'", - {ARG_TYPE_STRING, 0, 0} + "Usage: disable log-priority PRIORITY\n" + "\n" + "Parameters:" + "PRIORITY One of 'err', 'warning', 'notice','info' or 'debug'\n" + "\n" + "Example: disable log-priority info", + {ARG_TYPE_STRING} }, { "sessionlog-priority", 2, 2, disable_sess_log_priority, "[Deprecated] Disable a logging priority for a particular session", - "Usage: disable sessionlog-priority [err | warning | notice | info | debug] " - "\t E.g. enable sessionlog-priority info 123", - {ARG_TYPE_STRING, ARG_TYPE_STRING, 0} + "This command is deprecated", + {ARG_TYPE_STRING, ARG_TYPE_STRING} }, { "root", 1, 1, disable_service_root, "Disable root access", - "Disable root access to a service", - {ARG_TYPE_SERVICE, 0, 0} + "Usage: disable root SERVICE\n" + "\n" + "Parameters:\n" + "SERVICE Service where root user is disabled\n" + "\n" + "Example: disable root my-service", + {ARG_TYPE_SERVICE} }, { "feedback", 0, 0, disable_feedback_action, - "Disable feedback", - "Disable MaxScale modules list sending via http to notification service", - {0, 0, 0} + "Disable MaxScale feedback to notification service", + "Usage: disable feedback", + {0} }, { "syslog", 0, 0, disable_syslog, - "Disable syslog", "Disable syslog logging", - {0, 0, 0} + "Usage: disable syslog", + {0} }, { "maxlog", 0, 0, disable_maxlog, "Disable MaxScale logging", - "Disable MaxScale logging", - {0, 0, 0} + "Usage: disable maxlog", + {0} }, { "account", 1, 1, disable_account, "Disable Linux user", - "Disable maxadmin usage for Linux user. E.g.:\n" - " MaxScale> disable account alice", - {ARG_TYPE_STRING, 0, 0} + "Usage: disable account USER\n" + "\n" + "Parameters:\n" + "USER The user account to disable\n" + "\n" + "Example: disable account alice", + {ARG_TYPE_STRING} }, { EMPTY_OPTION @@ -805,18 +933,28 @@ struct subcommand addoptions[] = { { "user", 2, 2, telnetdAddUser, - "Add account for maxadmin", - "Add insecure account for using maxadmin over the network. E.g.:\n" - " MaxScale> add user bob somepass", - {ARG_TYPE_STRING, ARG_TYPE_STRING, 0} + "Add insecure account for using maxadmin over the network", + "Usage: add user USER PASSWORD\n" + "\n" + "Parameters:\n" + "USER User to add\n" + "PASSWORD Password for the user\n" + "\n" + "Example: add user bob somepass", + {ARG_TYPE_STRING, ARG_TYPE_STRING} }, { "server", 2, 12, cmd_AddServer, "Add a new server to a service", - "Usage: add server SERVER TARGET...\n\n" - "The TARGET must be a list of service and monitor names\n" - "e.g. add server my-db my-service 'Cluster Monitor'\n" - "A server can be assigned to a maximum of 11 objects in one command", + "Usage: add server SERVER TARGET...\n" + "\n" + "Parameters:\n" + "SERVER The server that is added to TARGET\n" + "TARGET List of service and/or monitor names separated by spaces\n" + "\n" + "A server can be assigned to a maximum of 11 objects in one command\n" + "\n" + "Example: add server my-db my-service \"Cluster Monitor\"", { ARG_TYPE_SERVER, ARG_TYPE_STRING, ARG_TYPE_STRING, ARG_TYPE_STRING, ARG_TYPE_STRING, ARG_TYPE_STRING, ARG_TYPE_STRING, ARG_TYPE_STRING, @@ -858,18 +996,28 @@ struct subcommand removeoptions[] = "user", 2, 2, telnetdRemoveUser, - "Remove account from maxadmin", - "Remove account for using maxadmin over the network. E.g.:\n" - " MaxAdmin> remove user bob somepass", + "Remove account for using maxadmin over the network", + "Usage: remove user USER PASSWORD\n" + "\n" + "Parameters:\n" + "USER User to remove\n" + "PASSWORD Password of the user\n" + "\n" + "Example: remove user bob somepass", {ARG_TYPE_STRING, ARG_TYPE_STRING} }, { "server", 2, 12, cmd_RemoveServer, "Remove a server from a service or a monitor", - "Usage: remove server SERVER TARGET...\n\n" - "The TARGET must be a list of service and monitor names\n" - "e.g. remove server my-db my-service 'Cluster Monitor'\n" - "A server can be removed from a maximum of 11 objects in one command", + "Usage: remove server SERVER TARGET...\n" + "\n" + "Parameters:\n" + "SERVER The server that is removed from TARGET\n" + "TARGET List of service and/or monitor names separated by spaces\n" + "\n" + "A server can be removed from a maximum of 11 objects in one command\n" + "\n" + "Example: remove server my-db my-service \"Cluster Monitor\"", { ARG_TYPE_SERVER, ARG_TYPE_STRING, ARG_TYPE_STRING, ARG_TYPE_STRING, ARG_TYPE_STRING, ARG_TYPE_STRING, ARG_TYPE_STRING, ARG_TYPE_STRING, @@ -956,17 +1104,17 @@ struct subcommand flushoptions[] = "log", 1, 1, flushlog, - "Flush log files", - "Flush the content of a log file, close that log, rename it and open a new log file", - {ARG_TYPE_STRING, 0, 0} + "Flush the content of a log file and reopen it", + "Usage: flush log", + {ARG_TYPE_STRING} }, { "logs", 0, 0, flushlogs, - "Flush log files", - "Flush the content of all log files, close those logs, rename them and open a new log files", - {0, 0, 0} + "Flush the content of a log file and reopen it", + "Usage: flush logs", + {0} }, { EMPTY_OPTION @@ -1049,15 +1197,19 @@ struct subcommand createoptions[] = { "server", 2, 6, createServer, "Create a new server", - "Usage: create server NAME HOST [PORT] [PROTOCOL] [AUTHENTICATOR] [OPTIONS]\n\n" - "Create a new server from the following parameters.\n\n" + "Usage: create server NAME HOST [PORT] [PROTOCOL] [AUTHENTICATOR] [OPTIONS]\n" + "\n" + "Parameters:\n" "NAME Server name\n" "HOST Server host address\n" "PORT Server port (default 3306)\n" "PROTOCOL Server protocol (default MySQLBackend)\n" "AUTHENTICATOR Authenticator module name (default MySQLAuth)\n" - "OPTIONS Options for the authenticator module\n\n" - "The first two parameters are required, the others are optional.\n", + "OPTIONS Comma separated list of options for the authenticator\n" + "\n" + "The first two parameters are required, the others are optional.\n" + "\n" + "Example: create server my-db-1 192.168.0.102 3306", { ARG_TYPE_STRING, ARG_TYPE_STRING, ARG_TYPE_STRING, ARG_TYPE_STRING, ARG_TYPE_STRING, ARG_TYPE_STRING @@ -1067,8 +1219,9 @@ struct subcommand createoptions[] = "listener", 2, 12, createListener, "Create a new listener for a service", "Usage: create listener SERVICE NAME [HOST] [PORT] [PROTOCOL] [AUTHENTICATOR] [OPTIONS]\n" - " [SSL_KEY] [SSL_CERT] [SSL_CA] [SSL_VERSION] [SSL_VERIFY_DEPTH]\n\n" - "Create a new server from the following parameters.\n\n" + " [SSL_KEY] [SSL_CERT] [SSL_CA] [SSL_VERSION] [SSL_VERIFY_DEPTH]\n" + "\n" + "Parameters\n" "SERVICE Service where this listener is added\n" "NAME Listener name\n" "HOST Listener host address (default [::])\n" @@ -1080,10 +1233,13 @@ struct subcommand createoptions[] = "SSL_CERT Path to SSL certificate\n" "SSL_CA Path to CA certificate\n" "SSL_VERSION SSL version (default MAX)\n" - "SSL_VERIFY_DEPTH Certificate verification depth\n\n" + "SSL_VERIFY_DEPTH Certificate verification depth\n" + "\n" "The first two parameters are required, the others are optional.\n" "Any of the optional parameters can also have the value 'default'\n" - "which will be replaced with the default value.\n", + "which will be replaced with the default value.\n" + "\n" + "Example: create listener my-service my-new-listener 192.168.0.101 4006", { ARG_TYPE_SERVICE, ARG_TYPE_STRING, ARG_TYPE_STRING, ARG_TYPE_STRING, ARG_TYPE_STRING, ARG_TYPE_STRING, ARG_TYPE_STRING, ARG_TYPE_STRING, @@ -1093,9 +1249,13 @@ struct subcommand createoptions[] = { "monitor", 2, 2, createMonitor, "Create a new monitor", - "Usage: create monitor NAME MODULE\n\n" + "Usage: create monitor NAME MODULE\n" + "\n" + "Parameters:\n" "NAME Monitor name\n" - "MODULE Monitor module\n", + "MODULE Monitor module\n" + "\n" + "Example: create monitor my-monitor mysqlmon", { ARG_TYPE_STRING, ARG_TYPE_STRING } @@ -1156,19 +1316,38 @@ struct subcommand destroyoptions[] = { "server", 1, 1, destroyServer, "Destroy a server", - "Usage: destroy server NAME", + "Usage: destroy server NAME\n" + "\n" + "Parameters:\n" + "NAME Server to destroy\n" + "\n" + "Example: destroy server my-db-1", {ARG_TYPE_SERVER} }, { "listener", 2, 2, destroyListener, "Destroy a listener", - "Usage: destroy listener SERVICE NAME", + "Usage: destroy listener SERVICE NAME\n" + "\n" + "Parameters:\n" + "NAME Listener to destroy\n" + "\n" + "The listener is stopped and it will be removed on the next restart of MaxScale\n" + "\n" + "Example: destroy listener my-listener", {ARG_TYPE_SERVICE, ARG_TYPE_STRING} }, { "monitor", 1, 1, destroyMonitor, "Destroy a monitor", - "Usage: destroy monitor NAME", + "Usage: destroy monitor NAME\n" + "\n" + "Parameters:\n" + "NAME Monitor to destroy\n" + "\n" + "The monitor is stopped and it will be removed on the next restart of MaxScale\n" + "\n" + "Example: destroy monitor my-monitor", {ARG_TYPE_MONITOR} }, { @@ -1266,8 +1445,8 @@ static void alterServer(DCB *dcb, SERVER *server, char *v1, char *v2, char *v3, } static void alterMonitor(DCB *dcb, MXS_MONITOR *monitor, char *v1, char *v2, char *v3, - char *v4, char *v5, char *v6, char *v7, char *v8, char *v9, - char *v10, char *v11) + char *v4, char *v5, char *v6, char *v7, char *v8, char *v9, + char *v10, char *v11) { char *values[11] = {v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11}; const int items = sizeof(values) / sizeof(values[0]); @@ -1306,8 +1485,14 @@ struct subcommand alteroptions[] = { "server", 2, 12, alterServer, "Alter server parameters", - "Usage: alter server NAME KEY=VALUE ...\n\n" - "This will alter an existing parameter of a server. The accepted values for KEY are:\n\n" + "Usage: alter server NAME KEY=VALUE ...\n" + "\n" + "Parameters:\n" + "NAME Server name\n" + "KEY=VALUE List of `key=value` pairs separated by spaces\n" + "\n" + "This will alter an existing parameter of a server. The accepted values for KEY are:\n" + "\n" "address Server address\n" "port Server port\n" "monuser Monitor user for this server\n" @@ -1317,9 +1502,12 @@ struct subcommand alteroptions[] = "ssl_cert Path to SSL certificate\n" "ssl_ca_cert Path to SSL CA certificate\n" "ssl_version SSL version\n" - "ssl_cert_verify_depth Certificate verification depth\n\n" + "ssl_cert_verify_depth Certificate verification depth\n" + "\n" "To configure SSL for a newly created server, the 'ssl', 'ssl_cert',\n" - "'ssl_key' and 'ssl_ca_cert' parameters must be given at the same time.\n", + "'ssl_key' and 'ssl_ca_cert' parameters must be given at the same time.\n" + "\n" + "Example: alter server my-db-1 address=192.168.0.202 port=3307", { ARG_TYPE_SERVER, ARG_TYPE_STRING, ARG_TYPE_STRING, ARG_TYPE_STRING, ARG_TYPE_STRING, ARG_TYPE_STRING, ARG_TYPE_STRING, ARG_TYPE_STRING, @@ -1329,9 +1517,24 @@ struct subcommand alteroptions[] = { "monitor", 2, 12, alterMonitor, "Alter monitor parameters", - "Usage: alter monitor NAME KEY=VALUE ...\n\n" + "Usage: alter monitor NAME KEY=VALUE ...\n" + "\n" + "Parameters:\n" + "NAME Monitor name\n" + "KEY=VALUE List of `key=value` pairs separated by spaces\n" + "\n" + "All monitors support the following values for KEY:\n" + "user Username used when connecting to servers\n" + "password Password used when connecting to servers\n" + "monitor_interval Monitoring interval in milliseconds\n" + "backend_connect_timeout Server coneection timeout in seconds\n" + "backend_write_timeout Server write timeout in seconds\n" + "backend_read_timeout Server read timeout in seconds\n" + "\n" "This will alter an existing parameter of a monitor. To remove parameters,\n" - "pass an empty value for a key e.g. 'maxadmin alter monitor my-monitor my-key='", + "pass an empty value for a key e.g. 'maxadmin alter monitor my-monitor my-key='\n" + "\n" + "Example: alter monitor my-monitor user=maxuser password=maxpwd", { ARG_TYPE_MONITOR, ARG_TYPE_STRING, ARG_TYPE_STRING, ARG_TYPE_STRING, ARG_TYPE_STRING, ARG_TYPE_STRING, ARG_TYPE_STRING, ARG_TYPE_STRING, @@ -1404,8 +1607,16 @@ struct subcommand calloptions[] = { "command", 2, 12, callModuleCommand, "Call module command", - "Usage: call command NAMESPACE COMMAND ARGS...\n\n" - "To list all registered commands, run 'list commands'.\n", + "Usage: call command MODULE COMMAND ARGS...\n" + "\n" + "Parameters:\n" + "MODULE The module name\n" + "COMMAND The command to call\n" + "ARGS... Arguments for the command\n" + "\n" + "To list all registered commands, run 'list commands'.\n" + "\n" + "Example: call command my-module my-command hello world!", { ARG_TYPE_STRING, ARG_TYPE_STRING, ARG_TYPE_STRING, ARG_TYPE_STRING, ARG_TYPE_STRING, ARG_TYPE_STRING, ARG_TYPE_STRING, ARG_TYPE_STRING, @@ -1520,6 +1731,9 @@ static void free_arg(int arg_type, void *value) static SPINLOCK debugcmd_lock = SPINLOCK_INIT; +static const char item_separator[] = + "----------------------------------------------------------------------------\n"; + /** * We have a complete line from the user, lookup the commands and execute them * @@ -1621,22 +1835,16 @@ execute_cmd(CLI_SESSION *cli) dcb_printf(dcb, "Available commands:\n"); for (i = 0; cmds[i].cmd; i++) { - if (cmds[i].options[1].arg1 == NULL) + dcb_printf(dcb, "%s:\n", cmds[i].cmd); + + for (j = 0; cmds[i].options[j].arg1; j++) { - dcb_printf(dcb, " %s %s\n", cmds[i].cmd, cmds[i].options[0].arg1); - } - else - { - dcb_printf(dcb, " %s [", cmds[i].cmd); - for (j = 0; cmds[i].options[j].arg1; j++) - { - dcb_printf(dcb, "%s%s", cmds[i].options[j].arg1, - cmds[i].options[j + 1].arg1 ? "|" : ""); - } - dcb_printf(dcb, "]\n"); + dcb_printf(dcb, " %s %s - %s\n", cmds[i].cmd, + cmds[i].options[j].arg1, cmds[i].options[j].help); } + dcb_printf(dcb, "\n"); } - dcb_printf(dcb, "\nType help command to see details of each command.\n"); + dcb_printf(dcb, "\nType `help COMMAND` to see details of each command.\n"); dcb_printf(dcb, "Where commands require names as arguments and these names contain\n"); dcb_printf(dcb, "whitespace either the \\ character may be used to escape the whitespace\n"); dcb_printf(dcb, "or the name may be enclosed in double quotes \".\n\n"); @@ -1648,10 +1856,15 @@ execute_cmd(CLI_SESSION *cli) if (!strcasecmp(args[1], cmds[i].cmd)) { found = 1; - dcb_printf(dcb, "Available options to the %s command:\n", args[1]); + dcb_printf(dcb, "Available options to the `%s` command:\n", cmds[i].cmd); for (j = 0; cmds[i].options[j].arg1; j++) { - dcb_printf(dcb, "'%s' - %s\n\n%s\n\n", cmds[i].options[j].arg1, + if (j != 0) + { + dcb_printf(dcb, item_separator); + } + + dcb_printf(dcb, "\n%s %s - %s\n\n%s\n\n", cmds[i].cmd, cmds[i].options[j].arg1, cmds[i].options[j].help, cmds[i].options[j].devhelp); }