From 9b7c9b073564d1c853e871496e9ce93f02cd05e9 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 10 Mar 2009 15:22:52 -0700 Subject: [PATCH] usage --- src/ceph.cc | 23 +++++++++++++++-------- src/cmds.cc | 10 ++++++---- src/cmon.cc | 10 ++++------ src/config.cc | 25 +++++++++++++++++++++++++ src/config.h | 3 +++ src/cosd.cc | 4 +--- 6 files changed, 54 insertions(+), 21 deletions(-) diff --git a/src/ceph.cc b/src/ceph.cc index f4f8a3f5e89..7a04e0866d4 100644 --- a/src/ceph.cc +++ b/src/ceph.cc @@ -377,18 +377,21 @@ int do_command(vector& cmd, bufferlist& bl, string& rs, bufferlist& rbl) void usage() { - cerr << "usage: ceph [options] monhost] command" << std::endl; - cerr << "Options:" << std::endl; - cerr << " -m monhost -- specify monitor hostname or ip" << std::endl; - cerr << " -i infile -- specify input file" << std::endl; - cerr << " -o outfile -- specify output file" << std::endl; - cerr << " -w or --watch -- watch mds, osd, pg status (push)" << std::endl; - cerr << " -p or --poll -- watch mds, osd, pg status (poll)" << std::endl; + cerr << "usage: ceph [options] [commands]" << std::endl; + cerr << "If no commands are specified, enter interactive mode.\n"; cerr << "Commands:" << std::endl; cerr << " stop -- cleanly shut down file system" << std::endl << " (osd|pg|mds) stat -- get monitor subsystem status" << std::endl << " ..." << std::endl; - exit(1); + cerr << "Options:" << std::endl; + cerr << " -i infile\n"; + cerr << " -o outfile\n"; + cerr << " specify input or output file (for certain commands)\n"; + cerr << " -w or --watch\n"; + cerr << " watch mds, osd, pg status changes in real time (push)\n"; + cerr << " -p or --poll\n"; + cerr << " watch mds, osd, pg status changes in real time (poll)\n"; + generic_client_usage(); } @@ -549,6 +552,10 @@ int main(int argc, const char **argv, const char *envp[]) { } else if (strcmp(args[i], "-p") == 0 || strcmp(args[i], "--poll") == 0) { watch = 1; + } else if (args[i][0] == '-') { + if (strcmp(args[i], "-h")) + cerr << "unrecognized option " << args[i] << std::endl; + usage(); } else nargs.push_back(args[i]); } diff --git a/src/cmds.cc b/src/cmds.cc index 59ba9659624..f55c328f15f 100644 --- a/src/cmds.cc +++ b/src/cmds.cc @@ -35,10 +35,12 @@ using namespace std; void usage() { - cerr << "usage: cmds [flags] [--mds rank] [--shadow rank]" << std::endl; - cerr << " --debug_mds n debug MDS level (e.g. 10)" << std::endl; - cerr << " --debug_ms n debug messaging level (e.g. 1)" << std::endl; - exit(1); + cerr << "usage: cmds [flags] [--mds rank] [--shadow rank]\n"; + cerr << " -m monitorip:port\n"; + cerr << " connect to monitor at given address\n"; + cerr << " --debug_mds n\n"; + cerr << " debug MDS level (e.g. 10)\n"; + generic_server_usage(); } int main(int argc, const char **argv) diff --git a/src/cmon.cc b/src/cmon.cc index 09c85646549..468a08e3cf4 100644 --- a/src/cmon.cc +++ b/src/cmon.cc @@ -36,12 +36,10 @@ using namespace std; void usage() { - cerr << "usage: ./cmon [flags] " << std::endl; - cerr << " -d daemonize" << std::endl; - cerr << " -o log output to dir/mon#" << std::endl; - cerr << " --debug_mon n debug monitor level (e.g. 10)" << std::endl; - cerr << " --debug_ms n debug messaging level (e.g. 1)" << std::endl; - exit(1); + cerr << "usage: cmon [flags] " << std::endl; + cerr << " --debug_mon n\n"; + cerr << " debug monitor level (e.g. 10)\n"; + generic_server_usage(); } int main(int argc, const char **argv) diff --git a/src/config.cc b/src/config.cc index 2390c093675..7cf9f47efc1 100644 --- a/src/config.cc +++ b/src/config.cc @@ -800,6 +800,31 @@ void configure_client_mode() g_conf.log_to_stdout = true; } +void generic_usage() +{ + cerr << " -C cluster.conf\n"; + cerr << " get monitor IP(s) from given conf (instead of /etc/ceph/cluster.conf)\n"; + cerr << " -c ceph.conf\n"; + cerr << " get runtime options from given conf file" << std::endl; +} + +void generic_server_usage() +{ + cerr << " --debug_ms N\n"; + cerr << " set message debug level (e.g. 1)\n"; + cerr << " -D debug (no fork, log to stdout)\n"; + cerr << " -f foreground (no fork, log to file)\n"; + generic_usage(); + exit(1); +} +void generic_client_usage() +{ + generic_usage(); + cerr << " -d daemonize (detach, fork, log to file)\n"; + cerr << " -f foreground (no fork, log to file)" << std::endl; + exit(1); +} + void parse_config_options(std::vector& args) { int opt_len = sizeof(config_optionsp)/sizeof(config_option); diff --git a/src/config.h b/src/config.h index 948ca34e8f8..45be9fa8878 100644 --- a/src/config.h +++ b/src/config.h @@ -361,6 +361,9 @@ extern bool parse_ip_port(const char *s, entity_addr_t& addr, const char **end=0 void configure_daemon_mode(); void configure_client_mode(); +void generic_server_usage(); +void generic_client_usage(); + class ConfFile; void parse_config_file(ConfFile *cf, bool update); diff --git a/src/cosd.cc b/src/cosd.cc index 85ce2e146b9..44ccc6b1dc5 100644 --- a/src/cosd.cc +++ b/src/cosd.cc @@ -37,10 +37,8 @@ using namespace std; void usage() { cerr << "usage: cosd [-j journalfileordev] [-m monitor] [--mkfs_for_osd ]" << std::endl; - cerr << " -d daemonize" << std::endl; cerr << " --debug_osd N set debug level (e.g. 10)" << std::endl; - cerr << " --debug_ms N set message debug level (e.g. 1)" << std::endl; - exit(1); + generic_server_usage(); }