ceph -s分析

本文通过源码跟踪详细分析了Ceph中`ceph -s`命令的工作流程,首先从get_cluster_status函数入手,接着探讨了在Monitor.cc中的实现,然后进入mgrstatmon()->print_summary()函数在PGMap.cc中的作用,该函数负责统计并打印集群的相关指标。
摘要由CSDN通过智能技术生成

1. 源码跟踪

1.1 get_cluster_status

https://github.com/ceph/ceph/blob/2a724a2ff313701fd7f6278ce8ed7f440bb355e0/src/mon/Monitor.cc

ceph -s 会执行get_cluster_status函数, 在函数的最后会调用打印
mgrstatmon()->print_summary函数

void Monitor::get_cluster_status(stringstream &ss, Formatter *f)
{
  if (f)
    f->open_object_section("status");
  if (f) {
    f->dump_stream("fsid") << monmap->get_fsid();
    get_health_status(false, f, nullptr);
    f->dump_unsigned("election_epoch", get_epoch());
    {
      f->open_array_section("quorum");
      for (set<int>::iterator p = quorum.begin(); p != quorum.end(); ++p)
    f->dump_int("rank", *p);
      f->close_section();
      f->open_array_section("quorum_names");
      for (set<int>::iterator p = quorum.begin(); p != quorum.end(); ++p)
    f->dump_string("id", monmap->get_name(*p));
      f->close_section();
    }
    f->open_object_section("monmap");
    monmap->dump(f);
    f->close_section();
    f->open_object_section("osdmap");
    osdmon()->osdmap.print_summary(f, cout, string(12, ' '));
    f->close_section();
    f->open_object_section("pgmap");
    mgrstatmon()->print_summary(f, NULL);
    f->close_section();
    f->open_object_section("fsmap");
    mdsmon()->get_fsmap().print_summary(f, NULL);
    f->close_section();
    f->open_object_section("mgrmap");
    mgrmon()->get_map().print_summary(f, nullptr);
    f->close_section();
    f->dump_object("servicemap", mgrstatmon()->get_service_map());
    f->close_section();
  } else {
    ss << "  cluster:\n";
    ss << "    id:
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值