]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
config: add 'show_config' admin socket command
authorSage Weil <sage@inktank.com>
Tue, 29 May 2012 17:11:43 +0000 (10:11 -0700)
committerSage Weil <sage@inktank.com>
Tue, 29 May 2012 19:07:07 +0000 (12:07 -0700)
Signed-off-by: Sage Weil <sage@inktank.com>
src/common/ceph_context.cc
src/common/config.cc
src/common/config.h

index ddda66795d7b1a87faf425b1f6bce3dd134e9834..dde67aaf663374a46bdaa4e90f0d5e5fca1ec45d 100644 (file)
@@ -160,15 +160,24 @@ public:
 
 void CephContext::do_command(std::string command, bufferlist *out)
 {
-  std::vector<char> v;
-
-  if (command == "perfcounters_dump" || command == "1")
+  if (command == "perfcounters_dump" || command == "1") {
+    std::vector<char> v;
     _perf_counters_collection->write_json_to_buf(v, false);
-  else if (command == "perfcounters_schema" || command == "2")
+    out->append(&v[0], v.size());
+  }
+  else if (command == "perfcounters_schema" || command == "2") {
+    std::vector<char> v;
     _perf_counters_collection->write_json_to_buf(v, true);
-  else 
+    out->append(&v[0], v.size());
+  }
+  else if (command == "show_config") {
+    ostringstream ss;
+    _conf->show_config(ss);
+    out->append(ss.str());
+  }
+  else {
     assert(0 == "registered under wrong command?");    
-  out->append(&v[0], v.size());
+  }
 };
 
 
@@ -200,6 +209,7 @@ CephContext::CephContext(uint32_t module_type_)
   _admin_socket->register_command("1", _admin_hook, "");
   _admin_socket->register_command("perfcounters_schema", _admin_hook, "dump perfcounters schema");
   _admin_socket->register_command("2", _admin_hook, "");
+  _admin_socket->register_command("show_config", _admin_hook, "dump current config settings");
 }
 
 CephContext::~CephContext()
@@ -210,6 +220,7 @@ CephContext::~CephContext()
   _admin_socket->unregister_command("1");
   _admin_socket->unregister_command("perfcounters_schema");
   _admin_socket->unregister_command("2");
+  _admin_socket->unregister_command("show_config");
   delete _admin_hook;
 
   delete _heartbeat_map;
index 49be99284ac9cf4d3c5bd4b4f2891d20db8b7f7b..b5037b7a8e165c1090d53e79ab078c88c1a2f9ca 100644 (file)
@@ -280,6 +280,12 @@ void md_config_t::parse_env()
 }
 
 void md_config_t::show_config(std::ostream& out)
+{
+  Mutex::Locker l(lock);
+  _show_config(out);
+}
+
+void md_config_t::_show_config(std::ostream& out)
 {
   out << "name = " << name << std::endl;
   out << "cluster = " << cluster << std::endl;
@@ -320,7 +326,7 @@ int md_config_t::parse_argv(std::vector<const char*>& args)
     }
     else if (ceph_argparse_flag(args, i, "--show_config", (char*)NULL)) {
       expand_all_meta();
-      show_config(cout);
+      _show_config(cout);
       _exit(0);
     }
     else if (ceph_argparse_witharg(args, i, &val, "--show_config_value", (char*)NULL)) {
index fec3f46c393e35c019017b850f3e6f2bedc9ea49..70731beb9c5707c051873cdba9fdc1f3114bf234 100644 (file)
@@ -140,9 +140,12 @@ public:
   int get_val_from_conf_file(const std::vector <std::string> &sections,
                   const char *key, std::string &out, bool emeta) const;
 
+  /// dump all config values to a stream
   void show_config(std::ostream& out);
 
 private:
+  void _show_config(std::ostream& out);
+
   int parse_option(std::vector<const char*>& args,
                   std::vector<const char*>::iterator& i,
                   std::ostream *oss);