Skip to content

Commit

Permalink
Adding a config flag that controls ability to send flow samples
Browse files Browse the repository at this point in the history
from vrouter to collector. When disable_flow_collection flag is
set, vrouter will not send flow samples to collector.

Change-Id: I59c441e27275db82c5021feb770f134c53ab9a39
Closes-Bug: #1499546
  • Loading branch information
Raj Reddy committed Sep 24, 2015
1 parent cffabee commit 3b252c7
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/vnsw/agent/contrail-vrouter-agent.conf
Expand Up @@ -48,6 +48,9 @@ log_local=1
# Enable/Disable local flow message logging. Possible values are 0 (disable) and 1 (enable)
# log_flow=0

# Disable sending of flow samples to collector. Possible values are 0 and 1
# disable_flow_collection=false

# Encapsulation type for tunnel. Possible values are MPLSoGRE, MPLSoUDP, VXLAN
# tunnel_type=

Expand Down
7 changes: 6 additions & 1 deletion src/vnsw/agent/init/agent_param.cc
Expand Up @@ -436,6 +436,7 @@ void AgentParam::ParseDefaultSection() {
log_flow_ = false;
}

GetValueFromTree<bool>(disable_flow_collection_, "DEFAULT.disable_flow_collection");

if (!GetValueFromTree<bool>(xmpp_auth_enable_, "DEFAULT.xmpp_auth_enable")) {
xmpp_auth_enable_ = false;
Expand Down Expand Up @@ -646,6 +647,7 @@ void AgentParam::ParseDefaultSectionArguments
if (var_map.count("DEFAULT.log_flow")) {
log_flow_ = true;
}
GetOptValue<bool>(var_map, disable_flow_collection_, "DEFAULT.disable_flow_collection");
GetOptValue<bool>(var_map, xmpp_auth_enable_, "DEFAULT.xmpp_auth_enable");
GetOptValue<string>(var_map, xmpp_server_cert_, "DEFAULT.xmpp_server_cert");
GetValueFromTree<int>(tcp_hold_time_, "DEFAULT.tcp_hold_time");
Expand Down Expand Up @@ -1100,7 +1102,8 @@ AgentParam::AgentParam(Agent *agent, bool enable_flow_options,
tunnel_type_(), metadata_shared_secret_(), max_vm_flows_(),
linklocal_system_flows_(), linklocal_vm_flows_(),
flow_cache_timeout_(), config_file_(), program_name_(),
log_file_(), log_local_(false), log_flow_(false), log_level_(),
log_file_(), log_local_(false), log_flow_(false),
disable_flow_collection_(false), log_level_(),
log_category_(), use_syslog_(false),
http_server_port_(), host_name_(),
agent_stats_interval_(kAgentStatsInterval),
Expand Down Expand Up @@ -1198,6 +1201,8 @@ AgentParam::AgentParam(Agent *agent, bool enable_flow_options,
("DEFAULT.syslog_facility", opt::value<string>()->default_value("LOG_LOCAL0"),
"Syslog facility to receive log lines")
("DEFAULT.log_flow", "Enable local logging of flow sandesh messages")
("DEFAULT.disable_flow_collection", opt::value<bool>()->default_value(false),
"Disable sending flow samples to collector")
;
options_.add(log);

Expand Down
2 changes: 2 additions & 0 deletions src/vnsw/agent/init/agent_param.h
Expand Up @@ -133,6 +133,7 @@ class AgentParam {
const long log_file_size() const { return log_file_size_; }
bool log_local() const { return log_local_; }
bool log_flow() const { return log_flow_; }
bool disable_flow_collection() const { return disable_flow_collection_; }
const std::string &log_level() const { return log_level_; }
const std::string &log_category() const { return log_category_; }
const std::string &log_property_file() const { return log_property_file_; }
Expand Down Expand Up @@ -360,6 +361,7 @@ class AgentParam {

bool log_local_;
bool log_flow_;
bool disable_flow_collection_;
std::string log_level_;
std::string log_category_;
bool use_syslog_;
Expand Down
4 changes: 3 additions & 1 deletion src/vnsw/agent/init/test/test_agent_init.cc
Expand Up @@ -124,14 +124,15 @@ TEST_F(FlowTest, Agent_Conf_Xen_1) {
}

TEST_F(FlowTest, Agent_Param_1) {
int argc = 19;
int argc = 21;
char *argv[] = {
(char *) "",
(char *) "--config_file",
(char *)"controller/src/vnsw/agent/init/test/cfg.ini",
(char *) "--DEFAULT.collectors", (char *)"1.1.1.1:1000",
(char *) "--DEFAULT.log_local",
(char *) "--DEFAULT.log_flow",
(char *) "--DEFAULT.disable_flow_collection", (char *)"false",
(char *) "--DEFAULT.log_level", (char *)"SYS_DEBUG",
(char *) "--DEFAULT.log_category", (char *)"Test",
(char *) "--DEFAULT.http_server_port", (char *)"8000",
Expand All @@ -146,6 +147,7 @@ TEST_F(FlowTest, Agent_Param_1) {

EXPECT_TRUE(param.log_local());
EXPECT_TRUE(param.log_flow());
EXPECT_FALSE(param.disable_flow_collection());
EXPECT_STREQ(param.log_level().c_str(), "SYS_DEBUG");
EXPECT_STREQ(param.log_category().c_str(), "Test");
EXPECT_EQ(param.collector_server_list().size(), 1);
Expand Down
3 changes: 3 additions & 0 deletions src/vnsw/agent/ovs_tor_agent/tor-agent.conf
Expand Up @@ -42,6 +42,9 @@
# Enable/Disable local flow message logging. Possible values are 0 (disable) and 1 (enable)
# log_flow=0

# Disable sending of flow samples to collector. Possible values are 0 and 1
# disable_flow_collection=0

# Encapsulation type for tunnel. Possible values are MPLSoGRE, MPLSoUDP, VXLAN
# tunnel_type=

Expand Down
3 changes: 3 additions & 0 deletions src/vnsw/agent/pkt/flow_table.cc
Expand Up @@ -3582,6 +3582,9 @@ void FlowTable::SourceIpOverride(FlowEntry *flow, FlowDataIpv4 &s_flow) {

void FlowTable::FlowExport(FlowEntry *flow, uint64_t diff_bytes,
uint64_t diff_pkts) {
if (agent_->params()->disable_flow_collection())
return;

FlowDataIpv4 s_flow;
SandeshLevel::type level = SandeshLevel::SYS_DEBUG;
FlowStats &stats = flow->stats_;
Expand Down
1 change: 1 addition & 0 deletions src/vnsw/agent/uve/vrouter.sandesh
Expand Up @@ -92,6 +92,7 @@ struct VrouterAgent { // Agent info
48: optional string mode;
49: optional list<string> unmanaged_if_list;
50: optional u32 vn_count; //being sent for UI dashboard optimization
51: optional bool disable_flow_collection;
}

uve sandesh UveVrouterAgent {
Expand Down
1 change: 1 addition & 0 deletions src/vnsw/agent/uve/vrouter_uve_entry_base.cc
Expand Up @@ -501,6 +501,7 @@ void VrouterUveEntryBase::BuildAgentConfig(VrouterAgent &vrouter_agent) {
vrouter_agent.set_config_file(param->config_file());
vrouter_agent.set_log_local(param->log_local());
vrouter_agent.set_log_flow(param->log_flow());
vrouter_agent.set_disable_flow_collection(param->disable_flow_collection());
vrouter_agent.set_log_category(param->log_category());
vrouter_agent.set_log_level(param->log_level());
vrouter_agent.set_sandesh_http_port(param->http_server_port());
Expand Down

0 comments on commit 3b252c7

Please sign in to comment.