MCPcopy Create free account
hub / github.com/NetSys/bess / GetPortStats

Method GetPortStats

core/bessctl.cc:1115–1150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1113 }
1114
1115 Status GetPortStats(ServerContext*, const GetPortStatsRequest* request,
1116 GetPortStatsResponse* response) override {
1117 std::lock_guard<std::recursive_mutex> lock(mutex_);
1118
1119 const auto& it = PortBuilder::all_ports().find(request->name());
1120 if (it == PortBuilder::all_ports().end()) {
1121 return return_with_error(response, ENOENT, "No port '%s' found",
1122 request->name().c_str());
1123 }
1124
1125 ::Port::PortStats stats = it->second->GetPortStats();
1126
1127 response->mutable_inc()->set_packets(stats.inc.packets);
1128 response->mutable_inc()->set_dropped(stats.inc.dropped);
1129 response->mutable_inc()->set_bytes(stats.inc.bytes);
1130 *response->mutable_inc()->mutable_requested_hist() = {
1131 stats.inc.requested_hist.begin(), stats.inc.requested_hist.end()};
1132 *response->mutable_inc()->mutable_actual_hist() = {
1133 stats.inc.actual_hist.begin(), stats.inc.actual_hist.end()};
1134 *response->mutable_inc()->mutable_diff_hist() = {
1135 stats.inc.diff_hist.begin(), stats.inc.diff_hist.end()};
1136
1137 response->mutable_out()->set_packets(stats.out.packets);
1138 response->mutable_out()->set_dropped(stats.out.dropped);
1139 response->mutable_out()->set_bytes(stats.out.bytes);
1140 *response->mutable_out()->mutable_requested_hist() = {
1141 stats.out.requested_hist.begin(), stats.out.requested_hist.end()};
1142 *response->mutable_out()->mutable_actual_hist() = {
1143 stats.out.actual_hist.begin(), stats.out.actual_hist.end()};
1144 *response->mutable_out()->mutable_diff_hist() = {
1145 stats.out.diff_hist.begin(), stats.out.diff_hist.end()};
1146
1147 response->set_timestamp(get_epoch_time());
1148
1149 return Status::OK;
1150 }
1151
1152 Status GetLinkStatus(ServerContext*, const GetLinkStatusRequest* request,
1153 GetLinkStatusResponse* response) override {

Callers

nothing calls this directly

Calls 4

return_with_errorFunction · 0.85
get_epoch_timeFunction · 0.85
endMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected