20042009 Ericsson AB. All Rights Reserved. The contents of this file are subject to the Erlang Public License, Version 1.1, (the "License"); you may not use this file except in compliance with the License. You should have received a copy of the Erlang Public License along with this software. If not, it can be retrieved online at http://www.erlang.org/. Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. snmpc snmpc.xml
snmpc Interface Functions to the SNMP toolkit MIB compiler

The module snmpc contains interface functions to the SNMP toolkit MIB compiler.

compile(File) compile(File, Options) -> {ok, BinFileName} | {error, Reason} Compile the specified MIB File = string() Options = [opt()] opt() = db() | deprecated() | description() | reference() | group_check() | i() | il() | imports() | module() | module_identity() | outdir() | no_defs() | verbosity() | warnings() db() = {db, volatile|persistent|mnesia} deprecated() = {deprecated, bool()} description() = description reference() = reference group_check() = {group_check, bool()} i() = {i, [dir()]} il() = {il, [dir()]} imports() = imports module() = {module, atom()} module_identity() = module_identity no_defs() = no_defs outdir() = {outdir, dir()} verbosity() = {verbosity, silence|warning|info|log|debug|trace} warnings() = {warnings, bool()} dir() = string() BinFileName = string()

Compiles the specified MIB file .mib]]>. The compiled file BinFileName is called .bin]]>.

The option db specifies which database should be used for the default instrumentation. Default is volatile. The option deprecated specifies if a deprecated definition should be kept or not. If the option is false the MIB compiler will ignore all deprecated definitions. Default is true. The option description specifies if the text of the DESCRIPTION field will be included or not. By default it is not included, but if this option is present it will be. The option reference specifies if the text of the REFERENCE field, when found in a table definition, will be included or not. By default it is not included, but if this option is present it will be. The reference text will be placed in the allocList field of the mib-entry record (#me{}) for the table. The option group_check specifies whether the mib compiler should check the OBJECT-GROUP macro and the NOTIFICATION-GROUP macro for correctness or not. Default is true. The option i specifies the path to search for imported (compiled) MIB files. The directories should be strings with a trailing directory delimiter. Default is ["./"]. The option il (include_lib) also specifies a list of directories to search for imported MIBs. It assumes that the first element in the directory name corresponds to an OTP application. The compiler will find the current installed version. For example, the value ["snmp/mibs/"] will be replaced by ["snmp-3.1.1/mibs/"] (or what the current version may be in the system). The current directory and the /priv/mibs/]]> are always listed last in the include path. The option imports, if present, specifies that the IMPORT statement of the MIB shall be included in the compiled mib. The option module, if present, specifies the name of a module which implements all instrumentation functions for the MIB. The name of all instrumentation functions must be the same as the corresponding managed object it implements. The option module_identity, if present, specifies that the info part of the MODULE-IDENTITY statement of the MIB shall be included in the compiled mib. The option no_defs, if present, specifies that if a managed object does not have an instrumentation function, the default instrumentation function should NOT be used, instead this is reported as an error, and the compilation aborts. The option verbosity specifies the verbosity of the SNMP mib compiler. I.e. if warning, info, log, debug and trace messages shall be shown. Default is silence. Note that if the option warnings is true and the option verbosity is silence, warning messages will still be shown. The option warnings specifies whether warning messages should be shown. Default is true.

The MIB compiler understands both SMIv1 and SMIv2 MIBs. It uses the MODULE-IDENTITY statement to determine if the MIB is version 1 or 2.

The MIB compiler can be invoked from the OS command line by using the command erlc. erlc recognizes the extension .mib, and invokes the SNMP MIB compiler for files with that extension. The options db, group_check, deprecated, description, verbosity, imports and module_identity have to be specified to erlc using the syntax +term. See erlc(1) for details.

is_consistent(Mibs) -> ok | {error, Reason} Check for OID conflicts between MIBs Mibs = [MibName] MibName = string()

Checks for multiple usage of object identifiers and traps between MIBs.

mib_to_hrl(MibName) -> ok | {error, Reason} Generate constants for the objects in the MIB MibName = string()

Generates a .hrl file with definitions of Erlang constants for the objects in the MIB. The .hrl file is called .hrl]]>. The MIB must be compiled, and present in the current directory.

The mib_to_hrl generator can be invoked from the OS command line by using the command erlc. erlc recognizes the extension .bin, and invokes this function for files with that extension.

See Also

erlc(1)