LCOV - code coverage report
Current view: top level - vnsw/agent/oper - agent_profile.h (source / functions) Hit Total Coverage
Test: OpenSDN C/C++ coverage (all TARGET_SET jobs) Lines: 3 5 60.0 %
Date: 2026-11-09 02:10:49 Functions: 3 5 60.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.14