diff options
author | 2016-03-14 13:48:40 +0200 | |
---|---|---|
committer | 2016-03-14 13:48:40 +0200 | |
commit | 22f33006471cfed556e6987f88d3d9f7e532687a (patch) | |
tree | d82c114419afa32076cb2edb687a1137aa3967f7 /src/flow_stat.cpp | |
parent | d82201e2da3beb0e81e0c8ba30600d87f1b8276f (diff) | |
parent | 22e06f3c3532890ad336341c279012afc0710a9d (diff) |
merge cleanup
Diffstat (limited to 'src/flow_stat.cpp')
-rw-r--r-- | src/flow_stat.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/flow_stat.cpp b/src/flow_stat.cpp index de081ffe..dc039661 100644 --- a/src/flow_stat.cpp +++ b/src/flow_stat.cpp @@ -640,11 +640,8 @@ bool CFlowStatRuleMgr::dump_json(std::string & json, bool baseline) { data_section["ts"]["freq"] = Json::Value::UInt64(os_get_hr_freq()); if (m_user_id_map.is_empty()) { - if (baseline) { - json = writer.write(root); - return true; - } else - return false; + json = writer.write(root); + return true; } // read hw counters, and update @@ -682,6 +679,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 +687,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); |