36 static bool first =
true;
37 VrouterStatsAgent stats;
82 if (
prev_stats_.get_exception_packets_allowed() != e_pkts_allowed) {
83 stats.set_exception_packets_allowed(e_pkts_allowed);
84 prev_stats_.set_exception_packets_allowed(e_pkts_allowed);
99 map<string, PhyIfStats> phy_if_list;
100 map<string, PhyIfInfo> phy_if_info;
101 map<string, AgentDropStats> phy_if_ds;
103 stats.set_raw_phy_if_stats(phy_if_list);
104 stats.set_raw_phy_if_drop_stats(phy_if_ds);
106 if (
prev_stats_.get_phy_if_info() != phy_if_info) {
107 stats.set_phy_if_info(phy_if_info);
119 vector<AgentIfBandwidth> phy_if_blist;
120 double in_util = 0, out_util = 0;
121 map<string,uint64_t> inb,outb;
125 stats.set_phy_band_in_bps(inb);
126 stats.set_phy_band_out_bps(outb);
127 if (in_util !=
prev_stats_.get_total_in_bandwidth_utilization()) {
128 stats.set_total_in_bandwidth_utilization(in_util);
129 prev_stats_.set_total_in_bandwidth_utilization(in_util);
131 if (out_util !=
prev_stats_.get_total_out_bandwidth_utilization()) {
132 stats.set_total_out_bandwidth_utilization(out_util);
133 prev_stats_.set_total_out_bandwidth_utilization(out_util);
139 vector<AgentIfBandwidth> phy_if_blist;
141 if (
prev_stats_.get_phy_if_5min_usage() != phy_if_blist) {
142 stats.set_phy_if_5min_usage(phy_if_blist);
155 AgentIfStats vhost_stats;
156 AgentDropStats vhost_ds;
158 vhost_stats.set_in_pkts(s->
in_pkts);
159 vhost_stats.set_in_bytes(s->
in_bytes);
160 vhost_stats.set_out_pkts(s->
out_pkts);
162 vhost_stats.set_speed(s->
speed);
165 stats.set_raw_vhost_stats(vhost_stats);
166 stats.set_raw_vhost_drop_stats(vhost_ds);
173 stats.set_raw_drop_stats(ds);
182 VrouterFlowRate flow_rate;
186 flow_rate.set_active_flows(active_flows);
187 stats.set_flow_rate(flow_rate);
200 double *utilization_bps)
const {
201 if (utilization_bps) *utilization_bps = 0;
202 if (bytes == 0 || speed_mbps == 0) {
205 uint64_t bits = bytes * 8;
206 if (diff_seconds == 0) {
210 uint64_t bps = bits/diff_seconds;
213 uint64_t speed_bps = speed_mbps * 1024 * 1024;
214 double bps_double = bits/diff_seconds;
215 if (utilization_bps) *utilization_bps = (bps_double * 100)/speed_bps;
220 bool dir_in,
int mins,
221 double *util)
const {
251 map<string, PhyIfInfo> &info,
252 map<string, AgentDropStats> &dsmap)
254 bool changed =
false;
255 PhysicalInterfaceSet::const_iterator it =
phy_intf_set_.begin();
265 PhyIfStats phy_stat_entry;
266 phy_stat_entry.set_in_pkts(s->
in_pkts);
267 phy_stat_entry.set_in_bytes(s->
in_bytes);
268 phy_stat_entry.set_out_pkts(s->
out_pkts);
269 phy_stat_entry.set_out_bytes(s->
out_bytes);
270 list.insert(make_pair(intf->
name(), phy_stat_entry));
272 PhyIfInfo phy_if_info;
273 phy_if_info.set_speed(s->
speed);
275 info.insert(make_pair(intf->
name(), phy_if_info));
279 dsmap.insert(make_pair(intf->
name(), ds));
286 (vector<AgentIfBandwidth> &phy_if_list, uint8_t mins)
const {
287 uint64_t in_band, out_band;
288 bool changed =
false;
290 PhysicalInterfaceSet::const_iterator it =
phy_intf_set_.begin();
299 AgentIfBandwidth phy_stat_entry;
300 phy_stat_entry.set_name(intf->
name());
303 phy_stat_entry.set_in_bandwidth_usage(in_band);
304 phy_stat_entry.set_out_bandwidth_usage(out_band);
305 phy_if_list.push_back(phy_stat_entry);
313 (map<string,uint64_t> &imp, map<string,uint64_t> &omp,
314 uint8_t mins,
double &in_avg_util,
315 double &out_avg_util)
const {
316 uint64_t in_band, out_band;
317 double in_util, out_util;
318 bool changed =
false;
323 PhysicalInterfaceSet::const_iterator it = phy_intf_set_.begin();
324 while (it != phy_intf_set_.end()) {
333 AgentIfBandwidth phy_stat_entry;
334 phy_stat_entry.set_name(intf->
name());
335 in_band = GetBandwidthUsage(s,
true, mins, &in_util);
336 out_band = GetBandwidthUsage(s,
false, mins, &out_util);
337 imp.insert(make_pair(intf->
name(),in_band));
338 omp.insert(make_pair(intf->
name(),out_band));
340 in_avg_util += in_util;
341 out_avg_util += out_util;
345 in_avg_util /= num_intfs;
346 out_avg_util /= num_intfs;
352 PhysicalInterfaceSet::const_iterator it =
phy_intf_set_.begin();
390 (std::map<std::string, AgentXmppStats> *xstats)
const {
393 if (!agent_->controller_ifmap_xmpp_server(count).empty()) {
402 peer.set_reconnects(agent_->stats()->xmpp_reconnects(count));
403 peer.set_in_msgs(agent_->stats()->xmpp_in_msgs(count));
404 peer.set_out_msgs(agent_->stats()->xmpp_out_msgs(count));
405 xstats->insert(std::make_pair(
406 agent_->controller_ifmap_xmpp_server(count),
413 bool changed =
false;
415 vector<uint32_t> tcp_sport;
417 vr_stats.set_tcp_sport_bitmap(tcp_sport);
421 vector<uint32_t> tcp_dport;
423 vr_stats.set_tcp_dport_bitmap(tcp_dport);
427 vector<uint32_t> udp_sport;
429 vr_stats.set_udp_sport_bitmap(udp_sport);
433 vector<uint32_t> udp_dport;
435 vr_stats.set_udp_dport_bitmap(udp_dport);
456 RouteTableSize value;
481 (
const VrouterControlStats &uve)
const {
482 VrouterControlStatsTrace::Send(uve);
493 VrouterControlStats stats;
496 std::map<std::string, AgentXmppStats> xstats;
498 stats.set_raw_xmpp_stats(xstats);
502 stats.set_raw_ifmap_stats(ifmap_stats);
504 stats.set_raw_rt_table_size(*(list.get()));
StatsManager * stats_manager() const
void FetchIFMapStats(AgentUve::DerivedStatsMap *ds) const
XmppChannel * GetXmppChannel()
FlowRateComputeInfo flow_info_
static const uint8_t bandwidth_mod_1min
uint64_t out_bytes() const
AgentRouteTable * GetInet4MulticastRouteTable() const
AgentRouteTable * GetEvpnRouteTable() const
IFMapAgentParser * cfg_parser() const
uint64_t GetBandwidthUsage(StatsManager::InterfaceStats *s, bool dir_in, int mins, double *util) const
uint64_t node_update_parse_errors()
AgentUveBase * uve() const
void AddPort(uint8_t proto, uint16_t sport, uint16_t dport)
uint64_t node_delete_parse_errors()
VrouterStatsAgent prev_stats_
vr_drop_stats_req drop_stats() const
AgentStats * stats() const
uint64_t flow_created() const
InetUnicastAgentRouteTable * GetInet4UnicastRouteTable() const
void UpdateBitmap(uint8_t proto, uint16_t sport, uint16_t dport)
uint64_t pkt_exceptions() const
const std::string & vhost_interface_name() const
void VrfWalkDone(DBTableBase *base, RouteTableSizeMapPtr list)
bool AppendVrf(DBTablePartBase *part, DBEntryBase *entry, RouteTableSizeMapPtr list)
virtual void DispatchVrouterStatsMsg(const VrouterStatsAgent &uve)
AgentDBEntry * FindActiveEntry(const DBEntry *key)
InterfaceTable * interface_table() const
void BuildDropStats(const vr_drop_stats_req &r, AgentDropStats &ds) const
InetUnicastAgentRouteTable * GetInet6UnicastRouteTable() const
const string & GetName() const
VrouterUveEntry(Agent *agent)
uint64_t CalculateBandwitdh(uint64_t bytes, int speed_mbps, int diff_seconds, double *utilization_bps) const
void DispatchVrouterControlStats(const VrouterControlStats &uve) const
std::map< string, uint64_t > DerivedStatsMap
virtual bool SendVrouterMsg()
std::pair< std::string, RouteTableSize > RouteTableSizePair
uint64_t flow_aged() const
uint64_t pkt_dropped() const
virtual bool SendVrouterMsg()
DBTableWalker * GetWalker()
virtual size_t Size() const
DBTableWalker::WalkId vrf_walk_id_
uint64_t prev_5min_out_bytes
void SendVrouterControlStats()
uint64_t link_delete_parse_errors()
bool SetVrouterPortBitmap(VrouterStatsAgent &vr_stats)
std::pair< string, uint64_t > DerivedStatsPair
AgentRouteTable * GetBridgeRouteTable() const
vr_drop_stats_req drop_stats
void BuildAndSendVrouterControlStats(RouteTableSizeMapPtr list)
static const uint8_t bandwidth_mod_5min
bool BuildPhysicalInterfaceBandwidth(std::vector< AgentIfBandwidth > &list, uint8_t mins) const
virtual ~VrouterUveEntry()
const std::string & agent_name() const
bool BuildFlowRate(AgentStats::FlowCounters &created, AgentStats::FlowCounters &aged, FlowRateComputeInfo &flow_info, VrouterFlowRate &flow_rate) const
FlowProto * get_flow_proto() const
VrfTable * vrf_table() const
WalkId WalkTable(DBTable *table, const DBRequestKey *key_start, WalkFn walker, WalkCompleteFn walk_complete, bool postpone_walk=false)
uint32_t FlowCount() const
uint64_t out_pkts() const
uint64_t prev_5min_in_bytes
static uint64_t UTCTimestampUsec()
boost::shared_ptr< RouteTableSizeMap > RouteTableSizeMapPtr
uint64_t in_bytes() const
bool Sync(std::vector< uint32_t > &bmap)
uint64_t link_update_parse_errors()
std::map< std::string, RouteTableSize > RouteTableSizeMap
const std::string & name() const
static const WalkId kInvalidWalkerId
L4PortBitmap port_bitmap_
void FetchDropStats(AgentDropStats &ds) const
AgentConfig * cfg() const
void BuildXmppStatsList(std::map< std::string, AgentXmppStats > *stats) const
void InitPrevStats() const
InterfaceStats * GetInterfaceStats(const Interface *intf)
bool BuildPhysicalInterfaceList(std::map< std::string, PhyIfStats > &list, std::map< std::string, PhyIfInfo > &info, std::map< std::string, AgentDropStats > &dsmap) const
PhysicalInterfaceSet phy_intf_set_