From 4b89567941ac6c00a994bde917e2d0d450dce91f Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Thu, 14 Nov 2013 17:53:11 +0100 Subject: [snmp] Loosing log entries when converting a large Audit Trail Log When converting an entire Audit Trail Log in a running system its possble to have log wraps and thereby loosing log entries. In order to prevent this the log is now blocked during conversion (log_to_txt or log_to_io). --- lib/snmp/doc/src/notes.xml | 61 ++++++++++++++++++++++++++++++++++++ lib/snmp/src/app/snmp.appup.src | 54 +++++++++++++++++++++---------- lib/snmp/src/misc/snmp_log.erl | 32 +++++++++++++++++-- lib/snmp/src/misc/snmp_verbosity.erl | 4 ++- lib/snmp/vsn.mk | 2 +- 5 files changed, 131 insertions(+), 22 deletions(-) diff --git a/lib/snmp/doc/src/notes.xml b/lib/snmp/doc/src/notes.xml index 8d280fb3a1..668e986486 100644 --- a/lib/snmp/doc/src/notes.xml +++ b/lib/snmp/doc/src/notes.xml @@ -33,6 +33,67 @@ +
+ SNMP Development Toolkit 4.22.3 +

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.

+ +
+ Improvements and new features +

-

+ + + +
+ +
+ Fixed Bugs and Malfunctions + + + + +

Loosing log entries when converting a large Audit Trail Log.

+

When converting an entire Audit Trail Log in a running + system its possble to have log wraps and thereby loosing log + entries.

+

In order to prevent this the log is now blocked + during conversion (log_to_txt or log_to_io).

+

Own Id: OTP-11396

+

Own Id: seq12433

+
+
+ +
+ +
+ Incompatibilities +

-

+
+ +
+ +
SNMP Development Toolkit 4.22.2

Version 4.22.2 supports code replacement in runtime from/to diff --git a/lib/snmp/src/app/snmp.appup.src b/lib/snmp/src/app/snmp.appup.src index 39e154d463..69237838ab 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..9c6cb1e077 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 @@ -443,9 +443,12 @@ do_log_convert(Log, File, Converter) -> %% "~n Log: ~p" %% "~n File: ~p" %% "~n disk_log:info(Log): ~p", [Log, File, disk_log:info(Log)]), + Verbosity = get(verbosity), {Pid, Ref} = erlang:spawn_monitor( fun() -> + put(sname, lc), + put(verbosity, Verbosity), Result = do_log_convert2(Log, File, Converter), exit(Result) end), @@ -462,19 +465,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. @@ -491,6 +510,8 @@ do_log_to_file(Log, TextFile, Mibs, Start, Stop) -> {ok, S} -> io:format(Fd, "~s", [S]); _ -> + ?vdebug("do_log_to_txt:fun -> " + "format failed", []), ok end end, @@ -499,6 +520,9 @@ do_log_to_file(Log, TextFile, Mibs, Start, Stop) -> file:close(Fd), Res; {error, Reason} -> + ?vinfo("Failed opening output file: " + "~n TestFile: ~p" + "~n Reason: ~p", [TextFile, Reason]), {error, {TextFile, Reason}} end. @@ -510,6 +534,8 @@ do_log_to_io(Log, Mibs, Start, Stop) -> {ok, S} -> io:format("~s", [S]); _ -> + ?vdebug("do_log_to_io:fun -> " + "format failed", []), ok end end, diff --git a/lib/snmp/src/misc/snmp_verbosity.erl b/lib/snmp/src/misc/snmp_verbosity.erl index df5986b7bc..e5ff3daf91 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,6 +148,8 @@ 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"; 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)" -- cgit v1.2.3