summaryrefslogtreecommitdiffstats
path: root/src/flow_stat.cpp
diff options
context:
space:
mode:
authorIdo Barnea <ibarnea@cisco.com>2016-03-13 14:32:39 +0200
committerIdo Barnea <ibarnea@cisco.com>2016-03-13 14:33:35 +0200
commitf53087722d09d19b4fa3ddea311484f3cc786a80 (patch)
tree45b7fb5ac36a7075380c07aa2a7de47b1a5e6397 /src/flow_stat.cpp
parent2e249a00eae2e2a1a25c115480b146ebafe0b54b (diff)
Send empty dict if no change for pg_id in flow stat
Diffstat (limited to 'src/flow_stat.cpp')
-rw-r--r--src/flow_stat.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/flow_stat.cpp b/src/flow_stat.cpp
index de081ffe..1a083f84 100644
--- a/src/flow_stat.cpp
+++ b/src/flow_stat.cpp
@@ -682,6 +682,7 @@ bool CFlowStatRuleMgr::dump_json(std::string & json, bool baseline) {
// build json report
flow_stat_user_id_map_it_t it;
for (it = m_user_id_map.begin(); it != m_user_id_map.end(); it++) {
+ bool send_empty = true;
CFlowStatUserIdInfo *user_id_info = it->second;
uint32_t user_id = it->first;
std::string str_user_id = static_cast<std::ostringstream*>( &(std::ostringstream()
@@ -689,19 +690,25 @@ bool CFlowStatRuleMgr::dump_json(std::string & json, bool baseline) {
if (! user_id_info->was_sent()) {
data_section[str_user_id]["first_time"] = true;
user_id_info->set_was_sent(true);
+ send_empty = false;
}
for (uint8_t port = 0; port < m_num_ports; port++) {
std::string str_port = static_cast<std::ostringstream*>( &(std::ostringstream() << int(port) ) )->str();
if (user_id_info->need_to_send_rx(port) || baseline) {
user_id_info->set_no_need_to_send_rx(port);
data_section[str_user_id]["rx_pkts"][str_port] = Json::Value::UInt64(user_id_info->get_rx_counter(port));
+ send_empty = false;
}
if (user_id_info->need_to_send_tx(port) || baseline) {
user_id_info->set_no_need_to_send_tx(port);
data_section[str_user_id]["tx_pkts"][str_port] = Json::Value::UInt64(user_id_info->get_tx_counter(port).get_pkts());
data_section[str_user_id]["tx_bytes"][str_port] = Json::Value::UInt64(user_id_info->get_tx_counter(port).get_bytes());
+ send_empty = false;
}
}
+ if (send_empty) {
+ data_section[str_user_id] = Json::objectValue;
+ }
}
json = writer.write(root);