Example #1
0
    def __init__(self, include_lists=None):
        """ Initializes profile log for cluster node stats.
    Renders header according to include_lists in advance and
    creates base directory for node stats profile log.

    Args:
      include_lists: An instance of IncludeLists describing which fields
        of node stats should be written to CSV log.
    """
        self._include_lists = include_lists
        self._header = (converter.get_stats_header(
            node_stats.NodeStatsSnapshot, self._include_lists))
        helper.ensure_directory(PROFILE_LOG_DIR)
Example #2
0
  def __init__(self, include_lists=None):
    """ Initializes profile log for cluster node stats.
    Renders header according to include_lists in advance and
    creates base directory for node stats profile log.

    Args:
      include_lists: An instance of IncludeLists describing which fields
        of node stats should be written to CSV log.
    """
    self._include_lists = include_lists
    self._header = (
      converter.get_stats_header(node_stats.NodeStatsSnapshot,
                                 self._include_lists)
    )
    helper.ensure_directory(PROFILE_LOG_DIR)
Example #3
0
  def _prepare_file(self, node_ip):
    """ Prepares CSV file with name node/<node-IP>.csv
    for appending new lines.

    Args:
      node_ip: A string representation of node IP.
    Returns:
      A file object opened for appending new data.
    """
    node_dir = path.join(PROFILE_LOG_DIR, node_ip)
    file_name = path.join(node_dir, 'node.csv')
    if not path.isfile(file_name):
      helper.ensure_directory(node_dir)
      # Create file and write header
      with open(file_name, 'w') as csv_file:
        csv.writer(csv_file).writerow(self._header)
    # Open table for appending data
    return open(file_name, 'a')
Example #4
0
  def _prepare_file(self, node_ip):
    """ Prepares CSV file with name node/<node-IP>.csv
    for appending new lines.

    Args:
      node_ip: A string representation of node IP.
    Returns:
      A file object opened for appending new data.
    """
    node_dir = path.join(PROFILE_LOG_DIR, node_ip)
    file_name = path.join(node_dir, 'node.csv')
    if not path.isfile(file_name):
      helper.ensure_directory(node_dir)
      # Create file and write header
      with open(file_name, 'w') as csv_file:
        csv.writer(csv_file).writerow(self._header)
    # Open table for appending data
    return open(file_name, 'a')
Example #5
0
    def __init__(self, include_lists=None):
        """ Initializes profile log for cluster processes stats.
    Renders header according to include_lists in advance and
    creates base directory for processes stats profile log.
    It also reads header of summary file (if it exists) to identify
    order of columns.

    Args:
      include_lists: An instance of IncludeLists describing which fields
        of processes stats should be written to CSV log.
    """
        self._include_lists = include_lists
        self._header = (['utc_timestamp'] + converter.get_stats_header(
            process_stats.ProcessStats, self._include_lists))
        self.write_detailed_stats = False
        helper.ensure_directory(PROFILE_LOG_DIR)
        self._summary_file_name_template = 'summary-{resource}.csv'
        self._summary_columns = self._get_summary_columns()
Example #6
0
  def _prepare_file(self, node_ip, pxname):
    """ Prepares CSV file with name <node-IP>/<pxname>.csv
    for appending new lines.

    Args:
      node_ip: A string representation of load balancer node IP.
      pxname: A string name of proxy as it's shown haproxy stats.
    Returns:
      A file object opened for appending new data.
    """
    proxies_dir = path.join(PROFILE_LOG_DIR, node_ip, 'proxies')
    file_name = path.join(proxies_dir, '{}.csv'.format(pxname))
    if not path.isfile(file_name):
      helper.ensure_directory(proxies_dir)
      # Create file and write header
      with open(file_name, 'w') as csv_file:
        csv.writer(csv_file).writerow(self._header)
    # Open file for appending new data
    return open(file_name, 'a')
Example #7
0
  def _prepare_file(self, node_ip, pxname):
    """ Prepares CSV file with name <node-IP>/<pxname>.csv
    for appending new lines.

    Args:
      node_ip: A string representation of load balancer node IP.
      pxname: A string name of proxy as it's shown haproxy stats.
    Returns:
      A file object opened for appending new data.
    """
    proxies_dir = path.join(PROFILE_LOG_DIR, node_ip, 'proxies')
    file_name = path.join(proxies_dir, '{}.csv'.format(pxname))
    if not path.isfile(file_name):
      helper.ensure_directory(proxies_dir)
      # Create file and write header
      with open(file_name, 'w') as csv_file:
        csv.writer(csv_file).writerow(self._header)
    # Open file for appending new data
    return open(file_name, 'a')
Example #8
0
  def __init__(self, include_lists=None):
    """ Initializes profile log for cluster processes stats.
    Renders header according to include_lists in advance and
    creates base directory for processes stats profile log.
    It also reads header of summary file (if it exists) to identify
    order of columns.

    Args:
      include_lists: An instance of IncludeLists describing which fields
        of processes stats should be written to CSV log.
    """
    self._include_lists = include_lists
    self._header = (
      ['utc_timestamp']
       + converter.get_stats_header(proxy_stats.ProxyStats, self._include_lists)
    )
    self.write_detailed_stats = False
    helper.ensure_directory(PROFILE_LOG_DIR)
    self._summary_file_name_template = 'summary-{property}.csv'
    self._summary_columns = self._get_summary_columns()