snmpm(3)
๐ snmpm โ Interface functions to the SNMP toolkit manager ๐
okay bestie, welcome to snmpm(3) โ this is the Erlang Module Definition page for snmpm, and it's literally the module that holds the interface functions to the SNMP manager. yes, THE manager. the main character. let's get into it ๐ซถ
โจ NAME โจ
snmpm โ Interface functions to the SNMP toolkit manager. that's the whole vibe. slay.
๐ธ DESCRIPTION ๐ธ
The module snmpm contains interface functions to the SNMP manager. that's it, that's the girl. she's the doorway, she's the front desk, she's everything ๐
๐ DATA TYPES ๐
okay so we're gonna go through every single type here, no skipping, because these are the building blocks and you NEED them.
agent_config() ::
{engine_id, snmp:engine_id()} |
{address, inet:ip_address()} |
{port, inet:port_number()} |
{tdomain, snmp:tdomain()} |
{community, snmp:community()} |
{timeout, register_timeout()} |
{max_message_size, snmp:mms()} |
{version, snmp:version()} |
{sec_model, snmp:sec_model()} |
{sec_name, snmp:sec_name()} |
{sec_level, snmp:sec_level()}
agent_config_item() ::
engine_id | address | port | tdomain | community | timeout |
max_message_size | version | sec_model | sec_name | sec_level
and the value type literally depends on which item it is, so let's break it down one by one ๐
engine_idโ Engine ID of the agent. Value type:engine_id()addressโ The IP address of the agent. Value type:ip_address()portโ Port number of the agent. Value type:port_number()tdomainโ Transport domain. Value type:tdomain()communityโ Community. Value type:community()timeoutโ Registration timeout. Value type:register_timeout/0max_message_sizeโ Max Message Size of a message. Value type:mms()versionโ What SNMP version is used when communicating with this agent. Value type:version()sec_modelโ Security Model. Value type:sec_model()sec_nameโ Security Name. Value type:sec_name()sec_levelโ Security Level. Value type:sec_level()
pdu_type() :: snmp:pdu_type() | trappdu.
register_timeout() :: pos_integer() | snmp:snmp_timer().
The time to complete a (agent) registration. yes bestie, registration takes TIME, be patient ๐ง
-opaque request_id()
Is a unique term that identifies a request. okay icon, we love a unique identifier ๐
snmp_reply() ::
{snmp:error_status(), snmp:error_index(), [snmp:varbind()]}
snmpm_user() :: module().
Module implementing the snmpm_user behaviour. (behaviour with a u, we're in Erlang land, periodt)
target_name() :: string().
Is a unique non-empty string. non-empty!!! like, it literally cannot be empty. don't try it ๐
user_id() :: term().
Is a unique term that identifies a user. another unique identifier, the girlies love to be identifiable ๐
usm_config_item() :: sec_name | auth | auth_key | priv | priv_key.
Value type depend on the item according to:
sec_nameโ Security Name. Value type:snmp:sec_name()authโ Authentication protocol. Value type:snmp:usm_auth_protocol()auth_keyโ Authentication key. Value type:snmp:usm_auth_key()privโ Privacy protocol. Value type:snmp:usm_priv_protocol()priv_keyโ Privacy key. Value type:snmp:usm_priv_key()
value_type() ::
o | i | u | g | s | s | b | ip | op | c32 | c64 | tt
and here's what each one is giving, fr fr:
o-'OBJECT IDENTIFIER'i-'INTEGER'u-'Unsigned32g-'Unsigned32's-'OCTET STRING'b-'BITS'ip-'IpAddress'op-'Opaque'c32-'Counter32'c64-'Counter64'tt-'TimeTicks'
var_and_val() ::
{OID :: snmp:oid(),
ValueType :: value_type(),
Value :: term()} |
{OID :: snmp:oid(), Value :: term()}
๐ฅ FUNCTIONS ๐ฅ
agent_info(TargetName, Item) -> {ok, Value} | {error, Reason}
when
TargetName :: target_name(),
Item :: agent_config_item(),
Value :: term(),
Reason :: term().
Retrieve agent config. that's it, that's the whole function. go get that config bestie โจ
async_get2(UserId, TargetName, Oids, SendOpts) -> {ok, ReqId} | {error, Reason}
when
UserId :: user_id(),
TargetName :: target_name(),
Oids :: [snmp:oid()],
SendOpts :: [SendOpt],
SendOpt ::
{context, snmp:context_name()} |
{timeout, pos_integer()} |
{community, snmp:community()} |
{sec_model, snmp:sec_model()} |
{sec_name, snmp:sec_name()} |
{sec_level, snmp:sec_level()} |
{max_message_size, snmp:mms()} |
{extra, term()},
ReqId :: request_id(),
Reason :: term().
Asynchronous get-request. async queen behavior ๐
The reply, if it arrives, will be delivered to the user through a call to the snmpm_user callback function handle_pdu.
The send option timeout specifies for how long the request is valid (after which the manager is free to delete it).
The send option extra specifies an opaque data structure passed on to the net-if process. The net-if process included in this application makes, with one exception, no use of this info, so the only use for it (when using the built in net-if) would be tracing. The one usage exception is: Any tuple with snmpm_extra_info_tag as its first element is reserved for internal use. โ ๏ธ don't touch those, they're not for you.
Some of the send options (community, sec_model, sec_name, sec_level and max_message_size) are override options. That is, for this request, they override any configuration done when the agent was registered. the way that these just override everything?? iconic.
async_get_bulk2(UserId, TargetName, NonRep, MaxRep, Oids, SendOpts) -> {ok, ReqId} | {error, Reason}
when
UserId :: user_id(),
TargetName :: target_name(),
NonRep :: non_neg_integer(),
MaxRep :: non_neg_integer(),
Oids :: [snmp:oid()],
SendOpts :: [SendOpt],
SendOpt ::
{context, snmp:context_name()} |
{timeout, pos_integer()} |
{community, snmp:community()} |
{sec_model, snmp:sec_model()} |
{sec_name, snmp:sec_name()} |
{sec_level, snmp:sec_level()} |
{max_message_size, snmp:mms()} |
{extra, term()},
ReqId :: request_id(),
Reason :: term().
Asynchronous get-bulk-request (See RFC1905). bulk means MORE, and more is always the vibe ๐
The reply, if it arrives, will be delivered to the user through a call to the snmpm_user callback function handle_pdu.
The send option timeout specifies for how long the request is valid (after which the manager is free to delete it).
The send option extra specifies an opaque data structure passed on to the net-if process. The net-if process included in this application makes no use of this info, so the only use for it in such a configuration (when using the built in net-if) would be tracing.
Some of the send options (community, sec_model, sec_name, sec_level and max_message_size) are override options. That is, for this request, they override any configuration done when the agent was registered.
async_get_next2(UserId, TargetName, Oids, SendOpts) -> {ok, ReqId} | {error, Reason}
when
UserId :: user_id(),
TargetName :: target_name(),
Oids :: [snmp:oid()],
SendOpts :: [SendOpt],
SendOpt ::
{context, snmp:context_name()} |
{timeout, pos_integer()} |
{community, snmp:community()} |
{sec_model, snmp:sec_model()} |
{sec_name, snmp:sec_name()} |
{sec_level, snmp:sec_level()} |
{max_message_size, snmp:mms()} |
{extra, term()},
ReqId :: request_id(),
Reason :: term().
Asynchronous get-next-request. next!! we're moving ON, no going back โจ
The reply, if it arrives, will be delivered to the user through a call to the snmpm_user callback function handle_pdu.
The send option timeout specifies for how long the request is valid (after which the manager is free to delete it).
The send option extra specifies an opaque data structure passed on to the net-if process. The net-if process included in this application makes, with one exception, no use of this info, so the only use for it (when using the built in net-if) would be tracing. The one usage exception is: Any tuple with snmpm_extra_info_tag as its first element is reserved for internal use.
Some of the send options (community, sec_model, sec_name, sec_level and max_message_size) are override options. That is, for this request, they override any configuration done when the agent was registered.
that's part 1 bestie, stay tuned ๐
๐ async_set2(UserId, TargetName, VarsAndVals, SendOpts)
async_set2(UserId, TargetName, VarsAndVals, SendOpts) ->
{ok, ReqId} | {error, Reason}
when
UserId :: user_id(),
TargetName :: target_name(),
VarsAndVals :: [var_and_val()],
SendOpts :: [SendOpt],
SendOpt ::
{context, snmp:context_name()} |
{timeout, pos_integer()} |
{community, snmp:community()} |
{sec_model, snmp:sec_model()} |
{sec_name, snmp:sec_name()} |
{sec_level, snmp:sec_level()} |
{max_message_size, snmp:mms()} |
{extra, term()},
ReqId :: request_id(),
Reason :: term().
Okay so this is the set-request you fire off and then go live your life ๐ฆ โ it's asynchronous, meaning you do NOT sit around waiting for the answer.
The reply comes back to you through a call to the snmpm_user callback function handle_pdu. That's the whole handoff, bestie.
The send option timeout says how long the request stays valid โ after that, the manager is totally free to delete it. gone. poof. ๐
When you pass var_and_val() as {oid(), value()}, the manager makes an educated guess based on the loaded mibs. she's intuitive like that.
The send option extra is an opaque data structure that gets passed on down to the net-if process. The net-if that ships with this application makes no use of this info, with exactly one exception โ so honestly, when you're using the built-in net-if, the only real use for it would be tracing. And that one exception? Any tuple with snmpm_extra_info_tag as its first element is reserved for internal use. do not touch. ๐
Also, heads up: some of the send options โ community, sec_model, sec_name, sec_level and max_message_size โ are override options. Which means, for this one request, they override any configuration that was done back when the agent was registered. she said "my rules this time". ๐
๐ backup(BackupDir)
backup(BackupDir) -> ok | {error, Reason}
when BackupDir :: snmp:dir(), Reason :: term().
Backs up the persistent data handled by the manager. ๐
โ ๏ธBackupDircannot be identical toDbDir. That's the rule, no exceptions, don't make me say it twice.
๐ cancel_async_request(UserId, ReqId)
cancel_async_request(UserId, ReqId) -> ok | {error, Reason}
when
UserId :: user_id(),
ReqId :: request_id(),
Reason :: term().
Cancels a previous asynchronous request. ๐ฅ yeah, we're done here, wrap it up.
๐ cancel_notify_started(Pid)
cancel_notify_started(Pid) -> snmp:void() when Pid :: pid().
Cancels a previous request to be notified of SNMP manager start. so you asked to be told when she wakes up, and now you're like... actually no. cancel that. ๐
๐ change_log_size(NewSize)
change_log_size(NewSize) -> ok | {error, Reason}
when
NewSize :: snmp:log_size(),
Reason :: term().
Changes the log size of the Audit Trail Log. The application must be configured to use the audit trail log function for this to matter, mmkay? If you want the deets on how to change the log size, please refer to disk_log(3) in Kernel Reference Manual. ๐
And bestie, listen โ the change is permanent, as long as the log is not deleted. That means the log size is remembered across reboots. she has a memory like an elephant. ๐โจ
๐ demonitor(Ref)
demonitor(Ref) -> true when Ref :: reference().
Turns off monitoring of the SNMP manager. we're unsubscribing from the drama ๐ซถ
๐ format_reason(Prefix, Reason)
format_reason(Prefix, Reason) -> FReason
when
Prefix :: non_neg_integer() | string(),
Reason :: term(),
FReason :: string().
This utility function is used to create a formatted (pretty printable) string of the error reason you got from either: ๐ธ
- The
Reasonreturned value, if any of the sync/async get / get-next / set / get-bulk functions returns{error, Reason} - The
Reasonparameter in thehandle_erroruser callback function.
Prefix should either be an indentation string (like, a list of spaces) or a positive integer, which will be used to create the indentation string of that length. cute AND functional. ๐
๐ info()
info() -> [{Key, Value}] when Key :: atom(), Value :: term().
Returns a list (a dictionary) containing information about the manager. ๐ Information includes statistics counters, miscellaneous info about each process (e.g. memory allocation), and so on. it's giving โจdashboardโจ.
๐ load_mib(MibName)
load_mib(MibName) -> ok | {error, Reason}
when MibName :: snmp:mib_name(), Reason :: term().
Loads a Mib into the manager. The MibName is the name of the Mib, including the path to where the compiled mib is found. Like, for example:
Dir = code:priv_dir(my_app) ++ "/mibs/",
snmpm:load_mib(Dir ++ "MY-MIB").
๐โจ
๐ log_to_io(LogDir, Mibs, LogName, LogFile, Block, Start, Stop)
log_to_io(LogDir, Mibs, LogName, LogFile, Block, Start, Stop) ->
ok | {ok, Cnt} | {error, Reason}
when
LogDir :: snmp:dir(),
Mibs :: [snmp:mib_name()],
LogName :: string(),
LogFile :: string(),
Block :: boolean(),
Start :: null | snmp:log_time(),
Stop :: null | snmp:log_time(),
Cnt :: {NumOK, NumERR},
NumOK :: non_neg_integer(),
NumERR :: pos_integer(),
Reason :: term().
Converts an Audit Trail Log to a readable format and prints it on stdio. ๐
LogNamedefaults to"snmpm_log".LogFiledefaults to"snmpm.log".
The Block argument indicates if the log should be blocked during conversion. This could be useful when converting large logs โ because otherwise the log could wrap while you're converting it, and nobody wants that. Defaults to true.
Start and Stop indicate which log entries should be converted, from when (Start) to when (Stop). ๐ฐ๏ธ
Start = null=> start from the beginning of the log.Stop = null=> stop the conversion at the end of the log.- Defaults to
Start = nullandStop = null(the entire log).
See snmp:log_to_io/7 for more info. ๐
๐ log_to_txt(LogDir, Mibs, OutFile, LogName, LogFile, Block, Start, Stop)
log_to_txt(LogDir :: snmp:dir(),
Mibs :: [snmp:mib_name()],
OutFile :: file:filename(),
LogName :: string(),
LogFile :: string(),
Block :: boolean(),
Start :: snmp:log_time(),
Stop :: snmp:log_time()) ->
snmp:void().
Converts an Audit Trail Log to a readable text file. ๐
OutFiledefaults to"./snmpm_log.txt".LogNamedefaults to"snmpm_log".LogFiledefaults to"snmpm.log".
The Block argument indicates if the log should be blocked during conversion. Again โ super useful when converting large logs, because otherwise the log could wrap mid-conversion. Defaults to true.
Start and Stop indicate which log entries should be converted, from when (Start) to when (Stop). โณ
Start = null=> start from the beginning of the log.Stop = null=> stop the conversion at the end of the log.- Defaults to
Start = nullandStop = null(the entire log).
See snmp:log_to_txt/8 for more info. ๐ซถ
๐ monitor()
monitor() -> MRef when MRef :: reference().
Monitors the SNMP manager. ๐ In case of a crash, the calling (monitoring) process will get a 'DOWN' message โ see the erlang module for more info. she will literally tell you if something goes down. fr fr.
๐ name_to_oid(AliasName)
name_to_oid(AliasName) -> {ok, OIDs} | {error, Reason}
when
AliasName :: atom(),
OIDs :: [snmp:oid()],
Reason :: term().
Transforms an alias-name to its oid. โจ
๐ก Heads up: an alias-name is only unique within the mib. So when you load several mib's into a manager, there might be several instances of the same aliasname. like, she's not going to warn you, so I will.
๐ notify_started(Timeout) / notify_started(Args)
notify_started(Timeout) -> Pid
when Timeout :: non_neg_integer(), Pid :: pid();
(Args) -> Pid when Args :: map(), Pid :: pid().
Requests a notification (message) when the SNMP manager has started. ๐
The Timeout is the time the request is valid. The value has to be greater than zero. (yes, actually.)
The Pid is the process handling the supervision of the SNMP manager start. When the manager has started, a completion message will be sent to the client from this process: {snmpm_started, Pid}. And if the SNMP manager was not started in time, a timeout message will be sent to the client instead: {snmpm_start_timeout, Pid}.
A client application that's dependent on the SNMP manager will use this function to get notified of when the manager has started. There are two situations where this is useful: ๐ฆ
- During the start of a system, when a client application could start prior to the SNMP manager but is dependent upon it โ and therefore has to wait for it to start.
- When the SNMP manager has crashed, the dependent client application has to wait for the SNMP manager to be restarted before it can reconnect.
The function returns the pid() of a handler process that does the supervision on behalf of the client application. ๐ Note that the client application is linked to this handler.
This function is used in conjunction with the monitor function. ๐
๐ oid_to_name(OID)
oid_to_name(OID) -> {ok, AliasName} | {error, Reason}
when
OID :: snmp:oid(),
AliasName :: atom(),
Reason :: term().
Transforms an oid to its aliasname. the reverse trick, iconic. โจ
๐ oid_to_type(OID)
oid_to_type(OID) -> {ok, Type} | {error, Reason}
when
OID :: snmp:oid(),
Type :: atom(),
Reason :: term().
Retrieves the type (asn1 bertype) of an oid. ๐
๐ register_agent(UserId, TargetName, Config)
register_agent(UserId, TargetName, Config) -> ok | {error, Reason}
when
UserId :: user_id(),
TargetName :: target_name(),
Config :: [ConfigEntry],
ConfigEntry :: {Item, Value},
Item :: agent_config_item(),
Value :: term(),
Reason :: term().
Explicitly instructs the manager to handle this agent, with UserId as the responsible user. ๐ you're basically saying "bestie, she's with me." ๐
Okay so this function is called to instruct the manager that this agent shall be handled. ๐
It's what you use when you already know which agents the manager is supposed to handle. And bestie, there's an alternate way to do the same thing: just add the agent to the manager config files (see agents.conf). โจ
TargetName is a non-empty string, uniquely identifying the agent. No blanks, no confusion. ๐
The type of Val depends on Item:
[mandatory] engine_id = engine_id()โ mandatory, periodt.[mandatory] address = inet:ip_address() % Depends on tdomainโ yeah, it depends ontdomain.[optional] port = inet:port_number()[optional] tdomain = snmp:tdomain()[optional] community = snmp:community()[optional] timeout = register_timeout()[optional] max_message_size = snmp:mms()[optional] version = snmp:version()[optional] sec_model = snmp:sec_model()[optional] sec_name = snmp:sec_name()[optional] sec_level = snmp:sec_level()
Note that if no tdomain is given, the default value, transportDomainUdpIpv4, is used. ๐ฆ
Note that if no port is given and if taddress does not contain a port number, the default value is used. ๐
Next up: register_user. This one's giving, "hey, you're responsible for these agents now."
register_user(UserId, Module, Data, DefaultAgentConfig) ->
ok | {error, Reason}
when
UserId :: user_id(),
Module :: snmpm_user(),
Data :: term(),
DefaultAgentConfig :: [DefaultConfigEntry],
DefaultConfigEntry :: {Item, Value},
Item :: agent_config_item(),
Value :: term(),
Reason :: term().
Register the manager entity (=user) responsible for specific agent(s). ๐
Module is the callback module (snmpm_user behaviour) which will be called whenever something happens (detected agent, incoming reply or incoming trap/notification). It's literally the main character handling the drama. ๐
Data is an opaque data structure, not inspected by the manager, that will be included in all callback calls to the Module callback module (snmpm_user behaviour). So it's just vibes the manager carries around for you. ๐
The argument DefaultAgentConfig is used as default values when this user register agents. Lowkey handy.
Note that this operation (register user) could have already been done as a consequence of the node config. (see users.conf). ๐
Then there's register_user_monitor โ same energy, but with a bodyguard.
register_user_monitor(UserId, Module, Data, DefaultAgentConfig) ->
ok | {error, Reason}
when
UserId :: user_id(),
Module :: snmpm_user(),
Data :: term(),
DefaultAgentConfig ::
[DefaultConfigEntry],
DefaultConfigEntry :: {Item, Value},
Item :: agent_config_item(),
Value :: term(),
Reason :: term().
Register the monitored manager entity (=user) responsible for specific agent(s). ๐
The process performing the registration will be monitored. Which means that if that process should die, all agents registered by that user process will be unregistered. All outstanding requests will be canceled. So yeah, if the process goes poof, everything tied to it goes poof too. ๐ Keep that in mind.
Module is the callback module (snmpm_user behaviour) which will be called whenever something happens (detected agent, incoming reply or incoming trap/notification). Same as above, bestie. โจ
Data is an opaque data structure, not inspected by the manager, that will be included in all callback calls to the Module callback module (snmpm_user behaviour). No notes, just vibes.
The argument DefaultAgentConfig is used as default values when this user register agents. ๐ซถ
register_usm_user โ USM users, rise.
register_usm_user(EngineID, UserName, Config) ->
ok | {error, Reason}
when
EngineID :: snmp:engine_id(),
UserName :: snmp:usm_name(),
Config :: [ConfigEntry],
ConfigEntry :: {Item, Value},
Item :: usm_config_item(),
Value :: term(),
Reason :: term().
Explicitly instruct the manager to handle this USM user. Note that there is an alternate way to do the same thing: Add the usm user to the manager config files (see usm.conf). Periodt. ๐
restart โ the "turn it off and on again" of it all.
restart(What) -> snmp:void() when What :: net_if.
Restart the indicated process (What). Note that its not without risk to restart a process, and should therefore be used with care.
โ ๏ธ Bestie, restarting a process is not without risk. Use it with care, fr fr. Don't just yolo it.
set_log_type โ for when you need to switch up the audit trail aesthetic.
set_log_type(NewType) -> {ok, OldType} | {error, Reason}
when
NewType :: snmp:atl_type(),
OldType :: snmp:atl_type(),
Reason :: term().
Changes the run-time Audit Trail log type. โจ
Note that this has no effect on the application configuration as defined by configuration files, so a node restart will revert the config to whatever is in those files. So it's a temporary glow-up, not a permanent one. ๐
This function is primarily useful in testing/debugging scenarios. ๐ง
sync_get2 โ synchronous get-request, let's go.
sync_get2(UserId, TargetName, Oids, SendOpts) ->
{ok, SnmpReply, Remaining} | {error, Reason}
when
UserId :: user_id(),
TargetName :: target_name(),
Oids :: [snmp:oid()],
SendOpts :: [SendOpt],
SendOpt ::
{context, snmp:context_name()} |
{timeout, pos_integer()} |
{community, snmp:community()} |
{sec_model, snmp:sec_model()} |
{sec_name, snmp:sec_name()} |
{sec_level, snmp:sec_level()} |
{max_message_size, snmp:mms()} |
{extra, term()},
SnmpReply :: snmp_reply(),
Remaining :: non_neg_integer(),
Reason ::
{send_failed, ReqId, ActualReason} |
{invalid_sec_info, SecInfo, SnmpInfo} |
term(),
ReqId :: request_id(),
ActualReason :: term(),
SecInfo :: {SecTag, ExpectedValue,
ReceivedValue},
SecTag :: atom(),
ExpectedValue :: term(),
ReceivedValue :: term(),
SnmpInfo :: term().
Synchronous get-request. ๐ซถ
Remaining is the remaining time of the given (or default) timeout time. So you know how much patience is left.
When Reason is {send_failed, ...} it means that the net-if process failed to send the (get-request ) message. This could happen because of any number of reasons, i.e. encoding error. ActualReason is the actual reason in this case. ๐ญ
The send option extra specifies an opaque data structure passed on to the net-if process. The net-if process included in this application makes, with one exception, no use of this info, so the only use for it (when using the built in net-if) would be tracing. The one usage exception is: Any tuple with snmpm_extra_info_tag as its first element is reserved for internal use. ๐ฅ
Some of the send options (community, sec_model, sec_name, sec_level and max_message_size) are override options. That is, for this request, they override any configuration done when the agent was registered. So they're the "for this request only" slay. ๐
For SnmpInfo, see the user callback function handle_report. ๐
sync_get_bulk2 โ bulk energy, same synchronous vibe.
sync_get_bulk2(UserId, TargetName, NonRep, MaxRep, Oids, SendOpts) ->
{ok, SnmpReply, Remaining} | {error, Reason}
when
UserId :: user_id(),
TargetName :: target_name(),
NonRep :: non_neg_integer(),
MaxRep :: non_neg_integer(),
Oids :: [snmp:oid()],
SendOpts :: [SendOpt],
SendOpt ::
{context, snmp:context_name()} |
{timeout, pos_integer()} |
{community, snmp:community()} |
{sec_model, snmp:sec_model()} |
{sec_name, snmp:sec_name()} |
{sec_level, snmp:sec_level()} |
{max_message_size, snmp:mms()} |
{extra, term()},
ReqId :: request_id(),
SnmpReply :: snmp_reply(),
Remaining :: non_neg_integer(),
Reason ::
{send_failed, ReqId, ActualReason} |
{invalid_sec_info, SecInfo, SnmpInfo} |
term(),
ReqId :: request_id(),
ActualReason :: term(),
SecInfo ::
{SecTag, ExpectedValue, ReceivedValue},
SecTag :: atom(),
ExpectedValue :: term(),
ReceivedValue :: term(),
SnmpInfo :: term().
Synchronous get-bulk-request (See RFC1905). ๐
Remaining is the remaining time of the given (or default) timeout time. Same as before, bestie. โณ
When Reason is {send_failed, ...} it means that the net-if process failed to send the message. This could happen because of any number of reasons, i.e. encoding error. ActualReason is the actual reason in this case. ๐
okay bestie, we're mid-roll through the function list โ no heading needed, just vibes and specs ๐
The extra send option is basically an opaque little goodie bag ๐ โ a data structure that gets passed on to the net-if process. And here's the tea โ: the net-if process that's included in this application makes no use of that info, with exactly one exception. So the only thing extra is good for (when you're using the built-in net-if) would be tracing. The one usage exception is: any tuple with snmpm_extra_info_tag as its first element is reserved for internal use. Don't poke it ๐
โโ๏ธ
Some of the send options (community, sec_model, sec_name, sec_level and max_message_size) are override options. Meaning: for this request, they override any configuration that was done back when the agent was registered. Periodt ๐
For SnmpInfo, go see the user callback function snmpm_user:handle_report/3.
sync_get_next2/4 ๐
sync_get_next2(UserId, TargetName, Oids, SendOpts) ->
{ok, SnmpReply, Remaining} | {error, Reason}
when
UserId :: user_id(),
TargetName :: target_name(),
Oids :: [snmp:oid()],
SendOpts :: [SendOpt],
SendOpt ::
{context, snmp:context_name()} |
{timeout, pos_integer()} |
{community, snmp:community()} |
{sec_model, snmp:sec_model()} |
{sec_name, snmp:sec_name()} |
{sec_level, snmp:sec_level()} |
{max_message_size, snmp:mms()} |
{extra, term()},
SnmpReply :: snmp_reply(),
Remaining :: non_neg_integer(),
Reason ::
{send_failed, ReqId, ActualReason} |
{invalid_sec_info, SecInfo, SnmpInfo} |
term(),
ReqId :: request_id(),
ActualReason :: term(),
SecInfo ::
{SecTag, ExpectedValue, ReceivedValue},
SecTag :: atom(),
ExpectedValue :: term(),
ReceivedValue :: term(),
SnmpInfo :: term().
It's your synchronous get-next-request. Classic โจ
Remaining is how much time is left of the given (or default) timeout time โณ
When Reason is {send_failed, ...}, that means the net-if process just couldn't send the message. This could happen for any number of reasons โ an encoding error, for example ๐ ActualReason is the actual reason in that case, iykyk.
The extra send option is that opaque data structure passed on to the net-if process again. And again: the net-if process included in this application makes, with one exception, no use of this info, so the only use for it (when using the built in net-if) would be tracing. The one usage exception is: any tuple with snmpm_extra_info_tag as its first element is reserved for internal use ๐
Some of the send options (community, sec_model, sec_name, sec_level and max_message_size) are override options. That is, for this request, they override any configuration done when the agent was registered. No takesies backsies ๐
For SnmpInfo, see the user callback function handle_report.
sync_set2/4 ๐
sync_set2(UserId, TargetName, VarsAndVals, SendOpts) ->
{ok, SnmpReply, Remaining} | {error, Reason}
when
UserId :: user_id(),
TargetName :: target_name(),
VarsAndVals :: [var_and_val()],
SendOpts :: [SendOpt],
SendOpt ::
{context, snmp:context_name()} |
{timeout, pos_integer()} |
{community, snmp:community()} |
{sec_model, snmp:sec_model()} |
{sec_name, snmp:sec_name()} |
{sec_level, snmp:sec_level()} |
{max_message_size, snmp:mms()} |
{extra, term()},
SnmpReply :: snmp_reply(),
Remaining :: non_neg_integer(),
Reason ::
{send_failed, ReqId, ActualReason} |
{invalid_sec_info, SecInfo, SnmpInfo} |
term(),
ReqId :: request_id(),
ActualReason :: term(),
SecInfo :: {SecTag, ExpectedValue,
ReceivedValue},
SecTag :: atom(),
ExpectedValue :: term(),
ReceivedValue :: term(),
SnmpInfo :: term().
The synchronous set-request, the other half of the iconic duo ๐
Remaining = the remaining time of the given (or default) timeout time โณ
When Reason is {send_failed, ...} it means the net-if process failed to send the message. This could happen because of any number of reasons, i.e. encoding error. ActualReason is the actual reason in this case ๐ญ
When var_and_val() is {oid(), value()}, the manager makes an educated guess based on the loaded mibs ๐ฎ (she's guessing, but she's confident about it)
The extra send option specifies an opaque data structure passed on to the net-if process. The net-if process included in this application makes, with one exception, no use of this info, so the only use for it (when using the built in net-if) would be tracing. The one usage exception is: any tuple with snmpm_extra_info_tag as its first element is reserved for internal use ๐
Some of the send options (community, sec_model, sec_name, sec_level and max_message_size) are override options โ for this request they override any configuration done when the agent was registered.
For SnmpInfo, see the user callback function snmpm_user:handle_report/3.
unload_mib/1 ๐ง
unload_mib(MibName) -> ok | {error, Reason}
when MibName :: snmp:mib_name(), Reason :: term().
Unload a Mib from the manager ๐ชโจ MibName is the name of the Mib, including the path to where the compiled mib is found. For example:
Dir = code:priv_dir(my_app) ++ "/mibs/",
snmpm:unload_mib(Dir ++ "MY-MIB").
unregister_agent/2 ๐
unregister_agent(UserId, TargetName) -> ok | {error, Reason}
when
UserId :: user_id(),
TargetName :: target_name(),
Reason :: term().
Unregister the agent. Breaking up is hard but it's healthy bestie ๐
unregister_user/1 ๐ซถ
unregister_user(UserId) -> ok | {error, Reason}
when UserId :: user_id(), Reason :: term().
Unregister the user. Byeeeee ๐โจ
unregister_usm_user/2 ๐
unregister_usm_user(EngineID, UserName) -> ok | {error, Reason}
when
EngineID :: snmp:engine_id(),
UserName :: snmp:usm_name(),
Reason :: term().
Unregister this USM user. Not me removing a whole USM user, she's gone girl ๐
update_agent_info/3 ๐
update_agent_info(UserId, TargetName, Info) ->
ok | {error, Reason}
when
UserId :: user_id(),
TargetName :: target_name(),
Info :: [{Item, Value}],
Item :: agent_config_item(),
Value :: term(),
Reason :: term().
Update agent config โ
Use this one โ update_agent_info/3 โ when several values need to be updated atomically ๐ (all or nothing, main character energy)
See function register_agent/3 for more info about what kind of items are allowed.
update_agent_info/4 ๐
update_agent_info(UserId, TargetName, Item, Value) ->
ok | {error, Reason}
when
UserId :: user_id(),
TargetName :: target_name(),
Item :: agent_config_item(),
Value :: term(),
Reason :: term().
Update agent config โ (single item edition)
See function register_agent/3 for more info about what kind of items are allowed.
update_usm_user_info/4 ๐
update_usm_user_info(EngineID, UserName, Item, Value) ->
ok | {error, Reason}
when
EngineID :: snmp:engine_id(),
UserName :: snmp:usm_name(),
Item :: usm_config_item(),
Value :: term(),
Reason :: term().
Update usm user config. Glow up those credentials โจ
usm_user_info/3 ๐
usm_user_info(EngineID, UserName, Item) ->
{ok, Value} | {error, Reason}
when
EngineID :: snmp:engine_id(),
UserName :: snmp:usm_name(),
Item :: usm_config_item(),
Value :: term(),
Reason :: term().
Retrieve usm user config. She's nosy but in a helpful way ๐๐
verbosity/2 ๐
verbosity(Target, Verbosity) -> snmp:void()
when
Target ::
config | server | net_if | note_store | all,
Verbosity :: snmp:verbosity().
Sets verbosity for the designated process ๐ฃ๏ธ For the lowest verbosity, silence, nothing is printed (shhh ๐คซ). The higher the verbosity, the more is printed. She's chatty, let her talk.
which_agents/1 ๐ (there are technically two, but here's the one with a UserId)
which_agents(UserId) -> Agents
when
UserId :: user_id(), Agents :: [target_name()].
Get a list of all registered agents โ or, if you pass a UserId, just all the agents registered by that specific user ๐
which_mibs/0 ๐
which_mibs() -> Mibs
when
Mibs :: [{MibName, MibFile}],
MibName :: snmp:mib_name(),
MibFile :: string().
Get a list of all the mib's loaded into the manager. (Yes, the original says "mib's" โ we respect the apostrophe ๐ซกโจ)
which_users/0 ๐ธ
which_users() -> Users when Users :: [user_id()].
Get a list of the identities of all registered users. The roster, if you will ๐
which_usm_users() -> UsmUsers
when
UsmUsers :: [{EngineID, UserName}],
EngineID :: snmp:engine_id(),
UserName :: snmp:usm_name().
okay bestie, so which_usm_users() is literally your one-stop shop for the entire usm user roster ๐โจ it returns a UsmUsers value, which is a list of tuples: [{EngineID, UserName}], where each EngineID is a snmp:engine_id() and each UserName is a snmp:usm_name(). that's the whole fam, no filter, no cap. periodt. ๐ซถ
which_usm_users(EngineID) -> UsmUsers
when
EngineID :: snmp:engine_id(),
UsmUsers :: [UserName],
UserName :: snmp:usm_name().
and then there's which_usm_users(EngineID) โ this one is giving filtered ๐ you pass in an EngineID (which has to be a snmp:engine_id()), and it returns a UsmUsers value that's just a list of UserNames: [UserName]. each UserName is a snmp:usm_name(). so it's all the usm users registered under that specific engine-id. iconic behavior, fr fr. ๐
that's the tea, bestie ๐ this man page is brought to you by Ericsson AB, snmp 5.20.5, all for snmpm(3). stay savvy, stay slaying ๐๐
๐ฆ where this page comes from
- ubuntu stonking: erlang-doc 1:29.0.6+dfsg-1 ยท Apache-2.0
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms