SnmpKit.SnmpMgr.Config (snmpkit v0.6.6)
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
Adds a directory to the MIB search paths.
Returns a specification to start this module under a supervisor.
Gets configuration value with fallback to application config.
Gets all current configuration as a map.
Gets the default community string.
Gets the default port.
Gets the default number of retries.
Gets the default timeout.
Gets the default SNMP version.
Gets the current MIB search paths.
Merges the current configuration with provided opts, giving priority to opts.
Resets configuration to defaults.
Sets the default community string for SNMP requests.
Sets the default port for SNMP requests.
Sets the default number of retries for SNMP requests.
Sets the default timeout for SNMP requests in milliseconds.
Sets the default SNMP version.
Sets the MIB search paths (replaces existing paths).
Starts the configuration GenServer.
Functions
Adds a directory to the MIB search paths.
Examples
iex> SnmpKit.SnmpMgr.Config.add_mib_path("/usr/share/snmp/mibs")
:ok
Returns a specification to start this module under a supervisor.
See Supervisor
.
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
Gets all current configuration as a map.
Examples
iex> SnmpKit.SnmpMgr.Config.get_all()
%{
community: "public",
timeout: 5000,
retries: 1,
port: 161,
version: :v1,
mib_paths: []
}
Gets the default community string.
Examples
iex> SnmpKit.SnmpMgr.Config.get_default_community()
"public"
Gets the default port.
Gets the default number of retries.
Gets the default timeout.
Gets the default SNMP version.
Gets the current MIB search paths.
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]
Resets configuration to defaults.
Examples
iex> SnmpKit.SnmpMgr.Config.reset()
:ok
Sets the default community string for SNMP requests.
Examples
iex> SnmpKit.SnmpMgr.Config.set_default_community("private")
:ok
Sets the default port for SNMP requests.
Examples
iex> SnmpKit.SnmpMgr.Config.set_default_port(1161)
:ok
Sets the default number of retries for SNMP requests.
Examples
iex> SnmpKit.SnmpMgr.Config.set_default_retries(3)
:ok
Sets the default timeout for SNMP requests in milliseconds.
Examples
iex> SnmpKit.SnmpMgr.Config.set_default_timeout(10000)
:ok
Sets the default SNMP version.
Examples
iex> SnmpKit.SnmpMgr.Config.set_default_version(:v2c)
:ok
Sets the MIB search paths (replaces existing paths).
Examples
iex> SnmpKit.SnmpMgr.Config.set_mib_paths(["/usr/share/snmp/mibs", "./mibs"])
:ok
Starts the configuration GenServer.