1snmp(3)                    Erlang Module Definition                    snmp(3)
2
3
4

NAME

6       snmp - Interface functions to the SNMP toolkit
7

DESCRIPTION

9       The module snmp contains interface functions to the SNMP toolkit.
10

COMMON DATA TYPES

12       The following data-types are used in the functions below:
13
14         * datetime() = {date(), time()}
15
16           See calendar for more info.
17

EXPORTS

19       config() -> ok | {error, Reason}
20
21              A  simple  interactive  configuration tool. Simple configuration
22              files can be generated, but more  complex  configurations  still
23              have to be edited manually.
24
25              The  tool  is  a textual based tool that asks some questions and
26              generates sys.config and *.conf files.
27
28              Note that if the application shall support version 3,  then  the
29              crypto  app  must be started before running this function (pass‐
30              word generation).
31
32              Note also that some of the configuration files for the agent and
33              manager  share  the  same names. This means that they have to be
34              stored in different directories!
35
36       start() -> ok | {error, Reason}
37       start(Type) -> ok | {error, Reason}
38
39              Types:
40
41                 Type = start_type()
42
43              Starts the SNMP application.
44
45              See application for more info.
46
47       start_agent() -> ok | {error, Reason}
48       start_agent(Type) -> ok | {error, Reason}
49
50              Types:
51
52                 Type = start_type()
53
54              The SNMP application consists of several entities, of which  the
55              agent  is  one.  This  function  starts  the agent entity of the
56              application.
57
58              Note that the only way to actually start the agent in  this  way
59              is  to  add the agent related config after starting the applica‐
60              tion (e.g it cannot be part of the  normal  application  config;
61              sys.config).  This is done by calling: application:set_env(snmp,
62              agent, Conf).
63
64              The default value for Type is normal.
65
66       start_manager() -> ok | {error, Reason}
67       start_manager(Type) -> ok | {error, Reason}
68
69              Types:
70
71                 Type = start_type()
72
73              The SNMP application consists of several entities, of which  the
74              manager  is  one. This function starts the manager entity of the
75              application.
76
77              Note that the only way to actually start the manager in this way
78              is to add the manager related config after starting the applica‐
79              tion (e.g it cannot be part of the  normal  application  config;
80              sys.config).  This is done by calling: application:set_env(snmp,
81              manager, Conf).
82
83              The default value for Type is normal.
84
85       date_and_time() -> DateAndTime
86
87              Types:
88
89                 DateAndTime = [int()]
90
91              Returns current date and time as the data type  DateAndTime,  as
92              specified in RFC1903. This is an OCTET STRING.
93
94       date_and_time_to_universal_time_dst(DateAndTime) -> [utc()]
95
96              Types:
97
98                 DateAndTime = [int()]
99                 utc() = {{Y,Mo,D},{H,M,S}}
100
101              Converts  a  DateAndTime  list  to  a list of possible universal
102              time(s). The universal time value on the same format as  defined
103              in calendar(3).
104
105       date_and_time_to_string(DateAndTime) -> string()
106       date_and_time_to_string(DateAndTime, Validate) -> string()
107
108              Types:
109
110                 DateAndTime = [int()]
111                 Validate = fun(Kind, Data) -> boolean()
112
113              Converts  a DateAndTime list to a printable string, according to
114              the DISPLAY-HINT definition in RFC2579.
115
116              The validation fun, Validate, allows for a more "flexible" vali‐
117              dation  of  the DateAndTime argument. Whenever the data is found
118              to not follow RFC2579, the fun is called to allow a  more  "lax"
119              validation.  See  the validate_date_and_time/2 function for more
120              info on the Validate fun.
121
122       date_and_time_to_string2(DateAndTime) -> string()
123
124              Types:
125
126                 DateAndTime = [int()]
127
128              Converts a DateAndTime list to a printable string, according  to
129              the  DISPLAY-HINT definition in RFC2579, with the extension that
130              it also allows the values "hours from UTC" =  14  together  with
131              "minutes from UTC" = 0.
132
133       local_time_to_date_and_time_dst(Local) -> [DateAndTime]
134
135              Types:
136
137                 Local = {{Y,Mo,D},{H,M,S}}
138                 DateAndTime = [int()]
139
140              Converts  a  local  time value to a list of possible DateAndTime
141              list(s). The local time value on the same format as  defined  in
142              calendar(3).
143
144       universal_time_to_date_and_time(UTC) -> DateAndTime
145
146              Types:
147
148                 UTC = {{Y,Mo,D},{H,M,S}}
149                 DateAndTime = [int()]
150
151              Converts  a universal time value to a DateAndTime list. The uni‐
152              versal time value on the same format as defined in calendar(3).
153
154       validate_date_and_time(DateAndTime) -> bool()
155       validate_date_and_time(DateAndTime, Validate) -> bool()
156
157              Types:
158
159                 DateAndTime = term()
160                 Validate = fun(Kind, Data) -> boolean()
161
162              Checks if DateAndTime is a correct DateAndTime value, as  speci‐
163              fied  in  RFC2579.  This function can be used in instrumentation
164              functions to validate a DateAndTime value.
165
166              The validation fun, Validate, allows for a more "flexible" vali‐
167              dation  of  the DateAndTime argument. Whenever the data is found
168              to not follow RFC2579, the fun is called to allow a  more  "lax"
169              validation. The input to the validation fun looks like this:
170
171                        Kind             Data
172                        --------------   ----------------------
173                        year             {Year1, Year2}
174                        month            Month
175                        day              Day
176                        hour             Hour
177                        minute           Minute
178                        seconds          Seconds
179                        deci_seconds     DeciSeconds
180                        diff             [Sign, Hour, Minute]
181                        valid_date       {Year, Month, Day}
182
183
184       passwd2localized_key(Alg, Passwd, EngineID) -> Key
185
186              Types:
187
188                 Alg = algorithm()
189                 algorithm() = md5 | sha
190                 Passwd = string()
191                 EngineID = string()
192                 Key = list()
193
194              Generates a key that can be used as an authentication or privacy
195              key using MD5 och SHA. The key is localized for EngineID.
196
197       octet_string_to_bits(S) -> Val
198
199              Types:
200
201                 Val = bits()
202
203              Utility function for converting a value of type OCTET-STRING  to
204              BITS.
205
206       bits_to_octet_string(B) -> Val
207
208              Types:
209
210                 Val = octet_string()
211
212              Utility  function  for converting a value of type BITS to OCTET-
213              STRING.
214
215       read_mib(FileName) -> {ok, mib()} | {error, Reason}
216
217              Types:
218
219                 FileName = string()
220                 mib() = #mib{}
221                 Reason = term()
222
223              Read a compiled mib.
224
225       log_to_txt(LogDir, Mibs, OutFile, LogName, LogFile)  ->  ok  |  {error,
226       Reason}
227       log_to_txt(LogDir,  Mibs,  OutFile, LogName, LogFile, Block | Start) ->
228       ok | {error, Reason}
229       log_to_txt(LogDir, Mibs, OutFile,  LogName,  LogFile,  Start,  Block  |
230       Stop) -> ok | {error, Reason}
231       log_to_txt(LogDir, Mibs, OutFile, LogName, LogFile, Start, Stop, Block)
232       -> ok | {error, Reason}
233
234              Types:
235
236                 LogDir = string()
237                 Mibs = [MibName]
238                 OutFile = string()
239                 MibName = string()
240                 LogName = string()
241                 LogFile = string()
242                 Start = Stop = null | datetime() | {local_time,datetime()}  |
243                 {universal_time,datetime()}
244                 Block = boolean()
245                 Reason = term()
246
247              Converts  an Audit Trail Log to a readable text file, where each
248              item has a trailing TAB character, and any TAB character in  the
249              body of an item has been replaced by ESC TAB.
250
251              The  function can be used on a running system, or by copying the
252              entire log directory and calling this  function.  SNMP  must  be
253              running in order to provide MIB information.
254
255              LogDir is the name of the directory where the audit trail log is
256              stored. Mibs is a list of Mibs to be used. The function uses the
257              information  in  the  Mibs to convert for example object identi‐
258              fiers to their symbolic name. OutFile is the name of the  gener‐
259              ated  text-file.  LogName is the name of the log, LogFile is the
260              name of the log file. Start is the start (first) date  and  time
261              from  which  log  events  will be converted and Stop is the stop
262              (last) date and time to which log events will be converted.  The
263              Block  argument  indicates  if  the log should be blocked during
264              conversion. This could be usefull  when  converting  large  logs
265              (when  otherwise the log could wrap during conversion). Defaults
266              to true.
267
268              The format of an audit trail log text item is as follows:
269
270              Tag Addr - Community [TimeStamp] Vsn
271              PDU
272
273              where Tag is request, response, report, trap or inform; Addr  is
274              IP:Port  (or  comma  space separated list of such); Community is
275              the  community  parameter  (SNMP  version   v1   and   v2),   or
276              SecLevel:"AuthEngineID":"UserName"  (SNMP  v3);  TimeStamp  is a
277              date and time stamp, and Vsn is the SNMP version. PDU is a  tex‐
278              tual  version  of  the  protocol  data unit. There is a new line
279              between Vsn and PDU.
280
281       log_to_io(LogDir, Mibs, LogName, LogFile) -> ok | {error, Reason}
282       log_to_io(LogDir, Mibs, LogName,  LogFile,  Block  |  Start)  ->  ok  |
283       {error, Reason}
284       log_to_io(LogDir,  Mibs, LogName, LogFile, Start, Block | Stop) -> ok |
285       {error, Reason}
286       log_to_io(LogDir, Mibs, LogName, LogFile, Start, Stop, Block) ->  ok  |
287       {error, Reason}
288
289              Types:
290
291                 LogDir = string()
292                 Mibs = [MibName]
293                 MibName = string()
294                 LogName = string()
295                 LogFile = string()
296                 Start  = Stop = null | datetime() | {local_time,datetime()} |
297                 {universal_time,datetime()}
298                 Reason = term()
299
300              Converts an Audit Trail Log to a readable format and  prints  it
301              on stdio. See log_to_txt above for more info.
302
303       change_log_size(LogName, NewSize) -> ok | {error, Reason}
304
305              Types:
306
307                 LogName = string()
308                 NewSize = {MaxBytes, MaxFiles}
309                 MaxBytes = integer()
310                 MaxFiles = integer()
311                 Reason = term()
312
313              Changes  the  log  size  of the Audit Trail Log. The application
314              must be configured to use the audit trail log  function.  Please
315              refer  to  disk_log(3) in Kernel Reference Manual for a descrip‐
316              tion of how to change the log size.
317
318              The change is permanent, as long as the log is not deleted. That
319              means, the log size is remembered across reboots.
320
321       print_version_info() -> void()
322       print_version_info(Prefix) -> void()
323
324              Types:
325
326                 Prefix = string() | integer()
327
328              Utility  function(s) to produce a formatted printout of the ver‐
329              sions info generated by the versions1 function
330
331              This is the same as doing, e.g.:
332
333                         {ok, V} = snmp:versions1(),
334                         snmp:print_versions(V).
335
336
337       versions1() -> {ok, Info} | {error, Reason}
338       versions2() -> {ok, Info} | {error, Reason}
339
340              Types:
341
342                 Info = [info()]
343                 info() = term()
344                 Reason = term()
345
346              Utility functions used to retrieve some system  and  application
347              info.
348
349              The  difference between the two functions is in how they get the
350              modules to check. versions1 uses the app-file and versions2 uses
351              the function application:get_key.
352
353       print_versions(VersionInfo) -> void()
354       print_versions(Prefix, VersionInfo) -> void()
355
356              Types:
357
358                 VersionInfo = [version_info()]
359                 version_info() = term()
360                 Prefix = string() | integer()
361
362              Utility function to produce a formatted printout of the versions
363              info generated by the versions1 and versions2 functions
364
365              Example:
366
367                         {ok, V} = snmp:versions1(),
368                         snmp:print_versions(V).
369
370
371       enable_trace() -> void()
372
373              Starts a dbg tracer that prints trace events  to  stdout  (using
374              plain io:format after a minor formatting).
375
376       disable_trace() -> void()
377
378              Stop the tracer.
379
380       set_trace(Targets) -> void()
381
382              Types:
383
384                 Targets = target() | targets()
385                 target() = module()
386                 module() = atom()
387                 targets() = [target() | {target(), target_options()}]
388                 target_options() = [target_option()]
389                 target_option()   =   {return_trace,   boolean()}  |  {scope,
390                 scope()}
391                 scope()  =  all_functions  |   exported_functions   |   func‐
392                 tion_name() | {function_name(), function_arity()}
393                 function_name() = atom()
394                 function_arity() = integer() >= 0
395
396              This function is used to set up default trace on function(s) for
397              the given module or modules. The scope of the trace will be  all
398              exported  functions  (both  the call info and the return value).
399              Timestamp info will also be included.
400
401       reset_trace(Targets) -> void()
402
403              Types:
404
405                 Targets = module() | modules()
406                 modules() = [module()]
407                 module() = atom()
408
409              This function is used to reset (disable)  trace  for  the  given
410              module(s).
411
412       set_trace(Targets, Opts) -> void()
413
414              Types:
415
416                 Targets = target() | targets()
417                 target() = module()
418                 module() = atom()
419                 targets() = [target() | {target(), target_options()}]
420                 target_options() = [target_option()]
421                 target_option()   =   {return_trace,   boolean()}  |  {scope,
422                 scope()}
423                 scope()  =  all_functions  |   exported_functions   |   func‐
424                 tion_name() | {function_name(), function_arity()}
425                 function_name() = atom()
426                 function_arity() = integer() >= 0
427                 Opts = disable | trace_options()
428                 trace_options() = [trace_option()]
429                 trace_option() = {timestamp, boolean()} | target_option()
430
431              This  function  is  used  to set up trace on function(s) for the
432              given module or modules.
433
434              The example below  sets  up  trace  on  the  exported  functions
435              (default)  of  module  snmp_generic  and all functions of module
436              snmp_generic_mnesia. With return values (which is  default)  and
437              timestamps in both cases (which is also default):
438
439                     snmp:enable_trace(),
440                     snmp:set_trace([snmp_generic,
441                                        {snmp_generic_mnesia, [{scope, all_functions}]}]),
442                     .
443                     .
444                     .
445                        snmp:set_trace(snmp_generic, disable),
446                     .
447                     .
448                     .
449                     snmp:disable_trace(),
450
451

SEE ALSO

453       calendar(3)
454
455
456
457Ericsson AB                      snmp 5.2.11.1                         snmp(3)
Impressum