OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
peer_stats.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 Juniper Networks, Inc. All rights reserved.
3  */
4 
5 #include "bgp/peer_stats.h"
6 
8  PeerProtoStats *proto_stats) {
9  proto_stats->set_open(stats.open);
10  proto_stats->set_keepalive(stats.keepalive);
11  proto_stats->set_close(stats.close);
12  proto_stats->set_update(stats.update);
13  proto_stats->set_notification(stats.notification);
14  proto_stats->set_total(stats.open + stats.keepalive + stats.close +
15  stats.update + stats.notification);
16 }
17 
19  PeerUpdateStats *rt_stats) {
20  rt_stats->set_total(stats.total);
21  rt_stats->set_reach(stats.reach);
22  rt_stats->set_unreach(stats.unreach);
23 }
24 
26  PeerRxErrorStats *dest) {
27  PeerRxInet6ErrorStats error_stats;
28  error_stats.set_bad_inet6_xml_token_count(src.inet6_bad_xml_token_count);
29  error_stats.set_bad_inet6_prefix_count(src.inet6_bad_prefix_count);
30  error_stats.set_bad_inet6_nexthop_count(src.inet6_bad_nexthop_count);
31  error_stats.set_bad_inet6_afi_safi_count(src.inet6_bad_afi_safi_count);
32  dest->set_inet6_error_stats(error_stats);
33 }
34 
36  PeerRxRouteStats *dest) {
37  dest->set_total_path_count(src.total_path_count);
38  dest->set_primary_path_count(src.primary_path_count);
39 }
40 
42  PeerUpdateStats *rt_stats_rx,
43  PeerUpdateStats *rt_stats_tx) {
44 
45  IPeerDebugStats::UpdateStats update_stats_rx;
46  peer_stats->GetRxRouteUpdateStats(&update_stats_rx);
47  FillRouteUpdateStats(update_stats_rx, rt_stats_rx);
48 
49  IPeerDebugStats::UpdateStats update_stats_tx;
50  peer_stats->GetTxRouteUpdateStats(&update_stats_tx);
51  FillRouteUpdateStats(update_stats_tx, rt_stats_tx);
52 }
53 
55  PeerStatsData *peer_stats_data) {
56  PeerUpdateStats stats_rx;
57  PeerUpdateStats stats_tx;
58 
59  FillPeerUpdateStats(peer_stats, &stats_rx, &stats_tx);
60  peer_stats_data->set_raw_rx_update_stats(stats_rx);
61  peer_stats_data->set_raw_tx_update_stats(stats_tx);
62 }
63 
65  PeerStatsInfo *stats) {
66  PeerProtoStats proto_stats_tx;
67  PeerProtoStats proto_stats_rx;
68  PeerUpdateStats rt_stats_rx;
69  PeerUpdateStats rt_stats_tx;
70  PeerRxErrorStats dest_error_stats_rx;
71  PeerRxRouteStats dest_route_stats_rx;
72 
74  peer_stats->GetRxProtoStats(&stats_rx);
75  FillProtoStats(stats_rx, &proto_stats_rx);
76 
78  peer_stats->GetTxProtoStats(&stats_tx);
79  FillProtoStats(stats_tx, &proto_stats_tx);
80 
81  FillPeerUpdateStats(peer_stats, &rt_stats_rx, &rt_stats_tx);
82 
83  IPeerDebugStats::RxErrorStats src_error_stats_rx;
84  peer_stats->GetRxErrorStats(&src_error_stats_rx);
85  FillRxErrorStats(src_error_stats_rx, &dest_error_stats_rx);
86 
87  IPeerDebugStats::RxRouteStats src_route_stats_rx;
88  peer_stats->GetRxRouteStats(&src_route_stats_rx);
89  FillRxRouteStats(src_route_stats_rx, &dest_route_stats_rx);
90 
91  stats->set_rx_proto_stats(proto_stats_rx);
92  stats->set_tx_proto_stats(proto_stats_tx);
93  stats->set_rx_update_stats(rt_stats_rx);
94  stats->set_tx_update_stats(rt_stats_tx);
95  stats->set_rx_error_stats(dest_error_stats_rx);
96  stats->set_rx_route_stats(dest_route_stats_rx);
97 }
tbb::atomic< uint64_t > unreach
Definition: ipeer.h:107
virtual void GetRxErrorStats(RxErrorStats *stats) const =0
virtual void GetTxRouteUpdateStats(UpdateStats *stats) const =0
static void FillRxRouteStats(const IPeerDebugStats::RxRouteStats &src, PeerRxRouteStats *dest)
Definition: peer_stats.cc:35
tbb::atomic< uint64_t > total
Definition: ipeer.h:105
static void FillRxErrorStats(const IPeerDebugStats::RxErrorStats &src, PeerRxErrorStats *dest)
Definition: peer_stats.cc:25
tbb::atomic< uint64_t > close
Definition: ipeer.h:57
virtual void GetRxRouteStats(RxRouteStats *stats) const =0
static void FillPeerUpdateStats(const IPeerDebugStats *peer_stats, PeerStatsData *peer_stats_data)
Definition: peer_stats.cc:54
tbb::atomic< uint64_t > primary_path_count
Definition: ipeer.h:94
static void FillProtoStats(const IPeerDebugStats::ProtoStats &stats, PeerProtoStats *proto_stats)
Definition: peer_stats.cc:7
tbb::atomic< uint64_t > inet6_bad_nexthop_count
Definition: ipeer.h:84
tbb::atomic< uint64_t > notification
Definition: ipeer.h:55
tbb::atomic< uint64_t > reach
Definition: ipeer.h:106
tbb::atomic< uint64_t > total_path_count
Definition: ipeer.h:93
static void FillRouteUpdateStats(const IPeerDebugStats::UpdateStats &stats, PeerUpdateStats *rt_stats)
Definition: peer_stats.cc:18
static void FillPeerDebugStats(const IPeerDebugStats *peer_stats, PeerStatsInfo *stats)
Definition: peer_stats.cc:64
tbb::atomic< uint64_t > inet6_bad_prefix_count
Definition: ipeer.h:83
virtual void GetRxProtoStats(ProtoStats *stats) const =0
tbb::atomic< uint64_t > open
Definition: ipeer.h:53
tbb::atomic< uint64_t > keepalive
Definition: ipeer.h:54
tbb::atomic< uint64_t > update
Definition: ipeer.h:56
virtual void GetTxProtoStats(ProtoStats *stats) const =0
tbb::atomic< uint64_t > inet6_bad_afi_safi_count
Definition: ipeer.h:85
tbb::atomic< uint64_t > inet6_bad_xml_token_count
Definition: ipeer.h:82
virtual void GetRxRouteUpdateStats(UpdateStats *stats) const =0