1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
|
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE erlref SYSTEM "erlref.dtd">
<erlref>
<header>
<copyright>
<year>1996</year><year>2016</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
</legalnotice>
<title>snmp</title>
<prepared></prepared>
<responsible></responsible>
<docno></docno>
<approved></approved>
<checked></checked>
<date></date>
<rev></rev>
<file>snmp.xml</file>
</header>
<module>snmp</module>
<modulesummary>Interface functions to the SNMP toolkit</modulesummary>
<description>
<p>The module <c>snmp</c> contains interface functions to the
SNMP toolkit.</p>
</description>
<section>
<title>Common Data Types</title>
<p>The following data-types are used in the functions below: </p>
<list type="bulleted">
<item>
<p><c>datetime() = {date(), time()}</c></p>
<p>See <seealso marker="stdlib:calendar">calendar</seealso>
for more info.</p>
</item>
</list>
<marker id="config"></marker>
</section>
<funcs>
<func>
<name>config() -> ok | {error, Reason}</name>
<fsummary>Configure with a simple interactive tool</fsummary>
<desc>
<p>A simple interactive configuration tool. Simple
configuration files can be generated, but more complex
configurations still have to be edited manually.
</p>
<p>The tool is a textual based tool that asks some questions
and generates <c>sys.config</c> and <c>*.conf</c> files.
</p>
<p><em>Note</em> that if the application shall support version 3,
then the crypto app must be started before running this function
(password generation).</p>
<p><em>Note</em> also that some of the configuration files for the
agent and manager share the same names. This means that
they have to be stored in <em>different</em> directories!</p>
<marker id="start"></marker>
</desc>
</func>
<func>
<name>start() -> ok | {error, Reason}</name>
<name>start(Type) -> ok | {error, Reason}</name>
<fsummary>Start the SNMP application</fsummary>
<type>
<v>Type = start_type()</v>
</type>
<desc>
<p>Starts the SNMP application.</p>
<p>See <seealso marker="kernel:application">application</seealso> for more info.</p>
<marker id="start_agent"></marker>
</desc>
</func>
<func>
<name>start_agent() -> ok | {error, Reason}</name>
<name>start_agent(Type) -> ok | {error, Reason}</name>
<fsummary>Start the agent part of the SNMP application</fsummary>
<type>
<v>Type = start_type()</v>
</type>
<desc>
<p>The SNMP application consists of several entities, of which the
agent is one. This function starts the agent entity of the
application.
</p>
<p>Note that the only way to actually start the agent in this way is
to add the agent related config after starting the application (e.g
it cannot be part of the normal application config; sys.config).
This is done by calling:
<c>application:set_env(snmp, agent, Conf)</c>.
</p>
<p>The default value for <c>Type</c> is <c>normal</c>.</p>
<marker id="start_manager"></marker>
</desc>
</func>
<func>
<name>start_manager() -> ok | {error, Reason}</name>
<name>start_manager(Type) -> ok | {error, Reason}</name>
<fsummary>Start the manager part of the SNMP application</fsummary>
<type>
<v>Type = start_type()</v>
</type>
<desc>
<p>The SNMP application consists of several entities, of which the
manager is one. This function starts the manager entity of the
application.
</p>
<p>Note that the only way to actually start the manager in this way is
to add the manager related config after starting the application (e.g
it cannot be part of the normal application config; sys.config).
This is done by calling:
<c>application:set_env(snmp, manager, Conf)</c>.
</p>
<p>The default value for <c>Type</c> is <c>normal</c>.</p>
<marker id="dat"></marker>
</desc>
</func>
<func>
<name>date_and_time() -> DateAndTime</name>
<fsummary>Return the current date and time as an OCTET STRING</fsummary>
<type>
<v>DateAndTime = [int()]</v>
</type>
<desc>
<p>Returns current date and time as the data type DateAndTime,
as specified in RFC1903. This is an OCTET STRING.</p>
<marker id="dat2ut_dst"></marker>
</desc>
</func>
<func>
<name>date_and_time_to_universal_time_dst(DateAndTime) -> [utc()]</name>
<fsummary>Convert a DateAndTime value to a list of possible utc()</fsummary>
<type>
<v>DateAndTime = [int()]</v>
<v>utc() = {{Y,Mo,D},{H,M,S}}</v>
</type>
<desc>
<p>Converts a DateAndTime list to a list of possible universal
time(s). The universal time value on the same format as defined in
calendar(3). </p>
<marker id="dat2s"></marker>
</desc>
</func>
<func>
<name>date_and_time_to_string(DateAndTime) -> string()</name>
<name>date_and_time_to_string(DateAndTime, Validate) -> string()</name>
<fsummary>Convert a DateAndTime value to a string</fsummary>
<type>
<v>DateAndTime = [int()]</v>
<v>Validate = fun(Kind, Data) -> boolean()</v>
</type>
<desc>
<p>Converts a DateAndTime list to a printable string, according
to the DISPLAY-HINT definition in RFC2579.</p>
<p>The validation fun, <c>Validate</c>, allows for a more "flexible"
validation of the <c>DateAndTime</c> argument. Whenever the data
is found to not follow RFC2579, the fun is called to allow a more
"lax" validation.
See the <seealso marker="#vdat">validate_date_and_time/2</seealso>
function for more info on the <c>Validate</c> fun. </p>
<marker id="dat2s2"></marker>
</desc>
</func>
<func>
<name>date_and_time_to_string2(DateAndTime) -> string()</name>
<fsummary>Convert a DateAndTime value to a string</fsummary>
<type>
<v>DateAndTime = [int()]</v>
</type>
<desc>
<p>Converts a DateAndTime list to a printable string, according
to the DISPLAY-HINT definition in RFC2579, with the extension
that it also allows the values "hours from UTC" = 14 together with
"minutes from UTC" = 0. </p>
<marker id="lt2dat_dst"></marker>
</desc>
</func>
<func>
<name>local_time_to_date_and_time_dst(Local) -> [DateAndTime]</name>
<fsummary>Convert a Local time value to a list of possible DateAndTime(s)</fsummary>
<type>
<v>Local = {{Y,Mo,D},{H,M,S}}</v>
<v>DateAndTime = [int()]</v>
</type>
<desc>
<p>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).</p>
<marker id="ut2dat"></marker>
</desc>
</func>
<func>
<name>universal_time_to_date_and_time(UTC) -> DateAndTime</name>
<fsummary>Convert a UTC value to DateAndTime</fsummary>
<type>
<v>UTC = {{Y,Mo,D},{H,M,S}}</v>
<v>DateAndTime = [int()]</v>
</type>
<desc>
<p>Converts a universal time value to a DateAndTime list. The
universal time value on the same format as defined in calendar(3).</p>
<marker id="vdat"></marker>
</desc>
</func>
<func>
<name>validate_date_and_time(DateAndTime) -> bool()</name>
<name>validate_date_and_time(DateAndTime, Validate) -> bool()</name>
<fsummary>Check if a DateAndTime value is correct</fsummary>
<type>
<v>DateAndTime = term()</v>
<v>Validate = fun(Kind, Data) -> boolean()</v>
</type>
<desc>
<p>Checks if <c>DateAndTime</c> is a correct DateAndTime
value, as specified in RFC2579. This function can be used in
instrumentation functions to validate a DateAndTime value.</p>
<p>The validation fun, <c>Validate</c>, allows for a more "flexible"
validation of the <c>DateAndTime</c> argument. Whenever the data
is found to not follow RFC2579, the fun is called to allow a more
"lax" validation.
The input to the validation fun looks like this: </p>
<pre>
Kind Data
-------------- ----------------------
year {Year1, Year2}
month Month
day Day
hour Hour
minute Minute
seconds Seconds
deci_seconds DeciSeconds
diff [Sign, Hour, Minute]
valid_date {Year, Month, Day}
</pre>
<marker id="passwd2localized_key"></marker>
</desc>
</func>
<func>
<name>passwd2localized_key(Alg, Passwd, EngineID) -> Key</name>
<fsummary>Generates an localized key</fsummary>
<type>
<v>Alg = algorithm()</v>
<v>algorithm() = md5 | sha</v>
<v>Passwd = string()</v>
<v>EngineID = string()</v>
<v>Key = list()</v>
</type>
<desc>
<p>Generates a key that can be used as an authentication
or privacy key using MD5 och SHA. The key is
localized for EngineID.</p>
<marker id="octet_string_to_bits"></marker>
</desc>
</func>
<func>
<name>octet_string_to_bits(S) -> Val</name>
<fsummary>Convert an OCTET-STRING to BITS</fsummary>
<type>
<v>Val = bits()</v>
</type>
<desc>
<p>Utility function for converting a value of type
<c>OCTET-STRING</c> to <c>BITS</c>. </p>
<marker id="bits_to_octet_string"></marker>
</desc>
</func>
<func>
<name>bits_to_octet_string(B) -> Val</name>
<fsummary>Convert an OCTET-STRING to BITS</fsummary>
<type>
<v>Val = octet_string()</v>
</type>
<desc>
<p>Utility function for converting a value of type <c>BITS</c>
to <c>OCTET-STRING</c>. </p>
<marker id="read_mib"></marker>
</desc>
</func>
<func>
<name>read_mib(FileName) -> {ok, mib()} | {error, Reason}</name>
<fsummary></fsummary>
<type>
<v>FileName = string()</v>
<v>mib() = #mib{}</v>
<v>Reason = term()</v>
</type>
<desc>
<p>Read a compiled mib.</p>
<marker id="log_to_txt"></marker>
</desc>
</func>
<func>
<name>log_to_txt(LogDir, Mibs, OutFile, LogName, LogFile) -> ok | {ok, Cnt} | {error, Reason}</name>
<name>log_to_txt(LogDir, Mibs, OutFile, LogName, LogFile, Block | Start) -> ok | {ok, Cnt} | {error, Reason}</name>
<name>log_to_txt(LogDir, Mibs, OutFile, LogName, LogFile, Start, Block | Stop) -> ok | {ok, Cnt} | {error, Reason}</name>
<name>log_to_txt(LogDir, Mibs, OutFile, LogName, LogFile, Start, Stop, Block) -> ok | {ok, Cnt} | {error, Reason}</name>
<fsummary>Convert an Audit Trail Log to text format</fsummary>
<type>
<v>LogDir = string()</v>
<v>Mibs = [MibName]</v>
<v>OutFile = string()</v>
<v>MibName = string()</v>
<v>LogName = string()</v>
<v>LogFile = string()</v>
<v>Start = Stop = null | datetime() | {local_time,datetime()} | {universal_time,datetime()} </v>
<v>Block = boolean()</v>
<v>Cnt = {NumOK, NumERR}</v>
<v>NumOK = non_neg_integer()</v>
<v>NumERR = pos_integer()</v>
<v>Reason = term()</v>
</type>
<desc>
<p>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. </p>
<p>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. </p>
<p><c>LogDir</c> is the name of the directory where the audit
trail log is stored.
<c>Mibs</c> 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.
<c>OutFile</c> is the name of the generated text-file.
<c>LogName</c> is the name of the log,
<c>LogFile</c> is the name of the log file.
<c>Start</c> is the start (first) date and time from which
log events will be converted and
<c>Stop</c> is the stop (last) date and time to which log
events will be converted.
The <c>Block</c> argument indicates if the log should be blocked
during conversion. This could be usefull when converting large
logs (when otherwise the log could wrap during conversion).
Defaults to <c>true</c>.
</p>
<p>The format of an audit trail log text item is as follows: </p>
<p><c>Tag Addr - Community [TimeStamp] Vsn</c><br></br>
<c>PDU</c></p>
<p>where <c>Tag</c> is <c>request</c>, <c>response</c>,
<c>report</c>, <c>trap</c> or <c>inform</c>; Addr is
<c>IP:Port</c> (or comma space separated list of such);
<c>Community</c> is the community parameter (SNMP version
v1 and v2), or <c>SecLevel:"AuthEngineID":"UserName"</c>
(SNMP v3); <c>TimeStamp</c> is a date and time stamp,
and <c>Vsn</c> is the SNMP version. <c>PDU</c> is a textual
version of the protocol data unit. There is a new line
between <c>Vsn</c> and <c>PDU</c>.</p>
<p>If the entire log is successfully converted, the function
will return <c>ok</c>.
If one of more entries fail to convert, the function will instead
return <c>{ok, {NumOK, NumERR}}</c>, where the counters indicate
how many valid and erroneous entries where found.
If instead <c>{error, Reason}</c> is returned, the conversion
encountered a fatal error and where either never done of aborted
midway. </p>
<marker id="log_to_io"></marker>
</desc>
</func>
<func>
<name>log_to_io(LogDir, Mibs, LogName, LogFile) -> ok | {ok, Cnt} | {error, Reason}</name>
<name>log_to_io(LogDir, Mibs, LogName, LogFile, Block | Start) -> ok | {ok, Cnt} | {error, Reason}</name>
<name>log_to_io(LogDir, Mibs, LogName, LogFile, Start, Block | Stop) -> ok | {ok, Cnt} | {error, Reason}</name>
<name>log_to_io(LogDir, Mibs, LogName, LogFile, Start, Stop, Block) -> ok | {ok, Cnt} | {error, Reason}</name>
<fsummary>Convert an Audit Trail Log to text format</fsummary>
<type>
<v>LogDir = string()</v>
<v>Mibs = [MibName]</v>
<v>MibName = string()</v>
<v>LogName = string()</v>
<v>LogFile = string()</v>
<v>Start = Stop = null | datetime() | {local_time,datetime()} | {universal_time,datetime()} </v>
<v>Cnt = {NumOK, NumERR}</v>
<v>NumOK = non_neg_integer()</v>
<v>NumERR = pos_integer()</v>
<v>Reason = term()</v>
</type>
<desc>
<p>Converts an Audit Trail Log to a readable format and
prints it on stdio. See
<seealso marker="snmp#log_to_txt">log_to_txt</seealso>
above for more info.</p>
<marker id="change_log_size"></marker>
</desc>
</func>
<func>
<name>change_log_size(LogName, NewSize) -> ok | {error, Reason}</name>
<fsummary>Change the size of the Audit Trail Log</fsummary>
<type>
<v>LogName = string()</v>
<v>NewSize = {MaxBytes, MaxFiles}</v>
<v>MaxBytes = integer()</v>
<v>MaxFiles = integer()</v>
<v>Reason = term()</v>
</type>
<desc>
<p>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.
</p>
<p>The change is permanent, as long as the log is not deleted.
That means, the log size is remembered across reboots.</p>
<marker id="print_version_info"></marker>
</desc>
</func>
<func>
<name>print_version_info() -> void()</name>
<name>print_version_info(Prefix) -> void()</name>
<fsummary>Formatted print of result of the versions functions</fsummary>
<type>
<v>Prefix = string() | integer()</v>
</type>
<desc>
<p>Utility function(s) to produce a formatted printout of the versions
info generated by the <c>versions1</c> function</p>
<p>This is the same as doing, e.g.: </p>
<pre>
{ok, V} = snmp:versions1(),
snmp:print_versions(V).
</pre>
<marker id="versions1"></marker>
<marker id="versions2"></marker>
</desc>
</func>
<func>
<name>versions1() -> {ok, Info} | {error, Reason}</name>
<name>versions2() -> {ok, Info} | {error, Reason}</name>
<fsummary>Retrieve various system and application info</fsummary>
<type>
<v>Info = [info()]</v>
<v>info() = term()</v>
<v>Reason = term()</v>
</type>
<desc>
<p>Utility functions used to retrieve some system and
application info.</p>
<p>The difference between the two functions is in how they get
the modules to check. <c>versions1</c> uses the app-file and
<c>versions2</c> uses the function <c>application:get_key</c>.</p>
<marker id="print_versions"></marker>
</desc>
</func>
<func>
<name>print_versions(VersionInfo) -> void()</name>
<name>print_versions(Prefix, VersionInfo) -> void()</name>
<fsummary>Formatted print of result of the versions functions</fsummary>
<type>
<v>VersionInfo = [version_info()]</v>
<v>version_info() = term()</v>
<v>Prefix = string() | integer()</v>
</type>
<desc>
<p>Utility function to produce a formatted printout of the versions
info generated by the <c>versions1</c> and <c>versions2</c>
functions</p>
<p>Example: </p>
<pre>
{ok, V} = snmp:versions1(),
snmp:print_versions(V).
</pre>
<marker id="enable_trace"></marker>
</desc>
</func>
<func>
<name>enable_trace() -> void()</name>
<fsummary>Starts a tracer</fsummary>
<!--
<type>
<v>Prefix = string() | integer()</v>
</type>
-->
<desc>
<p>Starts a dbg tracer that prints trace events to stdout (using
plain io:format after a minor formatting). </p>
<marker id="disable_trace"></marker>
</desc>
</func>
<func>
<name>disable_trace() -> void()</name>
<fsummary>Stop the tracer</fsummary>
<!--
<type>
<v>Prefix = string() | integer()</v>
</type>
-->
<desc>
<p>Stop the tracer. </p>
<marker id="set_trace1"></marker>
</desc>
</func>
<func>
<name>set_trace(Targets) -> void()</name>
<fsummary>Set trace target</fsummary>
<type>
<v>Targets = target() | targets()</v>
<v>target() = module()</v>
<v>module() = atom()</v>
<v>targets() = [target() | {target(), target_options()}]</v>
<v>target_options() = [target_option()]</v>
<v>target_option() = {return_trace, boolean()} | {scope, scope()}</v>
<v>scope() = all_functions | exported_functions | function_name() | {function_name(), function_arity()}</v>
<v>function_name() = atom()</v>
<v>function_arity() = integer() >= 0</v>
</type>
<desc>
<p>This function is used to set up default trace on function(s)
for the given module or modules. The scope of the trace will be
all <em>exported</em> functions (both the call info and the return
value). Timestamp info will also be included. </p>
<marker id="reset_trace"></marker>
</desc>
</func>
<func>
<name>reset_trace(Targets) -> void()</name>
<fsummary>Reset trace target</fsummary>
<type>
<v>Targets = module() | modules()</v>
<v>modules() = [module()]</v>
<v>module() = atom()</v>
</type>
<desc>
<p>This function is used to reset (disable) trace for the
given module(s). </p>
<marker id="set_trace2"></marker>
</desc>
</func>
<func>
<name>set_trace(Targets, Opts) -> void()</name>
<fsummary>Set trace target</fsummary>
<type>
<v>Targets = target() | targets()</v>
<v>target() = module()</v>
<v>module() = atom()</v>
<v>targets() = [target() | {target(), target_options()}]</v>
<v>target_options() = [target_option()]</v>
<v>target_option() = {return_trace, boolean()} | {scope, scope()}</v>
<v>scope() = all_functions | exported_functions | function_name() | {function_name(), function_arity()}</v>
<v>function_name() = atom()</v>
<v>function_arity() = integer() >= 0</v>
<v>Opts = disable | trace_options()</v>
<v>trace_options() = [trace_option()]</v>
<v>trace_option() = {timestamp, boolean()} | target_option()</v>
</type>
<desc>
<p>This function is used to set up trace on function(s) for the given
module or modules. </p>
<p>The example below sets up trace on the exported functions (default)
of module <c>snmp_generic</c> and all functions of module
<c>snmp_generic_mnesia</c>. With return values (which is default)
and timestamps in both cases (which is also default): </p>
<pre>
snmp:enable_trace(),
snmp:set_trace([snmp_generic,
{snmp_generic_mnesia, [{scope, all_functions}]}]),
.
.
.
snmp:set_trace(snmp_generic, disable),
.
.
.
snmp:disable_trace(),
</pre>
</desc>
</func>
</funcs>
<section>
<title>See Also</title>
<p>calendar(3)
</p>
</section>
</erlref>
|