当前位置: 首页>>代码示例>>Python>>正文


Python HaproxyLogFile.parse_file方法代码示例

本文整理汇总了Python中haproxy.haproxy_logfile.HaproxyLogFile.parse_file方法的典型用法代码示例。如果您正苦于以下问题:Python HaproxyLogFile.parse_file方法的具体用法?Python HaproxyLogFile.parse_file怎么用?Python HaproxyLogFile.parse_file使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在haproxy.haproxy_logfile.HaproxyLogFile的用法示例。


在下文中一共展示了HaproxyLogFile.parse_file方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_haproxy_log_file_cmd_requests_per_minute

# 需要导入模块: from haproxy.haproxy_logfile import HaproxyLogFile [as 别名]
# 或者: from haproxy.haproxy_logfile.HaproxyLogFile import parse_file [as 别名]
    def test_haproxy_log_file_cmd_requests_per_minute(self):
        """Check that the requests per minute command reports as expected."""
        log_file = HaproxyLogFile(
            logfile='haproxy/tests/files/requests_per_minute.log',
        )
        log_file.parse_file()
        requests = log_file.cmd_requests_per_minute()

        self.assertEqual(len(requests), 5)

        self.assertEqual(
            requests[0],
            (datetime(2013, 12, 11, 11, 2), 8)
        )
        self.assertEqual(
            requests[1],
            (datetime(2013, 12, 11, 11, 3), 3)
        )
        self.assertEqual(
            requests[2],
            (datetime(2013, 12, 11, 11, 13), 5)
        )
        self.assertEqual(
            requests[3],
            (datetime(2013, 12, 11, 11, 52), 7)
        )
        self.assertEqual(
            requests[4],
            (datetime(2013, 12, 11, 12, 2), 9)
        )
开发者ID:bogdangi,项目名称:haproxy_log_analysis,代码行数:32,代码来源:test_haproxy_log_file.py

示例2: test_haproxy_log_file_cmd_queue_peaks_no_end

# 需要导入模块: from haproxy.haproxy_logfile import HaproxyLogFile [as 别名]
# 或者: from haproxy.haproxy_logfile.HaproxyLogFile import parse_file [as 别名]
    def test_haproxy_log_file_cmd_queue_peaks_no_end(self):
        """Check that the queue peaks command reports as expected when the
        last log request did not have any queue.
        """
        log_file = HaproxyLogFile(
            logfile='haproxy/tests/files/queue_2.log',
        )
        log_file.parse_file()
        peaks = log_file.cmd_queue_peaks()

        self.assertEqual(len(peaks), 3)
        self.assertEqual(peaks[0]['peak'], 4)
        self.assertEqual(peaks[0]['span'], 5)

        self.assertEqual(peaks[1]['peak'], 19)
        self.assertEqual(peaks[1]['span'], 5)

        self.assertEqual(peaks[2]['peak'], 49)
        self.assertEqual(peaks[2]['span'], 3)

        self.assertTrue(peaks[0]['first'] < peaks[1]['first'])
        self.assertTrue(peaks[1]['first'] < peaks[2]['first'])

        self.assertTrue(peaks[0]['last'] < peaks[1]['last'])
        self.assertTrue(peaks[1]['last'] < peaks[2]['last'])
开发者ID:bogdangi,项目名称:haproxy_log_analysis,代码行数:27,代码来源:test_haproxy_log_file.py

示例3: test_haproxy_log_file_cmd_average_response_time

# 需要导入模块: from haproxy.haproxy_logfile import HaproxyLogFile [as 别名]
# 或者: from haproxy.haproxy_logfile.HaproxyLogFile import parse_file [as 别名]
 def test_haproxy_log_file_cmd_average_response_time(self):
     """Check that the average response time returns the expected output."""
     log_file = HaproxyLogFile(
         logfile='haproxy/tests/files/average_response.log',
     )
     log_file.parse_file()
     data = log_file.cmd_average_response_time()
     self.assertEqual(data, 105)
开发者ID:bogdangi,项目名称:haproxy_log_analysis,代码行数:10,代码来源:test_haproxy_log_file.py

示例4: test_haproxy_log_file_parsed

# 需要导入模块: from haproxy.haproxy_logfile import HaproxyLogFile [as 别名]
# 或者: from haproxy.haproxy_logfile.HaproxyLogFile import parse_file [as 别名]
 def test_haproxy_log_file_parsed(self):
     """Check that log files are parsed."""
     log_file = HaproxyLogFile(
         logfile='haproxy/tests/files/small.log'
     )
     self.assertEqual(log_file.cmd_counter(), 0)
     log_file.parse_file()
     self.assertTrue(log_file.cmd_counter() > 0)
开发者ID:bogdangi,项目名称:haproxy_log_analysis,代码行数:10,代码来源:test_haproxy_log_file.py

示例5: test_haproxy_log_file_total_lines

# 需要导入模块: from haproxy.haproxy_logfile import HaproxyLogFile [as 别名]
# 或者: from haproxy.haproxy_logfile.HaproxyLogFile import parse_file [as 别名]
 def test_haproxy_log_file_total_lines(self):
     """Check that even if some lines are not valid, 'total_lines' counts
     all of them.
     """
     log_file = HaproxyLogFile(
         logfile='haproxy/tests/files/2_ok_1_invalid.log'
     )
     log_file.parse_file()
     self.assertEqual(log_file.total_lines, 3)
开发者ID:bogdangi,项目名称:haproxy_log_analysis,代码行数:11,代码来源:test_haproxy_log_file.py

示例6: main

# 需要导入模块: from haproxy.haproxy_logfile import HaproxyLogFile [as 别名]
# 或者: from haproxy.haproxy_logfile.HaproxyLogFile import parse_file [as 别名]
def main(args):
    if show_help(args):
        return

    # show the command list
    if args['list_commands']:
        print_commands()
        # no need to process further
        return

    # show the filter list
    if args['list_filters']:
        print_filters()
        # no need to process further
        return

    # create a HaproxyLogFile instance and parse the log file
    log_file = HaproxyLogFile(
        logfile=args['log'],
    )
    log_file.parse_file()

    # apply the time frame filter
    if args['start'] is not None or args['delta'] is not None:
        start = args['start'] or ''
        delta = args['delta'] or ''
        filter_string = 'filters.filter_time_frame("{0}", "{1}")'
        filter_func = eval(filter_string.format(start, delta))

        log_file = log_file.filter(filter_func)

    # apply all other filters given
    if args['filters'] is not None:
        filter_string = 'filters.filter_{0}({1})'
        for filter_data in args['filters']:
            arg = ''
            if filter_data[1] is not None:
                arg = filter_data[1]
                arg = "'{0}'".format(arg)

            filter_func = eval(filter_string.format(filter_data[0], arg))

            log_file = log_file.filter(filter_func,
                                       reverse=args['negate_filter'])

    # run all commands
    command_string = 'log_file.cmd_{0}()'
    for command in args['commands']:
        string = 'command: {0}'.format(command)
        print(string)
        print('=' * len(string))

        result = eval(command_string.format(command))
        print(result)

    return log_file  # return the log_file object so that tests can inspect it
开发者ID:triplekill,项目名称:haproxy_log_analysis,代码行数:58,代码来源:main.py

示例7: test_haproxy_log_file_cmd_counter_slow_requests

# 需要导入模块: from haproxy.haproxy_logfile import HaproxyLogFile [as 别名]
# 或者: from haproxy.haproxy_logfile.HaproxyLogFile import parse_file [as 别名]
    def test_haproxy_log_file_cmd_counter_slow_requests(self):
        """Check that the slow requests counter command reports as expected.
        """
        log_file = HaproxyLogFile(
            logfile='haproxy/tests/files/small.log',
        )
        log_file.parse_file()
        slow_requests = log_file.cmd_counter_slow_requests()

        self.assertEqual(slow_requests, 5)
开发者ID:bogdangi,项目名称:haproxy_log_analysis,代码行数:12,代码来源:test_haproxy_log_file.py

示例8: test_haproxy_log_file_cmd_average_response_time_no_wait

# 需要导入模块: from haproxy.haproxy_logfile import HaproxyLogFile [as 别名]
# 或者: from haproxy.haproxy_logfile.HaproxyLogFile import parse_file [as 别名]
 def test_haproxy_log_file_cmd_average_response_time_no_wait(self):
     """Check that the average response time returns the expected output
     when there are connections that did not take any millisecond to reply.
     """
     log_file = HaproxyLogFile(
         logfile='haproxy/tests/files/average_response_no_wait.log',
     )
     log_file.parse_file()
     data = log_file.cmd_average_response_time()
     self.assertEqual(data, 74)
开发者ID:abourget,项目名称:haproxy_log_analysis,代码行数:12,代码来源:test_haproxy_log_file.py

示例9: test_haproxy_log_file_cmd_connection_type

# 需要导入模块: from haproxy.haproxy_logfile import HaproxyLogFile [as 别名]
# 或者: from haproxy.haproxy_logfile.HaproxyLogFile import parse_file [as 别名]
    def test_haproxy_log_file_cmd_connection_type(self):
        """Check that the connection type command reports as expected."""
        log_file = HaproxyLogFile(
            logfile='haproxy/tests/files/connection.log',
        )
        log_file.parse_file()
        ssl, non_ssl = log_file.cmd_connection_type()

        self.assertEqual(ssl, 7)
        self.assertEqual(non_ssl, 5)
开发者ID:bogdangi,项目名称:haproxy_log_analysis,代码行数:12,代码来源:test_haproxy_log_file.py

示例10: test_haproxy_log_file_cmd_average_waiting_time_aborted

# 需要导入模块: from haproxy.haproxy_logfile import HaproxyLogFile [as 别名]
# 或者: from haproxy.haproxy_logfile.HaproxyLogFile import parse_file [as 别名]
 def test_haproxy_log_file_cmd_average_waiting_time_aborted(self):
     """Check that the average time waiting on queues returns the expected
     output when there are aborted connections.
     """
     log_file = HaproxyLogFile(
         logfile='haproxy/tests/files/average_waiting_aborted.log',
     )
     log_file.parse_file()
     data = log_file.cmd_average_waiting_time()
     self.assertEqual(data, 110)
开发者ID:bogdangi,项目名称:haproxy_log_analysis,代码行数:12,代码来源:test_haproxy_log_file.py

示例11: test_haproxy_log_file_valid_and_invalid_lines

# 需要导入模块: from haproxy.haproxy_logfile import HaproxyLogFile [as 别名]
# 或者: from haproxy.haproxy_logfile.HaproxyLogFile import parse_file [as 别名]
 def test_haproxy_log_file_valid_and_invalid_lines(self):
     """Check that if some log lines can not be parsed both numbers are
     correctly reported.
     """
     log_file = HaproxyLogFile(
         logfile='haproxy/tests/files/2_ok_1_invalid.log'
     )
     log_file.parse_file()
     self.assertEqual(log_file.cmd_counter(), 2)
     self.assertEqual(log_file.cmd_counter_invalid(), 1)
开发者ID:bogdangi,项目名称:haproxy_log_analysis,代码行数:12,代码来源:test_haproxy_log_file.py

示例12: test_haproxy_log_file_cmd_print_empty

# 需要导入模块: from haproxy.haproxy_logfile import HaproxyLogFile [as 别名]
# 或者: from haproxy.haproxy_logfile.HaproxyLogFile import parse_file [as 别名]
 def test_haproxy_log_file_cmd_print_empty(self):
     """Check that the print command prints an empty string if the log file
     is empty.
     """
     log_file = HaproxyLogFile(
         logfile='haproxy/tests/files/empty.log',
     )
     log_file.parse_file()
     data = log_file.cmd_print()
     self.assertEqual('', data)
开发者ID:bogdangi,项目名称:haproxy_log_analysis,代码行数:12,代码来源:test_haproxy_log_file.py

示例13: test_haproxy_log_file_cmd_print

# 需要导入模块: from haproxy.haproxy_logfile import HaproxyLogFile [as 别名]
# 或者: from haproxy.haproxy_logfile.HaproxyLogFile import parse_file [as 别名]
    def test_haproxy_log_file_cmd_print(self):
        """Check that the print command prints the valid lines."""
        log_file = HaproxyLogFile(
            logfile='haproxy/tests/files/2_ok_1_invalid.log',
        )
        log_file.parse_file()
        data = log_file.cmd_print()
        self.assertNotEqual('', data)

        lines = data.split('\n')
        self.assertEqual(len(lines), 3)
开发者ID:bogdangi,项目名称:haproxy_log_analysis,代码行数:13,代码来源:test_haproxy_log_file.py

示例14: test_haproxy_log_file_cmd_average_waiting_time_no_wait

# 需要导入模块: from haproxy.haproxy_logfile import HaproxyLogFile [as 别名]
# 或者: from haproxy.haproxy_logfile.HaproxyLogFile import parse_file [as 别名]
 def test_haproxy_log_file_cmd_average_waiting_time_no_wait(self):
     """Check that the average time waiting on queues returns the expected
     output when there are requests that did not wait at all (i.e.
     time_wait_queues is 0).
     """
     log_file = HaproxyLogFile(
         logfile='haproxy/tests/files/average_waiting_no_wait.log',
     )
     log_file.parse_file()
     data = log_file.cmd_average_waiting_time()
     self.assertEqual(data, 52.5)
开发者ID:abourget,项目名称:haproxy_log_analysis,代码行数:13,代码来源:test_haproxy_log_file.py

示例15: test_haproxy_log_file_cmd_requests_per_minute_empty

# 需要导入模块: from haproxy.haproxy_logfile import HaproxyLogFile [as 别名]
# 或者: from haproxy.haproxy_logfile.HaproxyLogFile import parse_file [as 别名]
    def test_haproxy_log_file_cmd_requests_per_minute_empty(self):
        """Check that the requests per minute command reports nothing if
        there are no valid lines for whichever reason.
        """
        log_file = HaproxyLogFile(
            logfile='haproxy/tests/files/empty.log',
        )
        log_file.parse_file()
        requests = log_file.cmd_requests_per_minute()

        self.assertEqual(None, requests)
开发者ID:bogdangi,项目名称:haproxy_log_analysis,代码行数:13,代码来源:test_haproxy_log_file.py


注:本文中的haproxy.haproxy_logfile.HaproxyLogFile.parse_file方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。