aboutsummaryrefslogtreecommitdiffstats
path: root/lib/snmp/src/agent
diff options
context:
space:
mode:
Diffstat (limited to 'lib/snmp/src/agent')
-rw-r--r--lib/snmp/src/agent/snmpa_mib_storage.erl16
-rw-r--r--lib/snmp/src/agent/snmpa_mib_storage_dets.erl27
-rw-r--r--lib/snmp/src/agent/snmpa_mib_storage_ets.erl28
-rw-r--r--lib/snmp/src/agent/snmpa_mib_storage_mnesia.erl10
4 files changed, 54 insertions, 27 deletions
diff --git a/lib/snmp/src/agent/snmpa_mib_storage.erl b/lib/snmp/src/agent/snmpa_mib_storage.erl
index bbb9516ecb..5c3f76d89b 100644
--- a/lib/snmp/src/agent/snmpa_mib_storage.erl
+++ b/lib/snmp/src/agent/snmpa_mib_storage.erl
@@ -22,9 +22,7 @@
-export_type([
mib_storage_fields/0,
mib_storage_table_type/0,
- mib_storage_table_id/0,
-
- void/0
+ mib_storage_table_id/0
]).
@@ -37,7 +35,6 @@
-type mib_storage_fields() :: [atom()].
-type mib_storage_table_type() :: set | bag.
-type mib_storage_table_id() :: term().
--type void() :: term().
%% ---------------------------------------------------------------
@@ -99,7 +96,7 @@
%% ---------------------------------------------------------------
-callback delete(TabId :: mib_storage_table_id()) ->
- void().
+ snmp:void().
%% ---------------------------------------------------------------
@@ -149,14 +146,17 @@
%% ---------------------------------------------------------------
-%% info
+%% info/1,2
%%
%% Retrieve implementation dependent mib-storage table
%% information.
%% ---------------------------------------------------------------
-callback info(TabId :: mib_storage_table_id()) ->
- {ok, Info :: term()} | {error, Reason :: term()}.
+ Info :: term().
+
+-callback info(TabId :: mib_storage_table_id(), Item :: atom()) ->
+ Info :: term().
%% ---------------------------------------------------------------
@@ -166,7 +166,7 @@
%% ---------------------------------------------------------------
-callback sync(TabId :: mib_storage_table_id()) ->
- ok.
+ snmp:void().
%% ---------------------------------------------------------------
diff --git a/lib/snmp/src/agent/snmpa_mib_storage_dets.erl b/lib/snmp/src/agent/snmpa_mib_storage_dets.erl
index 6062f4327e..e84e18e7ea 100644
--- a/lib/snmp/src/agent/snmpa_mib_storage_dets.erl
+++ b/lib/snmp/src/agent/snmpa_mib_storage_dets.erl
@@ -33,19 +33,19 @@
write/2,
delete/1,
delete/2,
- sync/1,
- backup/2,
match_object/2,
match_delete/2,
tab2list/1,
- info/1
+ info/1, info/2,
+ sync/1,
+ backup/2
]).
-define(VMODULE, "MS-DETS").
-include("snmp_verbosity.hrl").
--record(tab, {id}).
+-record(tab, {id, rec_name}).
%% ---------------------------------------------------------------
@@ -62,7 +62,7 @@
%%
%% ---------------------------------------------------------------
-open(Name, _RecName, _Fields, Type, Opts) ->
+open(Name, RecName, _Fields, Type, Opts) ->
Dir = snmp_misc:get_option(dir, Opts),
Action = snmp_misc:get_option(action, Opts, keep),
AutoSave = snmp_misc:get_option(auto_save, Opts, default),
@@ -80,10 +80,10 @@ open(Name, _RecName, _Fields, Type, Opts) ->
end,
case dets:open_file(Name, OpenOpts) of
{ok, ID} when (Action =:= keep) ->
- {ok, #tab{id = ID}};
+ {ok, #tab{id = ID, rec_name = RecName}};
{ok, ID} when (Action =:= clear) ->
dets:match_delete(ID, '_'),
- {ok, #tab{id = ID}};
+ {ok, #tab{id = ID, rec_name = RecName}};
{error, Reason} ->
{error, {dets_open, Reason}}
end.
@@ -128,7 +128,8 @@ read(#tab{id = ID}, Key) ->
%% Write a record to the database table.
%% ---------------------------------------------------------------
-write(#tab{id = ID}, Rec) ->
+write(#tab{id = ID, rec_name = RecName}, Rec)
+ when (is_tuple(Rec) andalso (element(1, Rec) =:= RecName)) ->
?vtrace("write to table ~p", [ID]),
dets:insert(ID, Rec).
@@ -209,6 +210,16 @@ info(#tab{id = ID}) ->
dets:info(ID).
+info(TabId, all = _Item) ->
+ info(TabId);
+info(#tab{id = ID}, memory = _Item) ->
+ ?vtrace("info on ~p (~w)", [ID, _Item]),
+ dets:info(ID, file_size);
+info(#tab{id = ID}, Item) ->
+ ?vtrace("info on ~p (~w)", [ID, Item]),
+ dets:info(ID, Item).
+
+
%% ---------------------------------------------------------------
%% sync
%%
diff --git a/lib/snmp/src/agent/snmpa_mib_storage_ets.erl b/lib/snmp/src/agent/snmpa_mib_storage_ets.erl
index fcf5e12043..4afdc76ee5 100644
--- a/lib/snmp/src/agent/snmpa_mib_storage_ets.erl
+++ b/lib/snmp/src/agent/snmpa_mib_storage_ets.erl
@@ -33,19 +33,19 @@
write/2,
delete/1,
delete/2,
- sync/1,
- backup/2,
match_object/2,
match_delete/2,
tab2list/1,
- info/1
+ info/1, info/2,
+ sync/1,
+ backup/2
]).
-define(VMODULE,"MS-ETS").
-include("snmp_verbosity.hrl").
--record(tab, {id, file, checksum = false}).
+-record(tab, {id, rec_name, file, checksum = false}).
%% ---------------------------------------------------------------
@@ -67,7 +67,7 @@
%% ---------------------------------------------------------------
%% This function creates the ets table
-open(Name, _RecName, _Fields, Type, Opts) ->
+open(Name, RecName, _Fields, Type, Opts) ->
?vtrace("open table ~p", [Name]),
case lists:keysearch(dir, 1, Opts) of
{value, {dir, Dir}} ->
@@ -80,6 +80,7 @@ open(Name, _RecName, _Fields, Type, Opts) ->
case ets:file2tab(File, [{verify, Checksum}]) of
{ok, ID} ->
{ok, #tab{id = ID,
+ rec_name = RecName,
file = File,
checksum = Checksum}};
{error, Reason} when (Action =:= keep) ->
@@ -92,6 +93,7 @@ open(Name, _RecName, _Fields, Type, Opts) ->
ID = ets:new(Name, [Type, protected, {keypos, 2}]),
write_ets_file(ID, File, Checksum),
{ok, #tab{id = ID,
+ rec_name = RecName,
file = File,
checksum = Checksum}}
end;
@@ -105,12 +107,13 @@ open(Name, _RecName, _Fields, Type, Opts) ->
ID = ets:new(Name, [Type, protected, {keypos, 2}]),
write_ets_file(ID, File, Checksum),
{ok, #tab{id = ID,
+ rec_name = RecName,
file = File,
checksum = Checksum}}
end;
false ->
ID = ets:new(Name, [Type, protected, {keypos, 2}]),
- {ok, #tab{id = ID}}
+ {ok, #tab{id = ID, rec_name = RecName}}
end.
@@ -150,7 +153,9 @@ read(#tab{id = ID}, Key) ->
%% Write a record to the mib-storage table.
%% ---------------------------------------------------------------
-write(#tab{id = ID}, Rec) ->
+%% This is a very crude guard test is used instead of: is_record(Rec, RecName)
+write(#tab{id = ID, rec_name = RecName}, Rec)
+ when (is_tuple(Rec) andalso (element(1, Rec) =:= RecName)) ->
?vtrace("write to table ~p", [ID]),
ets:insert(ID, Rec).
@@ -219,7 +224,7 @@ tab2list(#tab{id = ID}) ->
%% ---------------------------------------------------------------
-%% info
+%% info/1,2
%%
%% Retrieve implementation dependent mib-storage table
%% information.
@@ -234,6 +239,13 @@ info(#tab{id = ID}) ->
end.
+info(TabId, all = _Item) ->
+ info(TabId);
+info(#tab{id = ID}, Item) ->
+ ?vtrace("info on ~p", [ID]),
+ ets:info(ID, Item).
+
+
%% ---------------------------------------------------------------
%% sync
%%
diff --git a/lib/snmp/src/agent/snmpa_mib_storage_mnesia.erl b/lib/snmp/src/agent/snmpa_mib_storage_mnesia.erl
index aee2192b24..a1f2be9af3 100644
--- a/lib/snmp/src/agent/snmpa_mib_storage_mnesia.erl
+++ b/lib/snmp/src/agent/snmpa_mib_storage_mnesia.erl
@@ -33,12 +33,12 @@
write/2,
delete/1,
delete/2,
- sync/1,
- backup/2,
match_object/2,
match_delete/2,
tab2list/1,
- info/1
+ info/1, info/2,
+ sync/1,
+ backup/2
]).
@@ -239,6 +239,10 @@ info(#tab{id = ID}) ->
end.
+info(#tab{id = ID}, Item) ->
+ mnesia:table_info(ID, Item).
+
+
%% ---------------------------------------------------------------
%% sync
%%