(ctx, mib_files, filters, aliases, debug, interactive, source, compiled_mibs_path)
Generate an SNMP profile from MIBs. Accepts a directory path containing mib files
    to be used as source to generate the profile, along with a filter if a device or
    family of devices support only a subset of oids from a mib.

    filters is the path to a yaml file containing a collection of MIBs, with their list of
    MIB node names to be included. For example:
    ```yaml
    RFC1213-MIB:
    - system
    - interfaces
    - ip
    CISCO-SYSLOG-MIB: []
    SNMP-FRAMEWORK-MIB:
    - snmpEngine
    ```
    Note that each `MIB:node_name` correspond to exactly one and only one OID. However, some MIBs report legacy nodes
    that are overwritten.

    To resolve, edit the MIB by removing legacy values manually before loading them with this profile generator. If a
    MIB is fully supported, it can be omitted from the filter as MIBs not found in a filter will be fully loaded.
    If a MIB is *not* fully supported, it can be listed with an empty node list, as `CISCO-SYSLOG-MIB` in the example.

    `-a, --aliases` is an option to provide the path to a YAML file containing a list of aliases to be
    used as metric tags for tables, in the following format:
    ```yaml
    aliases:
    - from:
        MIB: ENTITY-MIB
        name: entPhysicalIndex
      to:
        MIB: ENTITY-MIB
        name: entPhysicalName
    ```
    MIBs tables most of the time define a column OID within the table, or from a different table and even different MIB,
    which value can be used to index entries. This is the `INDEX` field in row nodes. As an example,
    entPhysicalContainsTable in ENTITY-MIB
    ```txt
    entPhysicalContainsEntry OBJECT-TYPE
    SYNTAX      EntPhysicalContainsEntry
    MAX-ACCESS  not-accessible
    STATUS      current
    DESCRIPTION
            "A single container/'containee' relationship."
    INDEX       { entPhysicalIndex, entPhysicalChildIndex }
    ::= { entPhysicalContainsTable 1 }
    ```
    or its json dump, where `INDEX` is replaced by indices
    ```json
    "entPhysicalContainsEntry": {
        "name": "entPhysicalContainsEntry",
        "oid": "1.3.6.1.2.1.47.1.3.3.1",
        "nodetype": "row",
        "class": "objecttype",
        "maxaccess": "not-accessible",
        "indices": [
          {
            "module": "ENTITY-MIB",
            "object": "entPhysicalIndex",
            "implied": 0
          },
          {
            "module": "ENTITY-MIB",
            "object": "entPhysicalChildIndex",
            "implied": 0
          }
        ],
        "status": "current",
        "description": "A single container/'containee' relationship."
      },
    ```
    Sometimes indexes are columns from another table, and we might want to use another column as it could have more
    human readable information - we might prefer to see the interface name vs its numerical table index. This can be
    achieved using metric_tag_aliases

    Return a list of SNMP metrics and copy its yaml dump to the clipboard
    Metric tags need to be added manually
Generate an SNMP profile from MIBs. Accepts a directory path containing mib files
    to be used as source to generate the profile, along with a filter if a device or
    family of devices support only a subset of oids from a mib.
Generate an SNMP profile from MIBs . Accepts a directory path containing mib files to be used as source to generate the profile along with a filter if a device or family of devices support only a subset of oids from a mib .
def generate_profile_from_mibs(ctx, mib_files, filters, aliases, debug, interactive, source, compiled_mibs_path):
    """
    Generate an SNMP profile from MIBs. Accepts a directory path containing mib files
    to be used as source to generate the profile, along with a filter if a device or
    family of devices support only a subset of oids from a mib.

    filters is the path to a yaml file containing a collection of MIBs, with their list of
    MIB node names to be included. For example:
    ```yaml
    RFC1213-MIB:
    - system
    - interfaces
    - ip
    CISCO-SYSLOG-MIB: []
    SNMP-FRAMEWORK-MIB:
    - snmpEngine
    ```
    Note that each `MIB:node_name` correspond to exactly one and only one OID. However, some MIBs report legacy nodes
    that are overwritten.

    To resolve, edit the MIB by removing legacy values manually before loading them with this profile generator. If a
    MIB is fully supported, it can be omitted from the filter as MIBs not found in a filter will be fully loaded.
    If a MIB is *not* fully supported, it can be listed with an empty node list, as `CISCO-SYSLOG-MIB` in the example.

    `-a, --aliases` is an option to provide the path to a YAML file containing a list of aliases to be
    used as metric tags for tables, in the following format:
    ```yaml
    aliases:
    - from:
        MIB: ENTITY-MIB
        name: entPhysicalIndex
      to:
        MIB: ENTITY-MIB
        name: entPhysicalName
    ```
    MIBs tables most of the time define a column OID within the table, or from a different table and even different MIB,
    which value can be used to index entries. This is the `INDEX` field in row nodes. As an example,
    entPhysicalContainsTable in ENTITY-MIB
    ```txt
    entPhysicalContainsEntry OBJECT-TYPE
    SYNTAX      EntPhysicalContainsEntry
    MAX-ACCESS  not-accessible
    STATUS      current
    DESCRIPTION
            "A single container/'containee' relationship."
    INDEX       { entPhysicalIndex, entPhysicalChildIndex }
    ::= { entPhysicalContainsTable 1 }
    ```
    or its json dump, where `INDEX` is replaced by indices
    ```json
    "entPhysicalContainsEntry": {
        "name": "entPhysicalContainsEntry",
        "oid": "1.3.6.1.2.1.47.1.3.3.1",
        "nodetype": "row",
        "class": "objecttype",
        "maxaccess": "not-accessible",
        "indices": [
          {
            "module": "ENTITY-MIB",
            "object": "entPhysicalIndex",
            "implied": 0
          },
          {
            "module": "ENTITY-MIB",
            "object": "entPhysicalChildIndex",
            "implied": 0
          }
        ],
        "status": "current",
        "description": "A single container/'containee' relationship."
      },
    ```
    Sometimes indexes are columns from another table, and we might want to use another column as it could have more
    human readable information - we might prefer to see the interface name vs its numerical table index. This can be
    achieved using metric_tag_aliases

    Return a list of SNMP metrics and copy its yaml dump to the clipboard
    Metric tags need to be added manually
    """
    if debug:
        set_debug()
        from pysmi import debug

        debug.setLogger(debug.Debug('all'))

    # ensure at least one mib file is provided
    if len(mib_files) == 0:
        abort('🙄 no mib file provided, need at least one mib file to generate a profile')

    # create a list of all mib files directories and mib names
    source_directories = set()
    mibs = set()
    for file in mib_files:
        source_directories.add(os.path.dirname(file))
        mibs.add(os.path.splitext(os.path.basename(file))[0])
    # create a tmp dir for compiled json mibs
    json_destination_directory = os.path.join(gettempdir(), 'mibs')

    if not os.path.exists(json_destination_directory):
        os.mkdir(json_destination_directory)

    profile_oid_collection = {}
    # build profile
    for oid_node in _extract_oids_from_mibs(
        list(mibs), list(source_directories), json_destination_directory, source, compiled_mibs_path, filters
    ):
        if oid_node.node_type == 'table':
            _add_profile_table_node(profile_oid_collection, oid_node)
        elif oid_node.node_type == 'row':
            # requires
            _add_profile_row_node(
                profile_oid_collection,
                oid_node,
                os.path.dirname(mib_files[0]),
                metric_tag_aliases_path=aliases,
                json_mib_directory=json_destination_directory,
                source=source,
                compiled_mibs_path=compiled_mibs_path,
            )
        elif oid_node.node_type == 'column':
            _add_profile_column_node(profile_oid_collection, oid_node)
        elif oid_node.node_type == 'scalar':
            _add_profile_scalar_node(profile_oid_collection, oid_node)

    echo_info('{} metrics found'.format(len(profile_oid_collection.values())))
    yaml_data = yaml.dump({'metrics': list(profile_oid_collection.values())}, sort_keys=False)
    if not interactive or click.confirm('Save to file?'):
        output_filename = 'metrics.yaml'
        with open(output_filename, 'w') as f:
            f.write(yaml_data)
            echo_info('Metrics saved to {}'.format(output_filename))

    echo_debug(yaml.dump({'metrics': list(profile_oid_collection.values())}, sort_keys=False))
def generate_profile_from_mibs ( ctx , mib_files , filters , aliases , debug , interactive , source , compiled_mibs_path ) : if debug : set_debug ( ) from pysmi import debug debug . setLogger ( debug . Debug ( 'all' ) ) # ensure at least one mib file is provided if len ( mib_files ) == 0 : abort ( '🙄 no mib file provided, need at least one mib file to generate a profile') # create a list of all mib files directories and mib names source_directories = set ( ) mibs = set ( ) for file in mib_files : source_directories . add ( os . path . dirname ( file ) ) mibs . add ( os . path . splitext ( os . path . basename ( file ) ) [ 0 ] ) # create a tmp dir for compiled json mibs json_destination_directory = os . path . join ( gettempdir ( ) , 'mibs' ) if not os . path . exists ( json_destination_directory ) : os . mkdir ( json_destination_directory ) profile_oid_collection = { } # build profile for oid_node in _extract_oids_from_mibs ( list ( mibs ) , list ( source_directories ) , json_destination_directory , source , compiled_mibs_path , filters ) : if oid_node . node_type == 'table' : _add_profile_table_node ( profile_oid_collection , oid_node ) elif oid_node . node_type == 'row' : # requires _add_profile_row_node ( profile_oid_collection , oid_node , os . path . dirname ( mib_files [ 0 ] ) , metric_tag_aliases_path = aliases , json_mib_directory = json_destination_directory , source = source , compiled_mibs_path = compiled_mibs_path , ) elif oid_node . node_type == 'column' : _add_profile_column_node ( profile_oid_collection , oid_node ) elif oid_node . node_type == 'scalar' : _add_profile_scalar_node ( profile_oid_collection , oid_node ) echo_info ( '{} metrics found' . format ( len ( profile_oid_collection . values ( ) ) ) ) yaml_data = yaml . dump ( { 'metrics' : list ( profile_oid_collection . values ( ) ) } , sort_keys = False ) if not interactive or click . confirm ( 'Save to file?' ) : output_filename = 'metrics.yaml' with open ( output_filename , 'w' ) as f : f . write ( yaml_data ) echo_info ( 'Metrics saved to {}' . format ( output_filename ) ) echo_debug ( yaml . dump ( { 'metrics' : list ( profile_oid_collection . values ( ) ) } , sort_keys = False ) )