aboutsummaryrefslogtreecommitdiffstats
path: root/extras/vom
diff options
context:
space:
mode:
Diffstat (limited to 'extras/vom')
-rw-r--r--extras/vom/vom/interface.cpp24
-rw-r--r--extras/vom/vom/interface.hpp1
-rw-r--r--extras/vom/vom/stat_client.cpp49
-rw-r--r--extras/vom/vom/stat_client.hpp2
-rw-r--r--extras/vom/vom/stat_reader.cpp41
-rw-r--r--extras/vom/vom/types.cpp7
-rw-r--r--extras/vom/vom/types.hpp10
7 files changed, 87 insertions, 47 deletions
diff --git a/extras/vom/vom/interface.cpp b/extras/vom/vom/interface.cpp
index 97f7776ebc6..f2f32b43a88 100644
--- a/extras/vom/vom/interface.cpp
+++ b/extras/vom/vom/interface.cpp
@@ -424,6 +424,8 @@ interface::set(const counter_t& count, const std::string& stat_type)
m_stats.m_rx = count;
else if ("tx" == stat_type)
m_stats.m_tx = count;
+ else if ("drops" == stat_type)
+ m_stats.m_drop = count;
else if ("rx-unicast" == stat_type)
m_stats.m_rx_unicast = count;
else if ("tx-unicast" == stat_type)
@@ -454,22 +456,12 @@ std::ostream&
operator<<(std::ostream& os, const interface::stats_t& stats)
{
os << "["
- << "rx [packets " << stats.m_rx.packets << ", bytes " << stats.m_rx.bytes
- << "]"
- << " rx-unicast [packets " << stats.m_rx_unicast.packets << ", bytes "
- << stats.m_rx_unicast.bytes << "]"
- << " rx-multicast [packets " << stats.m_rx_multicast.packets << ", bytes "
- << stats.m_rx_multicast.bytes << "]"
- << " rx-broadcast [packets " << stats.m_rx_broadcast.packets << ", bytes "
- << stats.m_rx_broadcast.bytes << "]"
- << " tx [packets " << stats.m_tx.packets << ", bytes " << stats.m_tx.bytes
- << "]"
- << " tx-unicast [packets " << stats.m_tx_unicast.packets << ", bytes "
- << stats.m_tx_unicast.bytes << "]"
- << " tx-multicast [packets " << stats.m_tx_multicast.packets << ", bytes "
- << stats.m_tx_multicast.bytes << "]"
- << " tx-broadcast [packets " << stats.m_tx_broadcast.packets << ", bytes "
- << stats.m_tx_broadcast.bytes << "]]" << std::endl;
+ << "rx " << stats.m_rx << " rx-unicast " << stats.m_rx_unicast
+ << " rx-multicast " << stats.m_rx_multicast << " rx-broadcast "
+ << stats.m_rx_broadcast << " tx " << stats.m_tx << " tx-unicast "
+ << stats.m_tx_unicast << " tx-multicast " << stats.m_tx_multicast
+ << " tx-broadcast " << stats.m_tx_broadcast << " drops " << stats.m_drop
+ << "]" << std::endl;
return (os);
}
diff --git a/extras/vom/vom/interface.hpp b/extras/vom/vom/interface.hpp
index 2f6511eac6d..05642f0cdf7 100644
--- a/extras/vom/vom/interface.hpp
+++ b/extras/vom/vom/interface.hpp
@@ -197,6 +197,7 @@ public:
counter_t m_tx_multicast;
counter_t m_rx_broadcast;
counter_t m_tx_broadcast;
+ counter_t m_drop;
};
/**
diff --git a/extras/vom/vom/stat_client.cpp b/extras/vom/vom/stat_client.cpp
index 6406e215193..b2d429929af 100644
--- a/extras/vom/vom/stat_client.cpp
+++ b/extras/vom/vom/stat_client.cpp
@@ -78,7 +78,7 @@ stat_client::stat_data_t::get_stat_segment_combined_counter_data() const
stat_client::stat_client(std::string& socket_name)
: m_socket_name(socket_name)
, m_patterns()
- , m_stat_connect(0)
+ , m_stat_connect(false)
, m_counter_vec()
, m_stat_seg_data(nullptr)
, m_stat_data()
@@ -89,7 +89,7 @@ stat_client::stat_client(std::string& socket_name)
stat_client::stat_client(std::vector<std::string>& pattern)
: m_socket_name("/run/vpp/stats.sock")
, m_patterns(pattern)
- , m_stat_connect(0)
+ , m_stat_connect(false)
, m_counter_vec()
, m_stat_seg_data(nullptr)
, m_stat_data()
@@ -100,7 +100,7 @@ stat_client::stat_client(std::string socket_name,
std::vector<std::string> patterns)
: m_socket_name(socket_name)
, m_patterns(patterns)
- , m_stat_connect(0)
+ , m_stat_connect(false)
, m_counter_vec()
, m_stat_seg_data(nullptr)
, m_stat_data()
@@ -110,7 +110,7 @@ stat_client::stat_client(std::string socket_name,
stat_client::stat_client()
: m_socket_name("/run/vpp/stats.sock")
, m_patterns()
- , m_stat_connect(0)
+ , m_stat_connect(false)
, m_counter_vec()
, m_stat_seg_data(nullptr)
, m_stat_data()
@@ -136,7 +136,7 @@ int
stat_client::connect()
{
if (stat_segment_connect(m_socket_name.c_str()) == 0) {
- m_stat_connect = 1;
+ m_stat_connect = true;
ls();
}
return m_stat_connect;
@@ -147,6 +147,7 @@ stat_client::disconnect()
{
if (m_stat_connect)
stat_segment_disconnect();
+ m_stat_connect = false;
}
int
@@ -176,17 +177,20 @@ const stat_client::stat_data_vec_t&
stat_client::dump()
{
stat_segment_data_free(m_stat_seg_data);
+ m_stat_seg_data = NULL;
if (m_stat_data.size()) {
m_stat_data.clear();
}
- m_stat_seg_data = stat_segment_dump(m_counter_vec);
- if (!m_stat_seg_data) {
- ls();
- return m_stat_data;
- }
- for (int i = 0; i < stat_segment_vec_len(m_stat_seg_data); i++) {
- stat_data_t sd(m_stat_seg_data[i]);
- m_stat_data.push_back(sd);
+ if (m_stat_connect) {
+ m_stat_seg_data = stat_segment_dump(m_counter_vec);
+ if (!m_stat_seg_data) {
+ ls();
+ return m_stat_data;
+ }
+ for (int i = 0; i < stat_segment_vec_len(m_stat_seg_data); i++) {
+ stat_data_t sd(m_stat_seg_data[i]);
+ m_stat_data.push_back(sd);
+ }
}
return m_stat_data;
}
@@ -195,17 +199,20 @@ const stat_client::stat_data_vec_t&
stat_client::dump_entry(uint32_t index)
{
stat_segment_data_free(m_stat_seg_data);
+ m_stat_seg_data = NULL;
if (m_stat_data.size()) {
m_stat_data.clear();
}
- m_stat_seg_data = stat_segment_dump_entry(index);
- if (!m_stat_seg_data) {
- ls();
- return m_stat_data;
- }
- for (int i = 0; i < stat_segment_vec_len(m_stat_seg_data); i++) {
- stat_data_t sd(m_stat_seg_data[i]);
- m_stat_data.push_back(sd);
+ if (m_stat_connect) {
+ m_stat_seg_data = stat_segment_dump_entry(index);
+ if (!m_stat_seg_data) {
+ ls();
+ return m_stat_data;
+ }
+ for (int i = 0; i < stat_segment_vec_len(m_stat_seg_data); i++) {
+ stat_data_t sd(m_stat_seg_data[i]);
+ m_stat_data.push_back(sd);
+ }
}
return m_stat_data;
}
diff --git a/extras/vom/vom/stat_client.hpp b/extras/vom/vom/stat_client.hpp
index 40729feef5f..8e014da19b1 100644
--- a/extras/vom/vom/stat_client.hpp
+++ b/extras/vom/vom/stat_client.hpp
@@ -179,7 +179,7 @@ private:
/**
* connection bit
*/
- int m_stat_connect;
+ bool m_stat_connect;
/**
* Pointer to VPP style vector of stat indexes
diff --git a/extras/vom/vom/stat_reader.cpp b/extras/vom/vom/stat_reader.cpp
index 82e09aedce0..1851f742247 100644
--- a/extras/vom/vom/stat_reader.cpp
+++ b/extras/vom/vom/stat_reader.cpp
@@ -61,7 +61,9 @@ stat_reader::unregisters(const interface& intf)
void
stat_reader::read()
{
+ std::set<std::shared_ptr<interface>> itfs_w_stats;
const stat_client::stat_data_vec_t& sd = m_client.dump();
+
for (auto& sde : sd) {
std::string name;
@@ -70,20 +72,41 @@ 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_ILLEGAL:
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<interface> 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 +114,19 @@ stat_reader::read()
count.packets += data[k][i].packets;
count.bytes += data[k][i].bytes;
}
+
std::shared_ptr<interface> 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<interface> itf = interface::find(i);
- if (itf)
- itf->publish_stats();
+ for (auto itf : itfs_w_stats) {
+ itf->publish_stats();
}
}
diff --git a/extras/vom/vom/types.cpp b/extras/vom/vom/types.cpp
index a67a7f360f9..0236df28417 100644
--- a/extras/vom/vom/types.cpp
+++ b/extras/vom/vom/types.cpp
@@ -324,6 +324,13 @@ ethertype_t::from_numeric_val(uint16_t numeric)
return (ethertype_t::UNSPECIFIED);
}
+std::ostream&
+operator<<(std::ostream& os, const counter_t& c)
+{
+ os << "[packets: " << c.packets << " bytes:" << c.bytes << "]";
+ return os;
+}
+
}; // namespace VOM
/*
diff --git a/extras/vom/vom/types.hpp b/extras/vom/vom/types.hpp
index e3b21add045..56759d5e741 100644
--- a/extras/vom/vom/types.hpp
+++ b/extras/vom/vom/types.hpp
@@ -385,6 +385,11 @@ struct counter_t
, bytes(0)
{
}
+ counter_t(const counter_t& c)
+ : packets(c.packets)
+ , bytes(c.bytes)
+ {
+ }
uint64_t packets;
uint64_t bytes;
};
@@ -398,6 +403,11 @@ std::ostream& operator<<(std::ostream& os, const mac_address_t& mac);
* Ostream operator for a MAC address
*/
std::ostream& operator<<(std::ostream& os, const l2_address_t& l2);
+
+/**
+ * Ostream operator for a MAC address
+ */
+std::ostream& operator<<(std::ostream& os, const counter_t& c);
};
/*