X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=extras%2Fvom%2Fvom%2Fstat_reader.cpp;h=50a25d2e0bad05cacad4f02010c3d682b8d1bc4a;hb=7c0eb56f4;hp=82e09aedce0e730a6300524f6ce860ae0fd40d6f;hpb=a8ac77f4706b7e40887426c446ebded4555885e4;p=vpp.git diff --git a/extras/vom/vom/stat_reader.cpp b/extras/vom/vom/stat_reader.cpp index 82e09aedce0..50a25d2e0ba 100644 --- a/extras/vom/vom/stat_reader.cpp +++ b/extras/vom/vom/stat_reader.cpp @@ -22,17 +22,13 @@ stat_reader::stat_indexes_t stat_reader::m_stat_itf_indexes; stat_reader::stat_reader() : m_client() -{ -} +{} stat_reader::stat_reader(stat_client sc) : m_client(sc) -{ -} +{} -stat_reader::~stat_reader() -{ -} +stat_reader::~stat_reader() {} int stat_reader::connect() @@ -61,7 +57,9 @@ stat_reader::unregisters(const interface& intf) void stat_reader::read() { + std::set> itfs_w_stats; const stat_client::stat_data_vec_t& sd = m_client.dump(); + for (auto& sde : sd) { std::string name; @@ -70,20 +68,43 @@ stat_reader::read() name = sde.name(); + if (name.find("/if") != std::string::npos) + name.erase(0, 4); + switch (sde.type()) { - case STAT_DIR_TYPE_COUNTER_VECTOR_SIMPLE: case STAT_DIR_TYPE_ERROR_INDEX: case STAT_DIR_TYPE_SCALAR_INDEX: + case STAT_DIR_TYPE_NAME_VECTOR: case STAT_DIR_TYPE_ILLEGAL: + case STAT_DIR_TYPE_EMPTY: + break; + + case STAT_DIR_TYPE_COUNTER_VECTOR_SIMPLE: { + uint64_t** data; + + data = sde.get_stat_segment_simple_counter_data(); + + for (auto& i : m_stat_itf_indexes) { + counter_t count; + + for (int k = 0; k < m_client.vec_len(data); k++) { + count.packets += data[k][i]; + } + + std::shared_ptr itf = interface::find(i); + if (itf) { + itf->set(count, name); + itfs_w_stats.insert(itf); + } + } break; + } case STAT_DIR_TYPE_COUNTER_VECTOR_COMBINED: { vlib_counter_t** data; data = sde.get_stat_segment_combined_counter_data(); - if (name.find("/if") != std::string::npos) - name.erase(0, 4); for (auto& i : m_stat_itf_indexes) { counter_t count; @@ -91,19 +112,19 @@ stat_reader::read() count.packets += data[k][i].packets; count.bytes += data[k][i].bytes; } + std::shared_ptr itf = interface::find(i); - if (itf) + if (itf) { itf->set(count, name); + itfs_w_stats.insert(itf); + } } break; } } } - - for (auto& i : m_stat_itf_indexes) { - std::shared_ptr itf = interface::find(i); - if (itf) - itf->publish_stats(); + for (auto itf : itfs_w_stats) { + itf->publish_stats(); } }