aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/snmp/doc/src/notes.xml73
-rw-r--r--lib/snmp/src/app/snmp.appup.src54
-rw-r--r--lib/snmp/src/misc/snmp_log.erl274
-rw-r--r--lib/snmp/src/misc/snmp_verbosity.erl16
-rw-r--r--lib/snmp/test/snmp_log_test.erl12
-rw-r--r--lib/snmp/vsn.mk2
6 files changed, 334 insertions, 97 deletions
diff --git a/lib/snmp/doc/src/notes.xml b/lib/snmp/doc/src/notes.xml
index 8d280fb3a1..9d9aa02d72 100644
--- a/lib/snmp/doc/src/notes.xml
+++ b/lib/snmp/doc/src/notes.xml
@@ -34,6 +34,79 @@
<section>
+ <title>SNMP Development Toolkit 4.22.3</title>
+ <p>Version 4.22.3 supports code replacement in runtime from/to
+ version 4.22.2, 4.22.1, 4.22,
+ 4.21.7 4.21.6 4.21.5, 4.21.4, 4.21.3, 4.21.2, 4.21.1 and 4.21. </p>
+
+ <section>
+ <title>Improvements and new features</title>
+ <p>-</p>
+
+<!--
+ <list type="bulleted">
+ <item>
+ <p>[agent] Errors in <c>vacmAccessTable</c> RowStatus handling.
+ There are problems with the handling of vacmAccessTableStatus
+ that cause some SNMP test suites to report errors.
+ Most notably, erroneous set operations frequently cause "genErr"
+ errors to be returned. These "genErr" errors are usually caused
+ by badmatch exceptions coming from
+ <c>{ok, Row} = snmpa_vacm:get_row(RowIndex)</c>
+ if the row does not exist. </p>
+ <p>The semantics of the RowStatus handling in that table has
+ been adjusted to be compliant with the RowStatus
+ textual description of SNPMv2-TC MIB. </p>
+ <p>Stefan Zegenhagen</p>
+ <p>Own Id: OTP-10164</p>
+ </item>
+ </list>
+-->
+
+ </section>
+
+ <section>
+ <title>Fixed Bugs and Malfunctions</title>
+<!--
+ <p>-</p>
+-->
+
+ <list type="bulleted">
+ <item>
+ <p>Loosing log entries when converting a large Audit Trail Log. </p>
+ <p>When converting an entire Audit Trail Log in a running
+ system its possble to have log wraps and thereby loosing log
+ entries. </p>
+ <p>In order to prevent this the log is now blocked
+ during conversion (<c>log_to_txt</c> or <c>log_to_io</c>). </p>
+ <p>Own Id: OTP-11396</p>
+ <p>Own Id: seq12433</p>
+ </item>
+
+ <item>
+ <p>When converting the Audit Trail Log to text a corrupt
+ log entry could cause the entire conversion to fail. </p>
+ <p>Also, for a log with sequence numbers, failing to
+ decode a log entry would cause the conversion to fail
+ (not because of the failed decode, but because of the
+ failure to write the error message). </p>
+ <p>Own Id: OTP-11453</p>
+ <p>Aux Id: Seq 12459</p>
+ </item>
+
+ </list>
+
+ </section>
+
+ <section>
+ <title>Incompatibilities</title>
+ <p>-</p>
+ </section>
+
+ </section> <!-- 4.22.3 -->
+
+
+ <section>
<title>SNMP Development Toolkit 4.22.2</title>
<p>Version 4.22.2 supports code replacement in runtime from/to
version 4.22.1, 4.22,
diff --git a/lib/snmp/src/app/snmp.appup.src b/lib/snmp/src/app/snmp.appup.src
index 39e154d463..31f56cb73c 100644
--- a/lib/snmp/src/app/snmp.appup.src
+++ b/lib/snmp/src/app/snmp.appup.src
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1999-2012. All Rights Reserved.
+%% Copyright Ericsson AB 1999-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -22,12 +22,22 @@
%% ----- U p g r a d e -------------------------------------------------------
[
+ {"4.22.2",
+ [
+ {load_module, snmp_log, soft_purge, soft_purge, [snmp_verbosity]},
+ {load_module, snmp_verbosity, soft_purge, soft_purge, []}
+ ]
+ },
{"4.22.1",
[
+ {load_module, snmp_log, soft_purge, soft_purge, [snmp_verbosity]},
+ {load_module, snmp_verbosity, soft_purge, soft_purge, []}
]
},
{"4.22",
[
+ {load_module, snmp_log, soft_purge, soft_purge, [snmp_verbosity]},
+ {load_module, snmp_verbosity, soft_purge, soft_purge, []},
{load_module, snmpm, soft_purge, soft_purge, []},
{load_module, snmp_pdus, soft_purge, soft_purge, []},
{load_module, snmp_view_based_acm_mib, soft_purge, soft_purge, []},
@@ -51,7 +61,7 @@
{load_module, snmp, soft_purge, soft_purge, [snmp_log]},
{load_module, snmpa, soft_purge, soft_purge, [snmp]},
{load_module, snmpm, soft_purge, soft_purge, [snmp]},
- {load_module, snmp_log, soft_purge, soft_purge, []},
+ {load_module, snmp_log, soft_purge, soft_purge, [snmp_verbosity]},
{load_module, snmp_verbosity, soft_purge, soft_purge, []},
{load_module, snmpm_mpd, soft_purge, soft_purge, []},
@@ -79,7 +89,7 @@
{load_module, snmp, soft_purge, soft_purge, [snmp_log]},
{load_module, snmpa, soft_purge, soft_purge, [snmp]},
{load_module, snmpm, soft_purge, soft_purge, [snmp]},
- {load_module, snmp_log, soft_purge, soft_purge, []},
+ {load_module, snmp_log, soft_purge, soft_purge, [snmp_verbosity]},
{load_module, snmp_verbosity, soft_purge, soft_purge, []},
{load_module, snmpm_mpd, soft_purge, soft_purge, []},
@@ -105,7 +115,7 @@
{load_module, snmp, soft_purge, soft_purge, [snmp_log]},
{load_module, snmpm, soft_purge, soft_purge, [snmp]},
- {load_module, snmp_log, soft_purge, soft_purge, []},
+ {load_module, snmp_log, soft_purge, soft_purge, [snmp_verbosity]},
{load_module, snmp_verbosity, soft_purge, soft_purge, []},
{load_module, snmpm_mpd, soft_purge, soft_purge, []},
@@ -137,7 +147,7 @@
{load_module, snmp, soft_purge, soft_purge, [snmp_log]},
{load_module, snmpm, soft_purge, soft_purge, [snmp]},
- {load_module, snmp_log, soft_purge, soft_purge, []},
+ {load_module, snmp_log, soft_purge, soft_purge, [snmp_verbosity]},
{load_module, snmp_verbosity, soft_purge, soft_purge, []},
{load_module, snmpm_mpd, soft_purge, soft_purge, []},
@@ -173,7 +183,7 @@
{load_module, snmp, soft_purge, soft_purge, [snmp_log]},
{load_module, snmpm, soft_purge, soft_purge, [snmp]},
- {load_module, snmp_log, soft_purge, soft_purge, []},
+ {load_module, snmp_log, soft_purge, soft_purge, [snmp_verbosity]},
{load_module, snmp_verbosity, soft_purge, soft_purge, []},
{load_module, snmpm_mpd, soft_purge, soft_purge, []},
@@ -209,7 +219,7 @@
{load_module, snmp, soft_purge, soft_purge, [snmp_log]},
{load_module, snmpm, soft_purge, soft_purge, [snmp]},
- {load_module, snmp_log, soft_purge, soft_purge, []},
+ {load_module, snmp_log, soft_purge, soft_purge, [snmp_verbosity]},
{load_module, snmp_verbosity, soft_purge, soft_purge, []},
{load_module, snmpm_mpd, soft_purge, soft_purge, []},
@@ -247,7 +257,7 @@
{load_module, snmp, soft_purge, soft_purge, [snmp_log]},
{load_module, snmpm, soft_purge, soft_purge, [snmp]},
- {load_module, snmp_log, soft_purge, soft_purge, []},
+ {load_module, snmp_log, soft_purge, soft_purge, [snmp_verbosity]},
{load_module, snmp_verbosity, soft_purge, soft_purge, []},
{load_module, snmpm_mpd, soft_purge, soft_purge, []},
@@ -286,7 +296,7 @@
{load_module, snmp, soft_purge, soft_purge, [snmp_log]},
{load_module, snmpm, soft_purge, soft_purge, [snmp]},
- {load_module, snmp_log, soft_purge, soft_purge, []},
+ {load_module, snmp_log, soft_purge, soft_purge, [snmp_verbosity]},
{load_module, snmp_verbosity, soft_purge, soft_purge, []},
{load_module, snmpm_mpd, soft_purge, soft_purge, []},
@@ -316,12 +326,22 @@
%% ------D o w n g r a d e ---------------------------------------------------
[
+ {"4.22.2",
+ [
+ {load_module, snmp_log, soft_purge, soft_purge, [snmp_verbosity]},
+ {load_module, snmp_verbosity, soft_purge, soft_purge, []}
+ ]
+ },
{"4.22.1",
[
+ {load_module, snmp_log, soft_purge, soft_purge, [snmp_verbosity]},
+ {load_module, snmp_verbosity, soft_purge, soft_purge, []}
]
},
{"4.22",
[
+ {load_module, snmp_log, soft_purge, soft_purge, [snmp_verbosity]},
+ {load_module, snmp_verbosity, soft_purge, soft_purge, []},
{load_module, snmpm, soft_purge, soft_purge, []},
{load_module, snmp_pdus, soft_purge, soft_purge, []},
{load_module, snmp_view_based_acm_mib, soft_purge, soft_purge, []},
@@ -346,7 +366,7 @@
{load_module, snmp, soft_purge, soft_purge, [snmp_log]},
{load_module, snmpa, soft_purge, soft_purge, [snmp]},
{load_module, snmpm, soft_purge, soft_purge, [snmp]},
- {load_module, snmp_log, soft_purge, soft_purge, []},
+ {load_module, snmp_log, soft_purge, soft_purge, [snmp_verbosity]},
{load_module, snmp_verbosity, soft_purge, soft_purge, []},
{load_module, snmpm_mpd, soft_purge, soft_purge, []},
@@ -374,7 +394,7 @@
{load_module, snmp, soft_purge, soft_purge, [snmp_log]},
{load_module, snmpa, soft_purge, soft_purge, [snmp]},
{load_module, snmpm, soft_purge, soft_purge, [snmp]},
- {load_module, snmp_log, soft_purge, soft_purge, []},
+ {load_module, snmp_log, soft_purge, soft_purge, [snmp_verbosity]},
{load_module, snmp_verbosity, soft_purge, soft_purge, []},
{load_module, snmpm_mpd, soft_purge, soft_purge, []},
@@ -400,7 +420,7 @@
{load_module, snmp, soft_purge, soft_purge, [snmp_log]},
{load_module, snmpm, soft_purge, soft_purge, [snmp]},
- {load_module, snmp_log, soft_purge, soft_purge, []},
+ {load_module, snmp_log, soft_purge, soft_purge, [snmp_verbosity]},
{load_module, snmp_verbosity, soft_purge, soft_purge, []},
{load_module, snmpm_mpd, soft_purge, soft_purge, []},
@@ -432,7 +452,7 @@
{load_module, snmp, soft_purge, soft_purge, [snmp_log]},
{load_module, snmpm, soft_purge, soft_purge, [snmp]},
- {load_module, snmp_log, soft_purge, soft_purge, []},
+ {load_module, snmp_log, soft_purge, soft_purge, [snmp_verbosity]},
{load_module, snmp_verbosity, soft_purge, soft_purge, []},
{load_module, snmpm_mpd, soft_purge, soft_purge, []},
@@ -468,7 +488,7 @@
{load_module, snmp, soft_purge, soft_purge, [snmp_log]},
{load_module, snmpm, soft_purge, soft_purge, [snmp]},
- {load_module, snmp_log, soft_purge, soft_purge, []},
+ {load_module, snmp_log, soft_purge, soft_purge, [snmp_verbosity]},
{load_module, snmp_verbosity, soft_purge, soft_purge, []},
{load_module, snmpm_mpd, soft_purge, soft_purge, []},
@@ -504,7 +524,7 @@
{load_module, snmp, soft_purge, soft_purge, [snmp_log]},
{load_module, snmpm, soft_purge, soft_purge, [snmp]},
- {load_module, snmp_log, soft_purge, soft_purge, []},
+ {load_module, snmp_log, soft_purge, soft_purge, [snmp_verbosity]},
{load_module, snmp_verbosity, soft_purge, soft_purge, []},
{load_module, snmpm_mpd, soft_purge, soft_purge, []},
@@ -542,7 +562,7 @@
{load_module, snmp, soft_purge, soft_purge, [snmp_log]},
{load_module, snmpm, soft_purge, soft_purge, [snmp]},
- {load_module, snmp_log, soft_purge, soft_purge, []},
+ {load_module, snmp_log, soft_purge, soft_purge, [snmp_verbosity]},
{load_module, snmp_verbosity, soft_purge, soft_purge, []},
{load_module, snmpm_mpd, soft_purge, soft_purge, []},
@@ -581,7 +601,7 @@
{load_module, snmp, soft_purge, soft_purge, [snmp_log]},
{load_module, snmpm, soft_purge, soft_purge, [snmp]},
- {load_module, snmp_log, soft_purge, soft_purge, []},
+ {load_module, snmp_log, soft_purge, soft_purge, [snmp_verbosity]},
{load_module, snmp_verbosity, soft_purge, soft_purge, []},
{load_module, snmpm_mpd, soft_purge, soft_purge, []},
diff --git a/lib/snmp/src/misc/snmp_log.erl b/lib/snmp/src/misc/snmp_log.erl
index a8c5df0b64..1aba3b56f8 100644
--- a/lib/snmp/src/misc/snmp_log.erl
+++ b/lib/snmp/src/misc/snmp_log.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1997-2012. All Rights Reserved.
+%% Copyright Ericsson AB 1997-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -16,6 +16,7 @@
%%
%% %CopyrightEnd%
%%
+%%
-module(snmp_log).
@@ -397,6 +398,8 @@ log_to_txt(Log, FileName, Dir, Mibs, TextFile, Start, Stop)
[Log, FileName, Dir, Mibs, TextFile, Start, Stop]),
File = filename:join(Dir, FileName),
Converter = fun(L) ->
+ ?vtrace("log_to_txt:fun -> entry with"
+ "~n L: ~p", [L]),
do_log_to_file(L, TextFile, Mibs, Start, Stop)
end,
log_convert(Log, File, Converter).
@@ -422,6 +425,8 @@ log_to_io(Log, FileName, Dir, Mibs, Start, Stop)
[Log, FileName, Dir, Mibs, Start, Stop]),
File = filename:join(Dir, FileName),
Converter = fun(L) ->
+ ?vtrace("log_to_io:fun -> entry with"
+ "~n L: ~p", [L]),
do_log_to_io(L, Mibs, Start, Stop)
end,
log_convert(Log, File, Converter).
@@ -441,20 +446,21 @@ log_convert(Log, File, Converter) ->
do_log_convert(Log, File, Converter) ->
%% ?vtrace("do_log_converter -> entry with"
%% "~n Log: ~p"
- %% "~n File: ~p"
- %% "~n disk_log:info(Log): ~p", [Log, File, disk_log:info(Log)]),
+ %% "~n File: ~p", [Log, File]),
+ Verbosity = get(verbosity),
{Pid, Ref} =
erlang:spawn_monitor(
fun() ->
+ put(sname, lc),
+ put(verbosity, Verbosity),
Result = do_log_convert2(Log, File, Converter),
+ %% ?vlog("convert result: ~p", [Result]),
exit(Result)
end),
receive
{'DOWN', Ref, process, Pid, Result} ->
%% ?vtrace("do_log_converter -> received result"
- %% "~n Result: ~p"
- %% "~n disk_log:info(Log): ~p",
- %% [Result, disk_log:info(Log)]),
+ %% "~n Result: ~p", [Result]),
Result
end.
@@ -462,19 +468,35 @@ do_log_convert2(Log, File, Converter) ->
%% First check if the caller process has already opened the
%% log, because if we close an already open log we will cause
%% a runtime error.
+ ?vtrace("do_log_convert2 -> entry - check if owner", []),
case is_owner(Log) of
true ->
- Converter(Log);
+ ?vdebug("do_log_converter2 -> owner - now convert log", []),
+ disk_log:block(Log, true),
+ Res = Converter(Log),
+ disk_log:unblock(Log),
+ Res;
false ->
%% Not yet member of the ruling party, apply for membership...
+ ?vtrace("do_log_converter2 -> not owner - open log", []),
case log_open(Log, File) of
{ok, _} ->
+ ?vdebug("do_log_convert2 -> opened - now convert log", []),
+ disk_log:block(Log, true),
Res = Converter(Log),
+ disk_log:unblock(Log),
disk_log:close(Log),
Res;
{error, {name_already_open, _}} ->
- Converter(Log);
+ ?vdebug("do_log_convert2 -> "
+ "already opened - now convert log", []),
+ disk_log:block(Log, true),
+ Res = Converter(Log),
+ disk_log:unblock(Log),
+ Res;
{error, Reason} ->
+ ?vinfo("Failed converting log - open failed: "
+ "~n Reason: ~p", [Reason]),
{error, {Log, Reason}}
end
end.
@@ -483,50 +505,93 @@ do_log_convert2(Log, File, Converter) ->
%% -- do_log_to_text ---
do_log_to_file(Log, TextFile, Mibs, Start, Stop) ->
+ ?vtrace("do_log_to_txt -> entry with"
+ "~n Log: ~p"
+ "~n TextFile: ~p"
+ "~n Start: ~p"
+ "~n Stop: ~p", [Log, TextFile, Start, Stop]),
case file:open(TextFile, [write]) of
{ok, Fd} ->
+ ?vtrace("do_log_to_txt -> outfile created - create mini MIB", []),
MiniMib = snmp_mini_mib:create(Mibs),
+ ?vtrace("do_log_to_txt -> mini-MIB created - begin conversion", []),
Write = fun(X) ->
+ ?vtrace("do_log_to_txt:fun -> "
+ "entry - try format", []),
case format_msg(X, MiniMib, Start, Stop) of
{ok, S} ->
+ ?vtrace("do_log_to_txt:fun -> "
+ "formated - now write", []),
io:format(Fd, "~s", [S]);
_ ->
+ ?vdebug("do_log_to_txt:fun -> "
+ "format failed", []),
ok
end
end,
Res = (catch loop(disk_log:chunk(Log, start), Log, Write)),
+ ?vtrace("do_log_to_txt -> converted - now delete mini-MIB", []),
snmp_mini_mib:delete(MiniMib),
+ ?vtrace("do_log_to_txt -> "
+ "mini-MIB closed - now close output file", []),
file:close(Fd),
+ ?vtrace("do_log_to_txt -> done", []),
Res;
{error, Reason} ->
+ ?vinfo("Failed opening output file: "
+ "~n TestFile: ~p"
+ "~n Reason: ~p", [TextFile, Reason]),
{error, {TextFile, Reason}}
end.
do_log_to_io(Log, Mibs, Start, Stop) ->
+ ?vtrace("do_log_to_io -> entry with"
+ "~n Log: ~p"
+ "~n Mibs: ~p"
+ "~n Start: ~p"
+ "~n Stop: ~p", [Log, Mibs, Start, Stop]),
MiniMib = snmp_mini_mib:create(Mibs),
+ ?vtrace("do_log_to_io -> mini-MIB created - begin conversion", []),
Write = fun(X) ->
+ ?vtrace("do_log_to_io:fun -> entry", []),
case format_msg(X, MiniMib, Start, Stop) of
{ok, S} ->
+ ?vtrace("do_log_to_io:fun -> "
+ "formated - now write", []),
io:format("~s", [S]);
_ ->
+ ?vdebug("do_log_to_io:fun -> "
+ "format failed", []),
ok
end
end,
(catch loop(disk_log:chunk(Log, start), Log, Write)),
+ ?vtrace("do_log_to_io -> converted - now delete mini-MIB", []),
snmp_mini_mib:delete(MiniMib),
+ ?vtrace("do_log_to_io -> done", []),
ok.
loop(eof, _Log, _Write) ->
+ ?vtrace("loop -> entry when eof", []),
ok;
-loop({error, _} = Error, _Log, _Write) ->
+loop({error, _Reason} = Error, _Log, _Write) ->
+ ?vtrace("loop -> entry with error"
+ "~n Reason: ~p", [_Reason]),
Error;
loop({Cont, Terms}, Log, Write) ->
- case (catch lists:foreach(Write, Terms)) of
+ ?vtrace("loop -> entry with terms"
+ "~n Cont: ~p"
+ "~n length(Terms): ~p", [Cont, length(Terms)]),
+ case (catch lists:foreach(Write, Terms)) of
{'EXIT', Reason} ->
+ ?vtrace("loop -> failure while writing terms"
+ "~n Reason: ~p", [Reason]),
{error, Reason};
- _ ->
+ _X ->
+ ?vtrace("loop -> terms written"
+ "~n X: ~p", [_X]),
loop(disk_log:chunk(Log, Cont), Log, Write)
end;
loop({Cont, Terms, BadBytes}, Log, Write) ->
@@ -539,6 +604,8 @@ loop({Cont, Terms, BadBytes}, Log, Write) ->
loop(disk_log:chunk(Log, Cont), Log, Write)
end;
loop(Error, _Log, _Write) ->
+ ?vtrace("loop -> entry with unknown"
+ "~n Error: ~p", [Error]),
Error.
@@ -553,14 +620,17 @@ format_msg(Entry, Mib, Start, Stop) ->
%% This is an old-style entry, that never had the sequence-number
do_format_msg({Timestamp, Packet, {Addr, Port}}, Mib) ->
+ ?vdebug("do_format_msg -> old style log entry", []),
do_format_msg(Timestamp, Packet, Addr, Port, Mib);
%% This is the format without sequence-number
do_format_msg({Timestamp, Packet, Addr, Port}, Mib) ->
+ ?vdebug("do_format_msg -> log entry without seqno", []),
do_format_msg(Timestamp, Packet, Addr, Port, Mib);
%% This is the format with sequence-number
do_format_msg({Timestamp, SeqNo, Packet, Addr, Port}, Mib) ->
+ ?vdebug("do_format_msg -> log entry with seqno", []),
do_format_msg(Timestamp, SeqNo, Packet, Addr, Port, Mib);
%% This is crap...
@@ -568,103 +638,165 @@ do_format_msg(_, _) ->
format_tab("** unknown entry in log file\n\n", []).
do_format_msg(TimeStamp, {V3Hdr, ScopedPdu}, Addr, Port, Mib) ->
+ ?vtrace("do_format_msg -> entry with"
+ "~n Timestamp: ~p"
+ "~n Addr: ~p"
+ "~n Port: ~p"
+ "~n => Try decode scoped pdu",
+ [TimeStamp, Addr, Port]),
case (catch snmp_pdus:dec_scoped_pdu(ScopedPdu)) of
ScopedPDU when is_record(ScopedPDU, scopedPdu) ->
+ ?vtrace("do_format_msg -> scoped pdu decoded"
+ "~n ScopedPDU: ~p", [ScopedPDU]),
Msg = #message{version = 'version-3',
vsn_hdr = V3Hdr,
data = ScopedPDU},
f(ts2str(TimeStamp), "", Msg, Addr, Port, Mib);
+
{'EXIT', Reason} ->
- format_tab("** error in log file at ~s from ~p:~w ~p\n\n",
+ ?vinfo("Failed decoding scoped pdu: "
+ "~n V3Hdr: ~w"
+ "~n ScopedPdu: ~w"
+ "~n Reason: ~p", [V3Hdr, ScopedPdu, Reason]),
+ format_tab("** error in log file at ~s from ~s:~w ~p\n\n",
[ts2str(TimeStamp), ip(Addr), Port, Reason])
end;
+
do_format_msg(TimeStamp, Packet, Addr, Port, Mib) ->
+ ?vtrace("do_format_msg -> entry with"
+ "~n Timestamp: ~p"
+ "~n Addr: ~p"
+ "~n Port: ~p"
+ "~n => Try decode packet",
+ [TimeStamp, Addr, Port]),
case (catch snmp_pdus:dec_message(binary_to_list(Packet))) of
- Msg when is_record(Msg, message) ->
+ #message{data = Data} = Msg when (is_record(Data, scopedPdu) orelse
+ is_record(Data, pdu) orelse
+ is_record(Data, trappdu)) ->
+ ?vtrace("do_format_msg -> packet decoded"
+ "~n Msg: ~p", [Msg]),
f(ts2str(TimeStamp), "", Msg, Addr, Port, Mib);
+
+ #message{version = Vsn,
+ vsn_hdr = VsnHdr} = Msg ->
+ ?vinfo("Message not fully decoded: "
+ "~n Msg: ~p", [Msg]),
+ Reason =
+ lists:flatten(
+ io_lib:format("Message not fully decoded: "
+ "Vsn = ~p, VsnHdr = ~w", [Vsn, VsnHdr])),
+ format_tab("** error in log file ~s from ~s:~w => "
+ "\n ~s\n\n",
+ [ts2str(TimeStamp), ip(Addr), Port, Reason]);
+
{'EXIT', Reason} ->
+ ?vinfo("Failed decoding packet: "
+ "~n Packet: ~w"
+ "~n Reason: ~p", [Packet, Reason]),
format_tab("** error in log file ~p\n\n", [Reason])
end.
do_format_msg(TimeStamp, SeqNo, {V3Hdr, ScopedPdu}, Addr, Port, Mib) ->
+ ?vtrace("do_format_msg -> entry with"
+ "~n Timestamp: ~p"
+ "~n SeqNo: ~p"
+ "~n Addr: ~p"
+ "~n Port: ~p"
+ "~n => Try decode scoped pdu",
+ [TimeStamp, SeqNo, Addr, Port]),
case (catch snmp_pdus:dec_scoped_pdu(ScopedPdu)) of
ScopedPDU when is_record(ScopedPDU, scopedPdu) ->
+ ?vtrace("do_format_msg -> scoped pdu decoded"
+ "~n ScopedPDU: ~p", [ScopedPDU]),
Msg = #message{version = 'version-3',
vsn_hdr = V3Hdr,
data = ScopedPDU},
f(ts2str(TimeStamp), sn2str(SeqNo), Msg, Addr, Port, Mib);
+
{'EXIT', Reason} ->
- format_tab("** error in log file at ~s from ~p:~w ~p\n\n",
+ ?vinfo("Failed decoding scoped pdu: "
+ "~n V3Hdr: ~w"
+ "~n ScopedPdu: ~w"
+ "~n Reason: ~p", [V3Hdr, ScopedPdu, Reason]),
+ format_tab("** error in log file at ~s~s from ~s:~w ~p\n\n",
[ts2str(TimeStamp), sn2str(SeqNo),
ip(Addr), Port, Reason])
end;
do_format_msg(TimeStamp, SeqNo, Packet, Addr, Port, Mib) ->
+ ?vtrace("do_format_msg -> entry with"
+ "~n Timestamp: ~p"
+ "~n SeqNo: ~p"
+ "~n Addr: ~p"
+ "~n Port: ~p"
+ "~n => Try decode message",
+ [TimeStamp, SeqNo, Addr, Port]),
case (catch snmp_pdus:dec_message(binary_to_list(Packet))) of
- Msg when is_record(Msg, message) ->
+ #message{data = Data} = Msg when (is_record(Data, scopedPdu) orelse
+ is_record(Data, pdu) orelse
+ is_record(Data, trappdu)) ->
+ ?vtrace("do_format_msg -> message decoded"
+ "~n Msg: ~p", [Msg]),
f(ts2str(TimeStamp), sn2str(SeqNo), Msg, Addr, Port, Mib);
+
+ #message{version = Vsn,
+ vsn_hdr = VsnHdr} = Msg ->
+ ?vinfo("Message not fully decoded: "
+ "~n Msg: ~p", [Msg]),
+ Reason =
+ lists:flatten(
+ io_lib:format("Message not fully decoded: "
+ "Vsn = ~p, VsnHdr = ~w", [Vsn, VsnHdr])),
+ format_tab("** error in log file ~s~s from ~s:~w => "
+ "\n ~s\n\n",
+ [ts2str(TimeStamp), sn2str(SeqNo),
+ ip(Addr), Port, Reason]);
+
{'EXIT', Reason} ->
- format_tab("** error in log file ~s from ~p:~w ~p\n\n",
+ ?vinfo("Failed decoding packet: "
+ "~n Packet: ~w"
+ "~n Reason: ~p", [Packet, Reason]),
+ format_tab("** error in log file ~s (~s) from ~s:~w ~p\n\n",
[ts2str(TimeStamp), sn2str(SeqNo),
ip(Addr), Port, Reason])
end.
-%% format_msg({TimeStamp, {V3Hdr, ScopedPdu}, {Addr, Port}},
-%% Mib, Start, Stop) ->
-%% format_msg({TimeStamp, {V3Hdr, ScopedPdu}, Addr, Port},
-%% Mib, Start, Stop);
-%% format_msg({TimeStamp, {V3Hdr, ScopedPdu}, Addr, Port},
-%% Mib, Start, Stop) ->
-%% case timestamp_filter(TimeStamp, Start, Stop) of
-%% true ->
-%% case (catch snmp_pdus:dec_scoped_pdu(ScopedPdu)) of
-%% ScopedPDU when record(ScopedPDU, scopedPdu) ->
-%% Msg = #message{version = 'version-3',
-%% vsn_hdr = V3Hdr,
-%% data = ScopedPDU},
-%% f(ts2str(TimeStamp), Msg, Addr, Port, Mib);
-%% {'EXIT', Reason} ->
-%% format_tab("** error in log file at ~s from ~p:~w ~p\n\n",
-%% [ts2str(TimeStamp), ip(Addr), Port, Reason])
-%% end;
-%% false ->
-%% ignore
-%% end;
-%% format_msg({TimeStamp, Packet, {Addr, Port}}, Mib, Start, Stop) ->
-%% format_msg({TimeStamp, Packet, Addr, Port}, Mib, Start, Stop);
-%% format_msg({TimeStamp, Packet, Addr, Port}, Mib, Start, Stop) ->
-%% case timestamp_filter(TimeStamp, Start, Stop) of
-%% true ->
-%% case (catch snmp_pdus:dec_message(binary_to_list(Packet))) of
-%% Msg when record(Msg, message) ->
-%% f(ts2str(TimeStamp), Msg, Addr, Port, Mib);
-%% {'EXIT', Reason} ->
-%% format_tab("** error in log file ~p\n\n", [Reason])
-%% end;
-%% false ->
-%% ignore
-%% end;
-%% format_msg(_, _Mib, _Start, _Stop) ->
-%% format_tab("** unknown entry in log file\n\n", []).
-
f(TimeStamp, SeqNo,
#message{version = Vsn, vsn_hdr = VsnHdr, data = Data},
Addr, Port, Mib) ->
- Str = format_pdu(Data, Mib),
- HdrStr = format_header(Vsn, VsnHdr),
- case get_type(Data) of
- trappdu ->
- f_trap(TimeStamp, SeqNo, Vsn, HdrStr, Str, Addr, Port);
- 'snmpv2-trap' ->
- f_trap(TimeStamp, SeqNo, Vsn, HdrStr, Str, Addr, Port);
- 'inform-request' ->
- f_inform(TimeStamp, SeqNo, Vsn, HdrStr, Str, Addr, Port);
- 'get-response' ->
- f_response(TimeStamp, SeqNo, Vsn, HdrStr, Str, Addr, Port);
- report ->
- f_report(TimeStamp, SeqNo, Vsn, HdrStr, Str, Addr, Port);
- _ ->
- f_request(TimeStamp, SeqNo, Vsn, HdrStr, Str, Addr, Port)
+ try
+ begin
+ Str = format_pdu(Data, Mib),
+ HdrStr = format_header(Vsn, VsnHdr),
+ case get_type(Data) of
+ trappdu ->
+ f_trap(TimeStamp, SeqNo, Vsn, HdrStr, Str, Addr, Port);
+ 'snmpv2-trap' ->
+ f_trap(TimeStamp, SeqNo, Vsn, HdrStr, Str, Addr, Port);
+ 'inform-request' ->
+ f_inform(TimeStamp, SeqNo, Vsn, HdrStr, Str, Addr, Port);
+ 'get-response' ->
+ f_response(TimeStamp, SeqNo, Vsn, HdrStr, Str, Addr, Port);
+ report ->
+ f_report(TimeStamp, SeqNo, Vsn, HdrStr, Str, Addr, Port);
+ _ ->
+ f_request(TimeStamp, SeqNo, Vsn, HdrStr, Str, Addr, Port)
+ end
+ end
+ catch
+ T:E ->
+ ?vinfo("Failed formating log entry"
+ "~n TimeStamp: ~p"
+ "~n SeqNo: ~p"
+ "~n Data: ~p"
+ "~n Vsn: ~p"
+ "~n VsnHdr: ~p"
+ "~n Addr: ~p"
+ "~n Port: ~p"
+ "~n Error Type: ~w"
+ "~n Error: ~p",
+ [TimeStamp, SeqNo, Data, Vsn, VsnHdr, Addr, Port, T, E]),
+ format_tab("** error while formating log entry ~p\n\n", [{T, E}])
end.
f_request(TimeStamp, SeqNo, Vsn, HdrStr, Str, Addr, Port) ->
@@ -691,7 +823,7 @@ f_inform(TimeStamp, SeqNo, Vsn, HdrStr, Str, Addr, Port) ->
%% Convert a timestamp 2-tupple to a printable string
%%
ts2str({Local,Universal}) ->
- dat2str(Local) ++ " , " ++ dat2str(Universal);
+ lists:flatten(dat2str(Local) ++ " , " ++ dat2str(Universal));
ts2str(_) ->
"".
@@ -788,7 +920,7 @@ get_type(#pdu{type = Type}) ->
ip({A,B,C,D}) ->
- io_lib:format("~w.~w.~w.~w", [A,B,C,D]).
+ lists:flatten(io_lib:format("~w.~w.~w.~w", [A,B,C,D])).
diff --git a/lib/snmp/src/misc/snmp_verbosity.erl b/lib/snmp/src/misc/snmp_verbosity.erl
index df5986b7bc..7d063fd702 100644
--- a/lib/snmp/src/misc/snmp_verbosity.erl
+++ b/lib/snmp/src/misc/snmp_verbosity.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2000-2012. All Rights Reserved.
+%% Copyright Ericsson AB 2000-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -148,11 +148,23 @@ image_of_sname(mnifl) -> "M-NET-IF-LOGGER";
image_of_sname(mnifw) -> io_lib:format("M-NET-IF-worker(~p)", [self()]);
image_of_sname(mconf) -> "M-CONF";
+image_of_sname(lc) -> io_lib:format("LOG-CONVERTER(~p)", [self()]);
+
image_of_sname(mgr) -> "MGR";
image_of_sname(mgr_misc) -> "MGR_MISC";
image_of_sname(undefined) -> "";
-image_of_sname(V) -> lists:flatten(io_lib:format("~p",[V])).
+image_of_sname(S) when is_list(S) ->
+ %% The assumption is that its a printable string,
+ %% but just in case it is some other list...
+ try lists:flatten(io_lib:format("~s", [S])) of
+ L ->
+ L
+ catch
+ _:_ ->
+ lists:flatten(io_lib:format("~p", [S]))
+ end;
+image_of_sname(V) -> lists:flatten(io_lib:format("~p", [V])).
validate(info) -> info;
diff --git a/lib/snmp/test/snmp_log_test.erl b/lib/snmp/test/snmp_log_test.erl
index aeac4d1f71..3b810493cb 100644
--- a/lib/snmp/test/snmp_log_test.erl
+++ b/lib/snmp/test/snmp_log_test.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2003-2012. All Rights Reserved.
+%% Copyright Ericsson AB 2003-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -331,7 +331,7 @@ log_to_io1(doc) -> "Log to io from the same process that opened "
log_to_io1(Config) when is_list(Config) ->
p(log_to_io1),
put(sname,l2i1),
- put(verbosity,trace),
+ put(verbosity, debug),
?DBG("log_to_io1 -> start", []),
Dir = ?config(log_dir, Config),
Name = "snmp_test_l2i1",
@@ -386,7 +386,7 @@ log_to_io2(Config) when is_list(Config) ->
process_flag(trap_exit, true),
p(log_to_io2),
put(sname, l2i2),
- put(verbosity,trace),
+ put(verbosity, debug),
?DBG("log_to_io2 -> start", []),
Dir = ?config(log_dir, Config),
Name = "snmp_test_l2i2",
@@ -445,7 +445,7 @@ log_to_txt1(suite) -> [];
log_to_txt1(Config) when is_list(Config) ->
p(log_to_txt1),
put(sname,l2t1),
- put(verbosity,trace),
+ put(verbosity, debug),
?DBG("log_to_txt1 -> start", []),
Name = "snmp_test_l2t1",
@@ -463,7 +463,7 @@ log_to_txt2(suite) -> [];
log_to_txt2(Config) when is_list(Config) ->
p(log_to_txt2),
put(sname,l2t2),
- put(verbosity,trace),
+ put(verbosity, debug),
?DBG("log_to_txt2 -> start", []),
Name = "snmp_test_l2t2",
@@ -593,7 +593,7 @@ log_to_txt3(Config) when is_list(Config) ->
process_flag(trap_exit, true),
p(log_to_txt3),
put(sname,l2t3),
- put(verbosity,trace),
+ put(verbosity, debug),
?DBG("log_to_txt3 -> start", []),
Dir = ?config(log_dir, Config),
Name = "snmp_test_l2t3",
diff --git a/lib/snmp/vsn.mk b/lib/snmp/vsn.mk
index 5d3c393bcc..8a4d9c14c0 100644
--- a/lib/snmp/vsn.mk
+++ b/lib/snmp/vsn.mk
@@ -18,6 +18,6 @@
# %CopyrightEnd%
APPLICATION = snmp
-SNMP_VSN = 4.22.2
+SNMP_VSN = 4.22.3
PRE_VSN =
APP_VSN = "$(APPLICATION)-$(SNMP_VSN)$(PRE_VSN)"