summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2016-03-09 18:04:31 +0200
committerimarom <imarom@cisco.com>2016-03-10 17:16:37 +0200
commit8b0bb76f7987e33ff1b13b5bdf360a9e15f96c68 (patch)
treece46b170f7b168726c33db7b1f5dbf1f491b15b8 /src
parent094411ef99a485017d300e632e14aee10c8234c5 (diff)
RX STATS !
Diffstat (limited to 'src')
-rw-r--r--src/flow_stat.cpp6
-rw-r--r--src/main_dpdk.cpp15
2 files changed, 16 insertions, 5 deletions
diff --git a/src/flow_stat.cpp b/src/flow_stat.cpp
index 4e05de8a..b2714b1e 100644
--- a/src/flow_stat.cpp
+++ b/src/flow_stat.cpp
@@ -630,8 +630,12 @@ bool CFlowStatRuleMgr::dump_json(std::string & json, bool force_sync) {
root["name"] = "flow_stats";
root["type"] = 0;
- Json::Value &data_section = root["data"];
+ if (force_sync) {
+ root["sync"] = true;
+ }
+
+ Json::Value &data_section = root["data"];
data_section["ts"]["value"] = Json::Value::UInt64(os_get_hr_tick_64());
data_section["ts"]["freq"] = Json::Value::UInt64(os_get_hr_freq());
diff --git a/src/main_dpdk.cpp b/src/main_dpdk.cpp
index 3f53f83c..2d087c8c 100644
--- a/src/main_dpdk.cpp
+++ b/src/main_dpdk.cpp
@@ -2307,7 +2307,7 @@ public:
public:
void Dump(FILE *fd,DumpFormat mode);
void DumpAllPorts(FILE *fd);
- void dump_json(std::string & json);
+ void dump_json(std::string & json, bool force_sync);
private:
std::string get_field(std::string name,float &f);
std::string get_field(std::string name,uint64_t &f);
@@ -2341,8 +2341,15 @@ std::string CGlobalStats::get_field_port(int port,std::string name,uint64_t &f){
}
-void CGlobalStats::dump_json(std::string & json){
- json="{\"name\":\"trex-global\",\"type\":0,\"data\":{";
+void CGlobalStats::dump_json(std::string & json, bool force_sync){
+ /* refactor this to JSON */
+
+ json="{\"name\":\"trex-global\",\"type\":0,";
+ if (force_sync) {
+ json += "\"sync\": true,";
+ }
+
+ json +="\"data\":{";
#define GET_FIELD(f) get_field(std::string(#f),f)
#define GET_FIELD_PORT(p,f) get_field_port(p,std::string(#f),lp->f)
@@ -3565,7 +3572,7 @@ CGlobalTRex::publish_async_data(bool sync_now) {
get_stats(m_stats);
}
- m_stats.dump_json(json);
+ m_stats.dump_json(json, sync_now);
m_zmq_publisher.publish_json(json);
/* generator json , all cores are the same just sample the first one */