Line data Source code
1 : /* 2 : * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved. 3 : */ 4 : 5 : #ifndef __SANDESH_STATISTICS_H__ 6 : #define __SANDESH_STATISTICS_H__ 7 : 8 : #include <boost/ptr_container/ptr_map.hpp> 9 : #include <sandesh/sandesh_uve_types.h> 10 : 11 : class SandeshMessageStatistics { 12 : public: 13 301 : SandeshMessageStatistics() {deleted_ = false;} 14 : 15 : void UpdateSend(const std::string &msg_name, uint64_t bytes); 16 : void UpdateSendFailed(const std::string &msg_name, uint64_t bytes, 17 : SandeshTxDropReason::type dreason); 18 : void UpdateRecv(const std::string &msg_name, uint64_t bytes); 19 : void UpdateRecvFailed(const std::string &msg_name, uint64_t bytes, 20 : SandeshRxDropReason::type dreason); 21 : void Clear(); 22 : 23 : // Detail statistics 24 : typedef boost::ptr_map<std::string, SandeshMessageTypeStats> 25 : DetailStatsMap; 26 : typedef std::vector<SandeshMessageTypeStats> DetailStatsList; 27 : 28 : void Get(DetailStatsList *v_detail_type_stats, 29 : SandeshMessageStats *detail_agg_stats) const; 30 : void Get(DetailStatsMap *m_detail_type_stats, 31 : SandeshMessageStats *detail_agg_stats) const; 32 : 33 : // Basic statistics 34 : typedef std::vector<SandeshMessageTypeBasicStats> BasicStatsList; 35 : 36 : void Get(BasicStatsList *v_basic_type_stats, 37 : SandeshMessageBasicStats *basic_agg_stats) const; 38 : void Shutdown(); 39 : 40 : private: 41 : bool deleted_; 42 : void UpdateInternal(const std::string &msg_name, 43 : uint64_t bytes, bool is_tx, bool dropped, 44 : SandeshTxDropReason::type send_dreason, 45 : SandeshRxDropReason::type recv_dreason); 46 : 47 : DetailStatsMap detail_type_stats_map_; 48 : SandeshMessageStats detail_agg_stats_; 49 : }; 50 : 51 : class SandeshEventStatistics { 52 : public: 53 0 : SandeshEventStatistics() {deleted_ = false;} 54 : 55 : void Update(std::string &event_name, bool enqueue, bool fail); 56 : void Get(std::vector<SandeshStateMachineEvStats> *ev_stats) const; 57 : void Shutdown(); 58 : 59 : typedef boost::ptr_map<std::string, SandeshStateMachineEvStats> EventStatsMap; 60 : EventStatsMap event_stats_; 61 : SandeshStateMachineEvStats agg_stats_; 62 : private: 63 : bool deleted_; 64 : }; 65 : 66 : #endif // __SANDESH_STATISTICS_H__