Skip to content

Commit

Permalink
Merge "Send Agent Route Table size in Vrouter UVE"
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Sep 16, 2016
2 parents 82cdb6a + ee893be commit 3d18e80
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 38 deletions.
2 changes: 2 additions & 0 deletions src/vnsw/agent/pkt/flow_mgmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@
// 1. All message between flow-management and flow-table/flow-stats module will
// hold object references. This will ensure ref-count for object dont drop
// till messages are processed.
// 2. Each flow seen by flow-management will hold a reference to FlowEntryInfo
// in FlowEntry as flow_mgmt_info_
//
// Per FlowEntry mutex is used to synchronize access to same Flow between
// FlowTable and Flow Management module
Expand Down
55 changes: 43 additions & 12 deletions src/vnsw/agent/uve/vrouter.sandesh
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,9 @@ uve sandesh UveVrouterAgent {
** Sandesh definition for agent xmpp connection
*/
struct AgentXmppStats {
1: string ip (aggtype="listkey")
2: optional u16 reconnects;
3: optional u64 in_msgs;
4: optional u64 out_msgs;
2: u16 reconnects;
3: u64 in_msgs;
4: u64 out_msgs;
}

/**
Expand Down Expand Up @@ -205,9 +204,6 @@ struct VrouterStatsAgent { // Agent stats
5: optional u64 out_tpkts;
6: optional u64 out_bytes;

//xmpp stats
7: optional list<AgentXmppStats> xmpp_stats_list;

//Process stats
12: optional cpuinfo.CpuLoadInfo cpu_info;

Expand Down Expand Up @@ -269,11 +265,6 @@ struct VrouterStatsAgent { // Agent stats
53: optional map<string,derived_stats_results.EWMResult> out_bps_ewm
(mstats="phy_band_out_bps:DSEWM:0.2")

56: optional map<string, u64> raw_ifmap_stats (metric="agg", hidden="yes")
/** @display_name:Vrouter IFMAP Parse Error Statistics*/
57: optional map<string, u64> ifmap_stats (mstats="raw_ifmap_stats:DSNon0:", tags=".__key")
58: optional map<string, u64> ifmap_stats_1h (mstats="raw_ifmap_stats:DSSum:120")

/** @display_name:Physical Interface Flow Setup Statistics*/
68: optional map<string, VrouterFlowRate> phy_flow_rate (tags="name:.__key")
69: optional map<string, derived_stats_results.AnomalyResult> phy_added_flows_ewm
Expand Down Expand Up @@ -327,3 +318,43 @@ struct ComputeCpuState {
uve sandesh ComputeCpuStateTrace {
1: ComputeCpuState data
}

/**
* Sandesh definition for VRF routing table size on vrouter
*/
struct RouteTableSize {
1: u32 inet4_unicast;
2: u32 inet4_multicast;
3: u32 evpn;
4: u32 bridge;
5: u32 inet6_unicast;
}

/**
* Sandesh definition for vrouter control information
*/
struct VrouterControlStats {
1: string name (key="ObjectVRouter")
2: optional bool deleted

/** @display_name:Vrouter XMPP Statistics*/
3: optional map<string, AgentXmppStats> raw_xmpp_stats (hidden="yes")
4: optional map<string, AgentXmppStats> xmpp_stats (mstats="raw_xmpp_stats:DSChange:")

/** @display_name:Vrouter IFMAP Parse Error Statistics*/
5: optional map<string, u64> raw_ifmap_stats (metric="agg", hidden="yes")
6: optional map<string, u64> ifmap_stats
(mstats="raw_ifmap_stats:DSNon0:")
7: optional map<string, u64> ifmap_stats_1h
(mstats="raw_ifmap_stats:DSSum:3600")

8: optional map<string, RouteTableSize> raw_rt_table_size (hidden="yes")
9: optional map<string, RouteTableSize> rt_table_size (mstats="raw_rt_table_size:DSChange:")
}

/**
* Vrouter control statistics uve
*/
uve sandesh VrouterControlStatsTrace {
1: VrouterControlStats data;
}
104 changes: 80 additions & 24 deletions src/vnsw/agent/uve/vrouter_uve_entry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ using namespace std;

VrouterUveEntry::VrouterUveEntry(Agent *agent)
: VrouterUveEntryBase(agent), bandwidth_count_(0), port_bitmap_(),
flow_info_() {
flow_info_(), vrf_walk_id_(DBTableWalker::kInvalidWalkerId) {
start_time_ = UTCTimestampUsec();
}

Expand Down Expand Up @@ -64,13 +64,6 @@ bool VrouterUveEntry::SendVrouterMsg() {
prev_stats_.set_out_bytes(agent_->stats()->out_bytes());
}

vector<AgentXmppStats> xmpp_list;
BuildXmppStatsList(xmpp_list);
if (prev_stats_.get_xmpp_stats_list() != xmpp_list) {
stats.set_xmpp_stats_list(xmpp_list);
prev_stats_.set_xmpp_stats_list(xmpp_list);
}

if (prev_stats_.get_exception_packets() !=
agent_->stats()->pkt_exceptions() || first) {
stats.set_exception_packets(agent_->stats()->pkt_exceptions());
Expand Down Expand Up @@ -215,16 +208,15 @@ bool VrouterUveEntry::SendVrouterMsg() {
stats.set_flow_rate(flow_rate);
}

DerivedStatsMap ifmap_stats;
FetchIFMapStats(ifmap_stats);
stats.set_raw_ifmap_stats(ifmap_stats);

map<string, VrouterFlowRate> rate;
if (BuildPhysicalInterfaceFlowRate(&rate)) {
stats.set_phy_flow_rate(rate);
}
DispatchVrouterStatsMsg(stats);
first = false;

//Send VrouterControlStats UVE
SendVrouterControlStats();
return true;
}

Expand Down Expand Up @@ -476,21 +468,22 @@ void VrouterUveEntry::FetchDropStats(DerivedStatsMap &ds) const {
ds.insert(DerivedStatsPair("vlan_fwd_enq", req.get_vds_vlan_fwd_enq()));
}

void VrouterUveEntry::FetchIFMapStats(DerivedStatsMap &ds) const {
void VrouterUveEntry::FetchIFMapStats(DerivedStatsMap *ds) const {
IFMapAgentParser *parser = agent_->cfg()->cfg_parser();
if (parser) {
ds.insert(DerivedStatsPair("node_update_parse_errors",
parser->node_update_parse_errors()));
ds.insert(DerivedStatsPair("link_update_parse_errors",
parser->link_update_parse_errors()));
ds.insert(DerivedStatsPair("node_delete_parse_errors",
parser->node_delete_parse_errors()));
ds.insert(DerivedStatsPair("link_delete_parse_errors",
parser->link_delete_parse_errors()));
ds->insert(DerivedStatsPair("node_update_parse_errors",
parser->node_update_parse_errors()));
ds->insert(DerivedStatsPair("link_update_parse_errors",
parser->link_update_parse_errors()));
ds->insert(DerivedStatsPair("node_delete_parse_errors",
parser->node_delete_parse_errors()));
ds->insert(DerivedStatsPair("link_delete_parse_errors",
parser->link_delete_parse_errors()));
}
}

void VrouterUveEntry::BuildXmppStatsList(vector<AgentXmppStats> &list) const {
void VrouterUveEntry::BuildXmppStatsList
(std::map<std::string, AgentXmppStats> *xstats) const {
for (int count = 0; count < MAX_XMPP_SERVERS; count++) {
AgentXmppStats peer;
if (!agent_->controller_ifmap_xmpp_server(count).empty()) {
Expand All @@ -502,11 +495,12 @@ void VrouterUveEntry::BuildXmppStatsList(vector<AgentXmppStats> &list) const {
if (xc == NULL) {
continue;
}
peer.set_ip(agent_->controller_ifmap_xmpp_server(count));
peer.set_reconnects(agent_->stats()->xmpp_reconnects(count));
peer.set_in_msgs(agent_->stats()->xmpp_in_msgs(count));
peer.set_out_msgs(agent_->stats()->xmpp_out_msgs(count));
list.push_back(peer);
xstats->insert(std::make_pair(
agent_->controller_ifmap_xmpp_server(count),
peer));
}
}
}
Expand Down Expand Up @@ -544,3 +538,65 @@ void VrouterUveEntry::UpdateBitmap(uint8_t proto, uint16_t sport,
uint16_t dport) {
port_bitmap_.AddPort(proto, sport, dport);
}

void VrouterUveEntry::VrfWalkDone(DBTableBase *base, RouteTableSizeMapPtr list){
vrf_walk_id_ = DBTableWalker::kInvalidWalkerId;
BuildAndSendVrouterControlStats(list);
}

bool VrouterUveEntry::AppendVrf(DBTablePartBase *part, DBEntryBase *entry,
RouteTableSizeMapPtr list) {
VrfEntry *vrf = static_cast<VrfEntry *>(entry);

if (!vrf->IsDeleted()) {
RouteTableSize value;
value.set_inet4_unicast(vrf->GetInet4UnicastRouteTable()->Size());
value.set_inet4_multicast(vrf->GetInet4MulticastRouteTable()->Size());
value.set_evpn(vrf->GetEvpnRouteTable()->Size());
value.set_bridge(vrf->GetBridgeRouteTable()->Size());
value.set_inet6_unicast(vrf->GetInet6UnicastRouteTable()->Size());
list.get()->insert(RouteTableSizePair(vrf->GetName(), value));
}
return true;
}

bool VrouterUveEntry::StartVrfWalk() {
if (vrf_walk_id_ != DBTableWalker::kInvalidWalkerId) {
return false;
}

RouteTableSizeMapPtr list(new RouteTableSizeMap());
DBTableWalker *walker = agent_->db()->GetWalker();
vrf_walk_id_ = walker->WalkTable(agent_->vrf_table(), NULL,
boost::bind(&VrouterUveEntry::AppendVrf, this, _1, _2, list),
boost::bind(&VrouterUveEntry::VrfWalkDone, this, _1, list));
return true;
}

void VrouterUveEntry::DispatchVrouterControlStats
(const VrouterControlStats &uve) const {
VrouterControlStatsTrace::Send(uve);
}

void VrouterUveEntry::SendVrouterControlStats() {
/* We do VRF walk to collect route table sizes. In Walk Done API we trigger
* building of all attributes of VrouterControlStats UVE and send it*/
StartVrfWalk();
}

void VrouterUveEntry::BuildAndSendVrouterControlStats(RouteTableSizeMapPtr
list) {
VrouterControlStats stats;
stats.set_name(agent_->agent_name());

std::map<std::string, AgentXmppStats> xstats;
BuildXmppStatsList(&xstats);
stats.set_raw_xmpp_stats(xstats);

DerivedStatsMap ifmap_stats;
FetchIFMapStats(&ifmap_stats);
stats.set_raw_ifmap_stats(ifmap_stats);

stats.set_raw_rt_table_size(*(list.get()));
DispatchVrouterControlStats(stats);
}
15 changes: 13 additions & 2 deletions src/vnsw/agent/uve/vrouter_uve_entry.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,24 @@ class VrouterUveEntry : public VrouterUveEntryBase {
public:
typedef std::map<string, uint64_t> DerivedStatsMap;
typedef std::pair<string, uint64_t> DerivedStatsPair;
typedef std::map<std::string, RouteTableSize> RouteTableSizeMap;
typedef std::pair<std::string, RouteTableSize> RouteTableSizePair;
typedef boost::shared_ptr<RouteTableSizeMap> RouteTableSizeMapPtr;

VrouterUveEntry(Agent *agent);
virtual ~VrouterUveEntry();
L4PortBitmap port_bitmap() { return port_bitmap_; }

virtual bool SendVrouterMsg();
void SendVrouterControlStats();
void UpdateBitmap(uint8_t proto, uint16_t sport, uint16_t dport);

protected:
uint8_t bandwidth_count_;
L4PortBitmap port_bitmap_;
FlowRateComputeInfo flow_info_;
private:
void DispatchVrouterControlStats(const VrouterControlStats &uve) const;
void InitPrevStats() const;
void FetchDropStats(DerivedStatsMap &ds) const;
bool SetVrouterPortBitmap(VrouterStatsAgent &vr_stats);
Expand All @@ -45,10 +50,16 @@ class VrouterUveEntry : public VrouterUveEntryBase {
bool BuildPhysicalInterfaceList(std::map<std::string, PhyIfStats> &list,
std::map<std::string, PhyIfInfo> info)const;
std::string GetMacAddress(const MacAddress &mac) const;
void BuildXmppStatsList(std::vector<AgentXmppStats> &list) const;
void FetchIFMapStats(DerivedStatsMap &ds) const;
void BuildXmppStatsList(std::map<std::string, AgentXmppStats> *stats) const;
void FetchIFMapStats(DerivedStatsMap *ds) const;
void VrfWalkDone(DBTableBase *base, RouteTableSizeMapPtr list);
bool AppendVrf(DBTablePartBase *part, DBEntryBase *entry,
RouteTableSizeMapPtr list);
bool StartVrfWalk();
void BuildAndSendVrouterControlStats(RouteTableSizeMapPtr list);

uint64_t start_time_;
DBTableWalker::WalkId vrf_walk_id_;
DISALLOW_COPY_AND_ASSIGN(VrouterUveEntry);
};

Expand Down

0 comments on commit 3d18e80

Please sign in to comment.