Search documentation of snmpkit

# SnmpKit.SnmpMgr.Config (snmpkit v1.3.17)

Configuration management for SnmpKit.SnmpMgr.

Provides global defaults and configuration options that can be set application-wide and used by all SNMP operations.

# Summary

## Functions

add_mib_path(path)

Adds a directory to the MIB search paths.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

get(key)

Gets configuration value with fallback to application config.

get_all()

Gets all current configuration as a map.

get_default_auto_start_services()

Gets whether manager services auto-start on demand.

get_default_community()

Gets the default community string.

get_default_include_formatted()

Gets the default include_formatted flag.

get_default_include_names()

Gets the default include_names flag.

get_default_port()

Gets the default port.

get_default_retries()

Gets the default number of retries.

get_default_timeout()

Gets the default timeout.

get_default_version()

Gets the default SNMP version.

get_mib_paths()

Gets the current MIB search paths.

merge_opts(opts)

Merges the current configuration with provided opts, giving priority to opts.

reset()

Resets configuration to defaults.

set_default_auto_start_services(flag)

Sets whether manager services auto-start on demand.

set_default_community(community)

Sets the default community string for SNMP requests.

set_default_include_formatted(flag)

Sets the default include_formatted flag (controls formatted field in results).

set_default_include_names(flag)

Sets the default include_names flag (controls reverse MIB lookups in results).

set_default_port(port)

Sets the default port for SNMP requests.

set_default_retries(retries)

Sets the default number of retries for SNMP requests.

set_default_timeout(timeout)

Sets the default timeout for SNMP requests in milliseconds.

set_default_version(version)

Sets the default SNMP version.

set_mib_paths(paths)

Sets the MIB search paths (replaces existing paths).

start_link(opts \\ [])

Starts the configuration GenServer.

# Functions

# add_mib_path(path)

Adds a directory to the MIB search paths.

## Examples

    iex> SnmpKit.SnmpMgr.Config.add_mib_path("/usr/share/snmp/mibs")
    :ok

# child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# get(key)

Gets configuration value with fallback to application config.

This is the main function used by other modules to get configuration values. It first checks the GenServer state, then falls back to application config, then to module defaults.

## Examples

    iex> SnmpKit.SnmpMgr.Config.get(:community)
    "public"

    iex> SnmpKit.SnmpMgr.Config.get(:timeout)
    5000

# get_all()

Gets all current configuration as a map.

## Examples

    iex> SnmpKit.SnmpMgr.Config.get_all()
    %{
      community: "public",
      timeout: 5000,
      retries: 1,
      port: 161,
      version: :v2c,
      mib_paths: []
    }

# get_default_auto_start_services()

Gets whether manager services auto-start on demand.

# get_default_community()

Gets the default community string.

## Examples

    iex> SnmpKit.SnmpMgr.Config.get_default_community()
    "public"

# get_default_include_formatted()

Gets the default include_formatted flag.

# get_default_include_names()

Gets the default include_names flag.

# get_default_port()

Gets the default port.

# get_default_retries()

Gets the default number of retries.

# get_default_timeout()

Gets the default timeout.

# get_default_version()

Gets the default SNMP version.

# get_mib_paths()

Gets the current MIB search paths.

# merge_opts(opts)

Merges the current configuration with provided opts, giving priority to opts.

This is useful for functions that want to use global defaults but allow per-request overrides.

## Examples

    iex> SnmpKit.SnmpMgr.Config.merge_opts(community: "private", timeout: 10000)
    [community: "private", timeout: 10000, retries: 1, port: 161]

# reset()

Resets configuration to defaults.

## Examples

    iex> SnmpKit.SnmpMgr.Config.reset()
    :ok

# set_default_auto_start_services(flag)

Sets whether manager services auto-start on demand.

# set_default_community(community)

Sets the default community string for SNMP requests.

## Examples

    iex> SnmpKit.SnmpMgr.Config.set_default_community("private")
    :ok

# set_default_include_formatted(flag)

Sets the default include_formatted flag (controls formatted field in results).

# set_default_include_names(flag)

Sets the default include_names flag (controls reverse MIB lookups in results).

# set_default_port(port)

Sets the default port for SNMP requests.

## Examples

    iex> SnmpKit.SnmpMgr.Config.set_default_port(1161)
    :ok

# set_default_retries(retries)

Sets the default number of retries for SNMP requests.

## Examples

    iex> SnmpKit.SnmpMgr.Config.set_default_retries(3)
    :ok

# set_default_timeout(timeout)

Sets the default timeout for SNMP requests in milliseconds.

## Examples

    iex> SnmpKit.SnmpMgr.Config.set_default_timeout(10000)
    :ok

# set_default_version(version)

Sets the default SNMP version.

## Examples

    iex> SnmpKit.SnmpMgr.Config.set_default_version(:v2c)
    :ok

# set_mib_paths(paths)

Sets the MIB search paths (replaces existing paths).

## Examples

    iex> SnmpKit.SnmpMgr.Config.set_mib_paths(["/usr/share/snmp/mibs", "./mibs"])
    :ok

# start_link(opts \\ [])

Starts the configuration GenServer.