# snmp

### MODULE

snmp

### MODULE SUMMARY

Interface functions to the SNMP toolkit

### DESCRIPTION

The module `snmp` contains interface functions to the SNMP toolkit.

### Common Data Types

The following datatypes are used in the functions below:

- `oid() = [byte()]`

The `oid()` type is used to represent an ASN.1 OBJECT IDENTIFIER.

### EXPORTS

`config() -> ok | {error, Reason}`

A simple interactive SNMP agent configuration tool. Simple configuration files can be generated, but more complex configurations still have to be edited manually.

The tool is a textual based tool that asks some questions and generates `sys.config` and `*.conf` files.

Note that if the application shall support version 3, then the crypto app must be started before running this function (password generation).

`date_and_time() -> DateAndTime`

Types:

`DateAndTime = [int()]`

Returns current date and time as the data type DateAndTime, as specified in RFC1903. This is an OCTET STRING.

`date_and_time_to_universal_time_dst(DateAndTime) -> [utc()]`

Types:

`DateAndTime = [int()]`
`utc() = {{Y,Mo,D},{H,M,S}}`

Converts a DateAndTime list to a list of possible universal time(s). The unversal time value on the same format as defined in calendar(3).

`date_and_time_to_string(DateAndTime) -> string()`

Types:

`DateAndTime = [int()]`

Converts a DateAndTime list to a printable string, according to the DISPLAY-HINT definition in RFC1903.

`local_time_to_date_and_time_dst(Local) -> [DateAndTime]`

Types:

`Local = {{Y,Mo,D},{H,M,S}}`
`DateAndTime = [int()]`

Converts a local time value to a list of possible DateAndTime list(s). The local time value on the same format as defined in calendar(3).

`universal_time_to_date_and_time(UTC) -> DateAndTime`

Types:

`UTC = {{Y,Mo,D},{H,M,S}}`
`DateAndTime = [int()]`

Converts a universal time value to a DateAndTime list. The unversal time value on the same format as defined in calendar(3).

`validate_date_and_time(DateAndTime) -> bool()`

Types:

`DateAndTime = term()`

Checks if `DateAndTime` is a correct DateAndTime value, as specified in RFC1903. This function can be used in instrumentation functions to validate a DateAndTime value.

`log_to_txt(LogDir, Mibs, OutFile, LogName, LogFile) -> ok | {error, Reason}`
`log_to_txt(LogDir, Mibs, OutFile, LogName, LogFile, Start) -> ok | {error, Reason}`
`log_to_txt(LogDir, Mibs, OutFile, LogName, LogFile, Start, Stop) -> ok | {error, Reason}`

Types:

`LogDir = string()`
`Mibs = [MibName]`
`OutFile = string()`
`MibName = string()`
`LogName = string()`
`LogFile = string()`
`Start = Stop = null | datetime() | {local_time,datetime()} | {universal_time,datetime()}`
`Reason = term()`

Converts an Audit Trail Log to a readable text file, where each item has a trailing TAB character, and any TAB character in the body of an item has been replaced by ESC TAB.

The function can be used on a running system, or by copying the entire log directory and calling this function. SNMP must be running in order to provide MIB information.

`LogDir` is the name of the directory where the audit trail log is stored. `Mibs` is a list of Mibs to be used. The function uses the information in the Mibs to convert for example object identifiers to their symbolic name. `OutFile` is the name of the generated textfile. `LogName` is the name of the log, `LogFile` is the name of the log file. `Start` is the start (first) date and time from which log events will be converted and `Stop` is the stop (last) date and time to which log events will be converted.

The format of an audit trail log text item is as follows:

`Tag Addr - Community [TimeStamp] Vsn`
`PDU`

where `Tag` is `request`, `response`, `report`, `trap` or `inform`; Addr is `IP:Port` (or comma space separated list of such); `Community` is the community parameter (SNMP version v1 and v2), or `SecLevel:"AuthEngineID":"UserName"` (SNMP v3); `TimeStamp` is a date and time stamp, and `Vsn` is the SNMP version. `PDU` is a textual version of the protocol data unit. There is a new line between `Vsn` and `PDU`.

`change_log_size(LogName, NewSize) -> ok | {error, Reason}`

Types:

`LogName = string()`
`NewSize = {MaxBytes, MaxFiles}`
`MaxBytes = integer()`
`MaxFiles = integer()`
`Reason = term()`

Changes the log size of the Audit Trail Log. The application must be configured to use the audit trail log function. Please refer to disk_log(3) in Kernel Reference Manual for a description of how to change the log size.

The change is permanent, as long as the log is not deleted. That means, the log size is remebered across reboots.

### See Also

calendar(3)

### AUTHORS

Martin Björklund - support@erlang.ericsson.se
Klas Eriksson - support@erlang.ericsson.se

snmp 4.1.1
Copyright © 1991-2005 Ericsson AB