(
    profile_oid_collection,
    oid_node,
    mibs_directories,
    json_mib_directory,
    metric_tag_aliases_path,
    source,
    compiled_mibs_path,
)
Updates a collection of profile nodes, indexed by oid, adding indexes if found in oid_node
Updates a collection of profile nodes, indexed by oid, adding indexes if found in oid_node
Updates a collection of profile nodes indexed by oid adding indexes if found in oid_node
def _add_profile_row_node(
    profile_oid_collection,
    oid_node,
    mibs_directories,
    json_mib_directory,
    metric_tag_aliases_path,
    source,
    compiled_mibs_path,
):
    """
    Updates a collection of profile nodes, indexed by oid, adding indexes if found in oid_node
    """
    if oid_node.node_type != 'row':
        raise ValueError('Must be a row node')

    # return without any change when no index is available
    if oid_node.indices is None:
        return

    # load aliases
    aliases = None
    if metric_tag_aliases_path is not None:
        aliases = _load_aliases_from_yaml(metric_tag_aliases_path)

    # Row objects are table entry, often defining indexing for table rows
    # Table oids are defined as:
    # <TABLE_OID>.<TABLE_ENTRY>
    # where <TABLE_ENTRY> is always 1
    oid = oid_node.oid
    table_oid = '.'.join(oid.split('.')[:-1])
    if table_oid not in profile_oid_collection:
        # create table if it does not exist yet
        table = {'OID': table_oid}
        profile_node = {'table': table, 'symbols': [], 'metric_tags': []}
        profile_oid_collection[table_oid] = profile_node

    metric_tags = []
    for item in oid_node.indices:
        mib = item.index_module
        oid_name = item.index_name
        # look for an alias
        alias_key = '{}:{}'.format(mib, oid_name)
        if aliases is not None and alias_key in aliases:
            alias = aliases[alias_key]
            mib = alias['MIB']
            oid_name = alias['name']

        index = {'MIB': mib, 'tag': oid_name}
        column = {'name': oid_name}
        index_oid = _find_oid_by_name(mib, oid_name, mibs_directories, json_mib_directory, source, compiled_mibs_path)
        if index_oid is not None:
            column['OID'] = index_oid
            index_table_oid = '.'.join(index_oid.split('.')[:-2])
            index_table_name = _find_name_by_oid(
                mib, index_table_oid, mibs_directories, json_mib_directory, source, compiled_mibs_path
            )
            if index_table_name is not None:
                index['table'] = index_table_name
        index['column'] = column
        metric_tags.append(index)

    profile_oid_collection[table_oid]['metric_tags'] = metric_tags
def _add_profile_row_node ( profile_oid_collection , oid_node , mibs_directories , json_mib_directory , metric_tag_aliases_path , source , compiled_mibs_path , ) : if oid_node . node_type != 'row' : raise ValueError ( 'Must be a row node' ) # return without any change when no index is available if oid_node . indices is None : return # load aliases aliases = None if metric_tag_aliases_path is not None : aliases = _load_aliases_from_yaml ( metric_tag_aliases_path ) # Row objects are table entry, often defining indexing for table rows # Table oids are defined as: # <TABLE_OID>.<TABLE_ENTRY> # where <TABLE_ENTRY> is always 1 oid = oid_node . oid table_oid = '.' . join ( oid . split ( '.' ) [ : - 1 ] ) if table_oid not in profile_oid_collection : # create table if it does not exist yet table = { 'OID' : table_oid } profile_node = { 'table' : table , 'symbols' : [ ] , 'metric_tags' : [ ] } profile_oid_collection [ table_oid ] = profile_node metric_tags = [ ] for item in oid_node . indices : mib = item . index_module oid_name = item . index_name # look for an alias alias_key = '{}:{}' . format ( mib , oid_name ) if aliases is not None and alias_key in aliases : alias = aliases [ alias_key ] mib = alias [ 'MIB' ] oid_name = alias [ 'name' ] index = { 'MIB' : mib , 'tag' : oid_name } column = { 'name' : oid_name } index_oid = _find_oid_by_name ( mib , oid_name , mibs_directories , json_mib_directory , source , compiled_mibs_path ) if index_oid is not None : column [ 'OID' ] = index_oid index_table_oid = '.' . join ( index_oid . split ( '.' ) [ : - 2 ] ) index_table_name = _find_name_by_oid ( mib , index_table_oid , mibs_directories , json_mib_directory , source , compiled_mibs_path ) if index_table_name is not None : index [ 'table' ] = index_table_name index [ 'column' ] = column metric_tags . append ( index ) profile_oid_collection [ table_oid ] [ 'metric_tags' ] = metric_tags