MCPcopy Create free account
hub / github.com/baidu/tera / CollectHardwareInfo

Method CollectHardwareInfo

src/tabletnode/tabletnode_sysinfo.cc:757–777  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

755}
756
757void TabletNodeSysInfo::CollectHardwareInfo() {
758 MutexLock lock(&mutex_);
759 if (!info_.unique()) {
760 SwitchInfo();
761 }
762 assert(info_.unique());
763 std::shared_ptr<CollectorReport> latest_report =
764 CollectorReportPublisher::GetInstance().GetCollectorReport();
765
766 int64_t cpu_usage = latest_report->FindMetricValue(kInstCpuMetricName);
767 info_->set_cpu_usage(static_cast<float>(cpu_usage));
768
769 int64_t mem_usage = latest_report->FindMetricValue(kInstMemMetricName);
770 info_->set_mem_used(mem_usage);
771
772 int64_t net_rx_usage = latest_report->FindMetricValue(kInstNetRXMetricName);
773 info_->set_net_rx(net_rx_usage);
774
775 int64_t net_tx_usage = latest_report->FindMetricValue(kInstNetTXMetricName);
776 info_->set_net_tx(net_tx_usage);
777}
778
779void TabletNodeSysInfo::GetTabletNodeInfo(TabletNodeInfo* info) {
780 MutexLock lock(&mutex_);

Callers 1

RefreshAndDumpSysInfoMethod · 0.80

Calls 2

GetCollectorReportMethod · 0.80
FindMetricValueMethod · 0.80

Tested by

no test coverage detected