def cmd_stats_line (self, line):
        '''Fetch statistics from TRex server by port\n'''
        # define a parser
        parser = parsing_opts.gen_parser(self,
                                         "stats",
                                         self.cmd_stats_line.__doc__,
                                         parsing_opts.PORT_LIST_WITH_ALL,
                                         parsing_opts.STATS_MASK)

        opts = parser.parse_args(line.split())

        if opts is None:
            return RC_ERR("bad command line parameters")

        # determine stats mask
        mask = self._get_mask_keys(**self._filter_namespace_args(opts, trex_stats.ALL_STATS_OPTS))
        if not mask:
            # set to show all stats if no filter was given
            mask = trex_stats.ALL_STATS_OPTS

        stats = self.cmd_stats(opts.ports, mask)

        # print stats to screen
        for stat_type, stat_data in stats.iteritems():
            text_tables.print_table_with_header(stat_data.text_table, stat_type)


        return RC_OK()
    def cmd_streams_line(self, line):
        '''Fetch streams statistics from TRex server by port\n'''
        # define a parser
        parser = parsing_opts.gen_parser(self,
                                         "streams",
                                         self.cmd_streams_line.__doc__,
                                         parsing_opts.PORT_LIST_WITH_ALL,
                                         parsing_opts.STREAMS_MASK)#,
                                         #parsing_opts.FULL_OUTPUT)

        opts = parser.parse_args(line.split())

        if opts is None:
            return RC_ERR("bad command line parameters")

        streams = self.cmd_streams(opts.ports, set(opts.streams))
        if not streams:
            # we got no streams running

            print format_text("No streams found with desired filter.\n", "bold", "magenta")
            return RC_ERR("No streams found with desired filter.")
        else:
            # print stats to screen
            for stream_hdr, port_streams_data in streams.iteritems():
                text_tables.print_table_with_header(port_streams_data.text_table,
                                                    header= stream_hdr.split(":")[0] + ":",
                                                    untouched_header= stream_hdr.split(":")[1])
            return RC_OK()
示例#3
0
文件: trex_tui.py 项目: lb1wh/trex
 def show(self):
     stats = self.stateless_client._get_formatted_stats(
         self.ports, trex_stats.COMPACT)
     # print stats to screen
     for stat_type, stat_data in stats.items():
         text_tables.print_table_with_header(stat_data.text_table,
                                             stat_type)
    def cmd_stats_line(self, line):
        '''Fetch statistics from TRex server by port\n'''
        # define a parser
        parser = parsing_opts.gen_parser(self, "stats",
                                         self.cmd_stats_line.__doc__,
                                         parsing_opts.PORT_LIST_WITH_ALL,
                                         parsing_opts.STATS_MASK)

        opts = parser.parse_args(line.split())

        if opts is None:
            return RC_ERR("bad command line parameters")

        # determine stats mask
        mask = self._get_mask_keys(
            **self._filter_namespace_args(opts, trex_stats.ALL_STATS_OPTS))
        if not mask:
            # set to show all stats if no filter was given
            mask = trex_stats.ALL_STATS_OPTS

        stats = self.cmd_stats(opts.ports, mask)

        # print stats to screen
        for stat_type, stat_data in stats.iteritems():
            text_tables.print_table_with_header(stat_data.text_table,
                                                stat_type)

        return RC_OK()
示例#5
0
 def show (self):
     stats = self.stateless_client.cmd_stats(self.ports, trex_stats.COMPACT)
     # print stats to screen
     for stat_type, stat_data in stats.iteritems():
         text_tables.print_table_with_header(stat_data.text_table, stat_type)
示例#6
0
 def show (self):
     stats = self.stateless_client.cmd_stats([self.port_id], trex_stats.COMPACT)
     # print stats to screen
     for stat_type, stat_data in stats.iteritems():
         text_tables.print_table_with_header(stat_data.text_table, stat_type)