Exemplo n.º 1
0
    def sandesh_stats_handle_request(self, sandesh_req):
        sandesh_stats = self._sandesh.stats()
        stats_map = sandesh_stats.stats_map()
        stats_list = []
        for sandesh_name, stats in stats_map.iteritems():
            msg_stat = SandeshMessageStats(stats.tx_count, stats.tx_bytes,
                                           stats.rx_count, stats.rx_bytes)
            mtype_stat = SandeshMessageTypeStats(sandesh_name, msg_stat)
            stats_list.append(mtype_stat)

        gen_stats = SandeshGeneratorStats()
        gen_stats.type_stats = stats_list
        gen_stats.aggregate_stats = SandeshMessageStats()
        gen_stats.aggregate_stats.messages_sent = sandesh_stats._sandesh_sent
        gen_stats.aggregate_stats.bytes_sent = sandesh_stats._bytes_sent
        gen_stats.aggregate_stats.messages_received = \
            sandesh_stats._sandesh_received
        gen_stats.aggregate_stats.bytes_received = \
            sandesh_stats._bytes_received
        connection = self._sandesh.client().connection()
        if connection and connection.session():
            session = connection.session()
            squeue = session.send_queue()
            send_queue_stats = SandeshQueueStats()
            send_queue_stats.enqueues = \
                squeue.num_enqueues()
            send_queue_stats.count = \
                squeue.num_enqueues() - squeue.num_dequeues()
            gen_stats.send_queue_stats = send_queue_stats
        stats_resp = SandeshMessageStatsResp(gen_stats)
        stats_resp.response(sandesh_req.context())
Exemplo n.º 2
0
 def update_rx_stats(self, message_type, nbytes,
                     drop_reason=SandeshRxDropReason.NoDrop):
     if SandeshRxDropReason.MinDropReason < drop_reason < \
        SandeshRxDropReason.MaxDropReason:
         try:
             message_stats = self._message_type_stats[message_type]
         except KeyError:
             message_stats = SandeshMessageStats()
             self._message_type_stats[message_type] = message_stats
         finally:
             self._update_rx_stats_internal(message_stats, nbytes,
                                            drop_reason)
             self._update_rx_stats_internal(self._aggregate_stats, nbytes,
                                            drop_reason)
             return True
     return False
Exemplo n.º 3
0
 def __init__(self):
     self._message_type_stats = {}
     self._aggregate_stats = SandeshMessageStats()