OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
agent_profile.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Juniper Networks, Inc. All rights reserved.
3  */
4 #ifndef SRC_VNSW_AGENT_OPER_PROFILE_H_
5 #define SRC_VNSW_AGENT_OPER_PROFILE_H_
6 #include "db/db.h"
7 class Agent;
8 class Timer;
9 
10 class ProfileData {
11 public:
12  ProfileData();
14  struct WorkQueueStats {
15  std::string name_;
16  uint64_t queue_count_;
17  uint64_t enqueue_count_;
18  uint64_t dequeue_count_;
19  uint64_t max_queue_count_;
20  uint64_t start_count_;
21  uint64_t busy_time_;
22  void Reset();
23  void Get();
24  };
25 
26  struct FlowTokenStats {
27  uint32_t add_tokens_;
28  uint64_t add_failures_;
29  uint64_t add_restarts_;
30  uint32_t ksync_tokens_;
31  uint64_t ksync_failures_;
32  uint64_t ksync_restarts_;
33  uint32_t update_tokens_;
34  uint64_t update_failures_;
35  uint64_t update_restarts_;
36  uint32_t del_tokens_;
37  uint64_t del_failures_;
38  uint64_t del_restarts_;
39  void Reset();
40  };
41 
42  struct DBTableStats {
43  uint64_t db_entry_count_;
44  uint64_t walker_count_;
45  uint64_t enqueue_count_;
46  uint64_t input_count_;
47  uint64_t notify_count_;
48  void Get(const DBTable *table);
49  void Accumulate(const DBTableBase *table);
50  void Reset();
51  };
52 
53  struct FlowStats {
54  uint64_t flow_count_;
55  uint64_t add_count_;
56  uint64_t del_count_;
57  uint64_t audit_count_;
58  uint64_t reval_count_;
59  uint64_t recompute_count_;
61  uint64_t vrouter_error_;
62  uint64_t evict_count_;
67  std::vector<WorkQueueStats> flow_event_queue_;
68  std::vector<WorkQueueStats> flow_tokenless_queue_;
69  std::vector<WorkQueueStats> flow_delete_queue_;
70  std::vector<WorkQueueStats> flow_ksync_queue_;
71  std::vector<WorkQueueStats> flow_stats_queue_;
72  void Get();
73  void Reset();
74  };
75 
76  struct PktStats {
77  uint64_t arp_count_;
78  uint64_t dhcp_count_;
79  uint64_t dns_count_;
80  uint64_t icmp_count_;
81  void Get();
82  void Reset();
83  };
84 
85  struct XmppStats {
86  uint64_t inet4_add_count_;
87  uint64_t inet4_del_count_;
88  uint64_t inet6_add_count_;
89  uint64_t inet6_del_count_;
90  uint64_t mcast_add_count_;
91  uint64_t mcast_del_count_;
94  void Get();
95  void Reset();
96  };
97 
98  struct NovaIpcStats {
99  uint64_t add_count_;
100  uint64_t del_count_;
101  void Get();
102  };
103 
104  void Get(Agent *agent);
105 public:
106  std::string time_;
119  std::map<std::string, DBTableStats > profile_stats_table_;
120 };
121 
123 public:
124  static const uint32_t kProfileTimeout = 1000;
125  static const uint16_t kSecondsHistoryCount = 300;
126  static const uint16_t kMinutesHistoryCount = 60;
127  static const uint16_t kHoursHistoryCount = 24;
128  typedef boost::function<void(ProfileData *data)> PktFlowStatsCb;
129  typedef boost::function<void(ProfileData *data)> KSyncStatsCb;
130  typedef boost::function<void(ProfileData *data)> ProfileCb;
131 
132  AgentProfile(Agent *agent, bool enable);
133  ~AgentProfile();
134  bool Init();
135  void Shutdown();
136  void InitDone();
137 
138  bool TimerRun();
139  void Log();
140 
144  void AddProfileData(ProfileData *data);
145  ProfileData *GetProfileData(uint16_t index);
146  uint16_t seconds_history_index() const { return seconds_history_index_; }
147  private:
149 
152  time_t start_time_;
153  bool enable_;
154 
164 
171 
176 };
177 
178 #endif // SRC_VNSW_AGENT_OPER_PROFILE_H_
XmppStats rx_stats_
Agent * agent_
WorkQueueStats flow_update_queue_
Definition: agent_profile.h:66
std::vector< WorkQueueStats > flow_delete_queue_
Definition: agent_profile.h:69
void RegisterPktFlowStatsCb(ProfileCb cb)
time_t start_time_
ProfileData twentyfour_hr_data_
uint16_t seconds_history_index() const
ProfileCb ksync_stats_cb_
void RegisterFlowStatsCb(ProfileCb cb)
void Get(const DBTable *table)
std::map< std::string, DBTableStats > profile_stats_table_
WorkQueueStats ksync_rx_queue_count_
AgentProfile(Agent *agent, bool enable)
WorkQueueStats pkt_handler_queue_
Definition: agent_profile.h:64
DISALLOW_COPY_AND_ASSIGN(AgentProfile)
DBTableStats evpn_routes_
ProfileData * GetProfileData(uint16_t index)
static const uint32_t kProfileTimeout
std::vector< WorkQueueStats > flow_ksync_queue_
Definition: agent_profile.h:70
XmppStats tx_stats_
ProfileData seconds_history_data_[kSecondsHistoryCount]
ProfileData minutes_history_data_[kMinutesHistoryCount]
boost::function< void(ProfileData *data)> KSyncStatsCb
ProfileData eight_hr_data_
std::string time_
void RegisterKSyncStatsCb(ProfileCb cb)
uint16_t seconds_history_index_
ProfileData fifteen_min_data_
ProfileData sixteen_hr_data_
Definition: task.h:26
Definition: agent.h:358
boost::function< void(ProfileData *data)> ProfileCb
static const uint16_t kSecondsHistoryCount
static const uint16_t kMinutesHistoryCount
WorkQueueStats flow_mgmt_queue_
Definition: agent_profile.h:65
DBTableStats inet6_routes_
std::vector< WorkQueueStats > flow_event_queue_
Definition: agent_profile.h:67
ProfileData hours_history_data_[kHoursHistoryCount]
void Get(Agent *agent)
FlowStats flow_
uint16_t minutes_history_index_
FlowTokenStats token_stats_
Definition: agent_profile.h:63
ProfileData * GetLastProfileData()
ProfileData thirty_min_data_
DBTableStats bridge_routes_
void Accumulate(const DBTableBase *table)
static const uint16_t kHoursHistoryCount
ProfileData five_min_data_
WorkQueueStats ksync_tx_queue_count_
DBTableStats multicast_routes_
void AddProfileData(ProfileData *data)
TaskStats task_stats_[24]
std::vector< WorkQueueStats > flow_stats_queue_
Definition: agent_profile.h:71
Definition: timer.h:54
DBTableStats inet4_routes_
std::vector< WorkQueueStats > flow_tokenless_queue_
Definition: agent_profile.h:68
ProfileData one_hr_data_
Timer * timer_
ProfileCb pkt_flow_stats_cb_
ProfileData one_min_data_
ProfileCb flow_stats_cb_
PktStats pkt_
boost::function< void(ProfileData *data)> PktFlowStatsCb
uint16_t hours_history_index_
ProfileData four_hr_data_