4
%% Copyright Ericsson AB 2004-2009. All Rights Reserved.
4
%% Copyright Ericsson AB 2004-2010. All Rights Reserved.
6
6
%% The contents of this file are subject to the Erlang Public License,
7
7
%% Version 1.1, (the "License"); you may not use this file except in
8
8
%% compliance with the License. You should have received a copy of the
9
9
%% Erlang Public License along with this software. If not, it can be
10
10
%% retrieved online at http://www.erlang.org/.
12
12
%% Software distributed under the License is distributed on an "AS IS"
13
13
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14
14
%% the License for the specific language governing rights and limitations
15
15
%% under the License.
19
19
%% -------------------------------------------------------------------------
28
28
-behaviour(gen_server).
30
30
%% External exports
31
%% Avoid warning for local function error/1 clashing with autoimported BIF.
32
-compile({no_auto_import,[error/1]}).
31
33
-export([start_link/1, stop/0, is_started/0]).
32
34
-export([register_user/4, unregister_user/1,
798
%% <ATL Sequence Number>
799
increment_counter(Counter, Initial, Max) ->
801
increment_counter(Counter, Initial, Increment, Max).
803
increment_counter(Counter, Initial, Increment, Max) ->
804
%% This is to make sure no one else increments our counter
805
Key = {Counter, self()},
811
UpdateOp = {Position, Increment, Threshold, SetValue},
813
%% And now for the actual increment
814
Tab = snmpm_counter_table,
815
case (catch ets:update_counter(Tab, Key, UpdateOp)) of
816
{'EXIT', {badarg, _}} ->
818
ets:insert(Tab, {Key, Initial}),
820
Next when is_integer(Next) ->
823
%% </ATL Sequence Number>
795
826
maybe_cre_stats_counter(Counter, Initial) ->
796
827
case ets:lookup(snmpm_stats_table, Counter) of
1013
1044
AuditTrailLogOpts ->
1014
1045
?vtrace("ATL options: ~p", [AuditTrailLogOpts]),
1015
1046
ets:insert(snmpm_config_table, {audit_trail_log, true}),
1016
LogDir = get_atl_dir(AuditTrailLogOpts),
1017
LogType = get_atl_type(AuditTrailLogOpts),
1018
LogSize = get_atl_size(AuditTrailLogOpts),
1019
LogRep = get_atl_repair(AuditTrailLogOpts),
1047
LogDir = get_atl_dir(AuditTrailLogOpts),
1048
LogType = get_atl_type(AuditTrailLogOpts),
1049
LogSize = get_atl_size(AuditTrailLogOpts),
1050
LogRep = get_atl_repair(AuditTrailLogOpts),
1051
LogSeqNo = get_atl_seqno(AuditTrailLogOpts),
1020
1052
ets:insert(snmpm_config_table, {audit_trail_log_dir, LogDir}),
1021
1053
ets:insert(snmpm_config_table, {audit_trail_log_type, LogType}),
1022
1054
ets:insert(snmpm_config_table, {audit_trail_log_size, LogSize}),
1023
ets:insert(snmpm_config_table, {audit_trail_log_repair, LogRep})
1055
ets:insert(snmpm_config_table, {audit_trail_log_repair, LogRep}),
1056
ets:insert(snmpm_config_table, {audit_trail_log_seqno, LogSeqNo})
1026
1059
%% -- System default agent config --
1398
1431
verify_audit_trail_log_opts([{repair, Repair}|Opts]) ->
1399
1432
verify_log_repair(Repair),
1400
1433
verify_audit_trail_log_opts(Opts);
1434
verify_audit_trail_log_opts([{seqno, SeqNo}|Opts]) ->
1435
verify_log_seqno(SeqNo),
1436
verify_audit_trail_log_opts(Opts);
1401
1437
verify_audit_trail_log_opts([Opt|_Opts]) ->
1402
1438
error({invalid_audit_trail_log_option, Opt}).
1440
1476
verify_log_repair(Repair) ->
1441
1477
error({invalid_audit_trail_log_repair, Repair}).
1479
verify_log_seqno(true) -> ok;
1480
verify_log_seqno(false) -> ok;
1481
verify_log_seqno(SeqNo) ->
1482
error({invalid_audit_trail_log_seqno, SeqNo}).
1444
1485
verify_module(_, Mod) when is_atom(Mod) ->
3040
3082
get_atl_repair(Opts) ->
3041
3083
get_opt(repair, Opts, truncate).
3085
get_atl_seqno(Opts) ->
3086
get_opt(seqno, Opts, false).
3044
3089
%%----------------------------------------------------------------------