From 0c86f27f70a46e2c28bd70ac8d4406fb8ceaf5dd Mon Sep 17 00:00:00 2001
From: Micael Karlberg
Date: Mon, 6 Dec 2010 14:27:25 +0100
Subject: Added print operations for tables vacmSecurityToGroupTable and
vacmViewTreeFamilyTable. There is still vacmAccessTable and vacmContextTable.
---
lib/snmp/src/agent/snmp_target_mib.erl | 9 +--
lib/snmp/src/agent/snmp_view_based_acm_mib.erl | 86 ++++++++++++++++++++++++++
lib/snmp/vsn.mk | 2 +-
3 files changed, 90 insertions(+), 7 deletions(-)
(limited to 'lib')
diff --git a/lib/snmp/src/agent/snmp_target_mib.erl b/lib/snmp/src/agent/snmp_target_mib.erl
index 3c32d1f59f..033dfdd92e 100644
--- a/lib/snmp/src/agent/snmp_target_mib.erl
+++ b/lib/snmp/src/agent/snmp_target_mib.erl
@@ -591,12 +591,9 @@ snmpTargetAddrTable(print) ->
?'snmpTargetAddrRowStatus_active' -> active;
_ -> undefined
end,
- Prefix,
- element(?snmpTargetAddrEngineId, Row),
- Prefix,
- element(?snmpTargetAddrTMask, Row),
- Prefix,
- element(?snmpTargetAddrMMS, Row)]))
+ Prefix, element(?snmpTargetAddrEngineId, Row),
+ Prefix, element(?snmpTargetAddrTMask, Row),
+ Prefix, element(?snmpTargetAddrMMS, Row)]))
end,
snmpa_mib_lib:print_table(Table, DB, FOI, PrintRow);
%% Op == new | delete
diff --git a/lib/snmp/src/agent/snmp_view_based_acm_mib.erl b/lib/snmp/src/agent/snmp_view_based_acm_mib.erl
index 657207b36e..9aff0f9810 100644
--- a/lib/snmp/src/agent/snmp_view_based_acm_mib.erl
+++ b/lib/snmp/src/agent/snmp_view_based_acm_mib.erl
@@ -348,6 +348,49 @@ vacmContextTable(Op, Arg1, Arg2) ->
snmp_framework_mib:intContextTable(Op, Arg1, Arg2).
+vacmSecurityToGroupTable(print) ->
+ Table = vacmSecurityToGroupTable,
+ DB = db(Table),
+ FOI = foi(Table),
+ PrintRow =
+ fun(Prefix, Row) ->
+ lists:flatten(
+ io_lib:format("~sSecurityModel: ~p (~w)"
+ "~sSecurityName: ~p"
+ "~sGroupName: ~p"
+ "~sStorageType: ~p (~w)"
+ "~sStatus: ~p (~w)",
+ [Prefix, element(?vacmSecurityModel, Row),
+ case element(?vacmSecurityModel, Row) of
+ ?SEC_ANY -> any;
+ ?SEC_V1 -> v1;
+ ?SEC_V2C -> v2c;
+ ?SEC_USM -> usm;
+ _ -> undefined
+ end,
+ Prefix, element(?vacmSecurityName, Row),
+ Prefix, element(?vacmGroupName, Row),
+ Prefix, element(?vacmSecurityToGroupStorageType, Row),
+ case element(?vacmSecurityToGroupStorageType, Row) of
+ ?'vacmSecurityToGroupStorageType_readOnly' -> readOnly;
+ ?'vacmSecurityToGroupStorageType_permanent' -> permanent;
+ ?'vacmSecurityToGroupStorageType_nonVolatile' -> nonVolatile;
+ ?'vacmSecurityToGroupStorageType_volatile' -> volatile;
+ ?'vacmSecurityToGroupStorageType_other' -> other;
+ _ -> undefined
+ end,
+ Prefix, element(?vacmSecurityToGroupStatus, Row),
+ case element(?vacmSecurityToGroupStatus, Row) of
+ ?'vacmSecurityToGroupStatus_destroy' -> destroy;
+ ?'vacmSecurityToGroupStatus_createAndWait' -> createAndWait;
+ ?'vacmSecurityToGroupStatus_createAndGo' -> createAndGo;
+ ?'vacmSecurityToGroupStatus_notReady' -> notReady;
+ ?'vacmSecurityToGroupStatus_notInService' -> notInService;
+ ?'vacmSecurityToGroupStatus_active' -> active;
+ _ -> undefined
+ end]))
+ end,
+ snmpa_mib_lib:print_table(Table, DB, FOI, PrintRow);
vacmSecurityToGroupTable(Op) ->
snmp_generic:table_func(Op, db(vacmSecurityToGroupTable)).
@@ -719,6 +762,49 @@ vacmViewSpinLock(set, NewVal) ->
{vacmViewSpinLock, volatile}).
+vacmViewTreeFamilyTable(print) ->
+ Table = vacmViewTreeFamilyTable,
+ DB = db(Table),
+ FOI = foi(Table),
+ PrintRow =
+ fun(Prefix, Row) ->
+ lists:flatten(
+ io_lib:format("~sViewName: ~p"
+ "~sSubtree: ~p"
+ "~sMask: ~p"
+ "~sType: ~p (~w)"
+ "~sStorageType: ~p (~w)"
+ "~sStatus: ~p (~w)",
+ [Prefix, element(?vacmViewTreeFamilyViewName, Row),
+ Prefix, element(?vacmViewTreeFamilySubtree, Row),
+ Prefix, element(?vacmViewTreeFamilyMask, Row),
+ Prefix, element(?vacmViewTreeFamilyType, Row),
+ case element(?vacmViewTreeFamilyType, Row) of
+ ?vacmViewTreeFamilyType_included -> included;
+ ?vacmViewTreeFamilyType_excluded -> excluded;
+ _ -> undefined
+ end,
+ Prefix, element(?vacmViewTreeFamilyStorageType, Row),
+ case element(?vacmViewTreeFamilyStorageType, Row) of
+ ?vacmViewTreeFamilyStorageType_readOnly -> readOnly;
+ ?vacmViewTreeFamilyStorageType_permanent -> permanent;
+ ?vacmViewTreeFamilyStorageType_nonVolatile -> nonVolatile;
+ ?vacmViewTreeFamilyStorageType_volatile -> volatile;
+ ?vacmViewTreeFamilyStorageType_other -> other;
+ _ -> undefined
+ end,
+ Prefix, element(?vacmViewTreeFamilyStatus, Row),
+ case element(?vacmViewTreeFamilyStatus, Row) of
+ ?vacmViewTreeFamilyStatus_destroy -> destroy;
+ ?vacmViewTreeFamilyStatus_createAndWait -> createAndWait;
+ ?vacmViewTreeFamilyStatus_createAndGo -> createAndGo;
+ ?vacmViewTreeFamilyStatus_notReady -> notReady;
+ ?vacmViewTreeFamilyStatus_notInService -> notInService;
+ ?vacmViewTreeFamilyStatus_active -> active;
+ _ -> undefined
+ end]))
+ end,
+ snmpa_mib_lib:print_table(Table, DB, FOI, PrintRow);
vacmViewTreeFamilyTable(Op) ->
snmp_generic:table_func(Op, db(vacmViewTreeFamilyTable)).
vacmViewTreeFamilyTable(get_next, RowIndex, Cols) ->
diff --git a/lib/snmp/vsn.mk b/lib/snmp/vsn.mk
index 1229b12ae2..ac9a192f5d 100644
--- a/lib/snmp/vsn.mk
+++ b/lib/snmp/vsn.mk
@@ -1,3 +1,3 @@
-SNMP_VSN = 4.18
+SNMP_VSN = 4.19
PRE_VSN =
APP_VSN = "snmp-$(SNMP_VSN)$(PRE_VSN)"
--
cgit v1.2.3
From e8d677e46c6bafd290d189e4b0385c21092e4e91 Mon Sep 17 00:00:00 2001
From: Micael Karlberg
Date: Mon, 6 Dec 2010 18:20:03 +0100
Subject: Added print operation for vacmAccessTable.
---
lib/snmp/src/agent/snmp_view_based_acm_mib.erl | 95 ++++++++++++++++++++------
1 file changed, 75 insertions(+), 20 deletions(-)
(limited to 'lib')
diff --git a/lib/snmp/src/agent/snmp_view_based_acm_mib.erl b/lib/snmp/src/agent/snmp_view_based_acm_mib.erl
index 9aff0f9810..f91262ab57 100644
--- a/lib/snmp/src/agent/snmp_view_based_acm_mib.erl
+++ b/lib/snmp/src/agent/snmp_view_based_acm_mib.erl
@@ -133,7 +133,6 @@ check_vacm({vacmSecurityToGroup, SecModel, SecName, GroupName}) ->
{ok, SecM} = snmp_conf:check_sec_model(SecModel, []),
snmp_conf:check_string(SecName),
snmp_conf:check_string(GroupName),
-
Vacm = {SecM, SecName, GroupName,
?'StorageType_nonVolatile', ?'RowStatus_active'},
{ok, {vacmSecurityToGroup, Vacm}};
@@ -188,8 +187,8 @@ init_tabs(Sec2Group, Access, View) ->
init_view_table(View).
init_sec2group_table([Row | T]) ->
-% ?vtrace("init security-to-group table: "
-% "~n Row: ~p",[Row]),
+%% ?vtrace("init security-to-group table: "
+%% "~n Row: ~p",[Row]),
Key1 = element(1, Row),
Key2 = element(2, Row),
Key = [Key1, length(Key2) | Key2],
@@ -198,12 +197,12 @@ init_sec2group_table([Row | T]) ->
init_sec2group_table([]) -> true.
init_access_table([{GN, Prefix, Model, Level, Row} | T]) ->
-% ?vtrace("init access table: "
-% "~n GN: ~p"
-% "~n Prefix: ~p"
-% "~n Model: ~p"
-% "~n Level: ~p"
-% "~n Row: ~p",[GN, Prefix, Model, Level, Row]),
+%% ?vtrace("init access table: "
+%% "~n GN: ~p"
+%% "~n Prefix: ~p"
+%% "~n Model: ~p"
+%% "~n Level: ~p"
+%% "~n Row: ~p",[GN, Prefix, Model, Level, Row]),
Key = [length(GN) | GN] ++ [length(Prefix) | Prefix] ++ [Model, Level],
snmpa_vacm:insert([{Key, Row}], false),
init_access_table(T);
@@ -211,8 +210,8 @@ init_access_table([]) ->
snmpa_vacm:dump_table().
init_view_table([Row | T]) ->
-% ?vtrace("init view table: "
-% "~n Row: ~p",[Row]),
+%% ?vtrace("init view table: "
+%% "~n Row: ~p",[Row]),
Key1 = element(1, Row),
Key2 = element(2, Row),
Key = [length(Key1) | Key1] ++ [length(Key2) | Key2],
@@ -356,10 +355,10 @@ vacmSecurityToGroupTable(print) ->
fun(Prefix, Row) ->
lists:flatten(
io_lib:format("~sSecurityModel: ~p (~w)"
- "~sSecurityName: ~p"
- "~sGroupName: ~p"
- "~sStorageType: ~p (~w)"
- "~sStatus: ~p (~w)",
+ "~n~sSecurityName: ~p"
+ "~n~sGroupName: ~p"
+ "~n~sStorageType: ~p (~w)"
+ "~n~sStatus: ~p (~w)",
[Prefix, element(?vacmSecurityModel, Row),
case element(?vacmSecurityModel, Row) of
?SEC_ANY -> any;
@@ -488,6 +487,49 @@ verify_vacmSecurityToGroupTable_col(_, Val) ->
%% {RowIndex, {Col4, Col5, ..., Col9}}
%%
%%-----------------------------------------------------------------
+vacmAccessTable(print) ->
+ %% Måste jag göra om alla entrien till {RowIdx, Row}?
+ TableInfo = get_table(vacmAccessTable),
+ PrintRow =
+ fun(Prefix, Row) ->
+ lists:flatten(
+ io_lib:format("~sContextMatch: ~p (~w)"
+ "~n~sReadViewName: ~p"
+ "~n~sWriteViewName: ~p"
+ "~n~sNotifyViewName: ~p"
+ "~n~sStorageType: ~p (~w)"
+ "~n~sStatus: ~p (~w)",
+ [Prefix, element(?vacmAccessContextMatch-3, Row),
+ case element(?vacmAccessContextMatch-3, Row) of
+ ?vacmAccessContextMatch_exact -> exact;
+ ?vacmAccessContextMatch_prefix -> prefix;
+ _ -> undefined
+ end,
+ Prefix, element(?vacmAccessReadViewName-3, Row),
+ Prefix, element(?vacmAccessWriteViewName-3, Row),
+ Prefix, element(?vacmAccessNotifyViewName-3, Row),
+ Prefix, element(?vacmAccessStorageType-3, Row),
+ case element(?vacmAccessStorageType-3, Row) of
+ ?vacmAccessStorageType_other -> other ;
+ ?vacmAccessStorageType_volatile -> volatile;
+ ?vacmAccessStorageType_nonVolatile -> nonVolatile;
+ ?vacmAccessStorageType_permanent -> permanent;
+ ?vacmAccessStorageType_readOnly -> readOnly;
+ _ -> undefined
+ end,
+ Prefix, element(?vacmAccessStatus-3, Row),
+ case element(?vacmAccessStatus-3, Row) of
+ ?vacmAccessStatus_destroy -> destroy;
+ ?vacmAccessStatus_createAndWait -> createAndWait;
+ ?vacmAccessStatus_createAndGo -> createAndGo;
+ ?vacmAccessStatus_notReady -> notReady;
+ ?vacmAccessStatus_notInService -> notInService;
+ ?vacmAccessStatus_active -> active;
+ _ -> undefined
+ end
+ ]))
+ end,
+ snmpa_mib_lib:print_table(vacmAccessTable, {ok, TableInfo}, PrintRow);
vacmAccessTable(_Op) ->
ok.
vacmAccessTable(get, RowIndex, Cols) ->
@@ -770,11 +812,11 @@ vacmViewTreeFamilyTable(print) ->
fun(Prefix, Row) ->
lists:flatten(
io_lib:format("~sViewName: ~p"
- "~sSubtree: ~p"
- "~sMask: ~p"
- "~sType: ~p (~w)"
- "~sStorageType: ~p (~w)"
- "~sStatus: ~p (~w)",
+ "~n~sSubtree: ~p"
+ "~n~sMask: ~p"
+ "~n~sType: ~p (~w)"
+ "~n~sStorageType: ~p (~w)"
+ "~n~sStatus: ~p (~w)",
[Prefix, element(?vacmViewTreeFamilyViewName, Row),
Prefix, element(?vacmViewTreeFamilySubtree, Row),
Prefix, element(?vacmViewTreeFamilyMask, Row),
@@ -881,6 +923,19 @@ table_next(Name, RestOid) ->
snmp_generic:table_next(db(Name), RestOid).
+get_table(vacmAccessTable) ->
+ do_get_vacmAccessTable([], []).
+
+do_get_vacmAccessTable(Key0, Acc) ->
+ case snmpa_vacm:get_next_row(Key0) of
+ {Key, _Row} = Entry ->
+ do_get_vacmAccessTable(Key, [Entry | Acc]);
+ false ->
+ lists:reverse(Acc)
+ end.
+
+
+
db(X) -> snmpa_agent:db(X).
fa(vacmSecurityToGroupTable) -> ?vacmGroupName;
--
cgit v1.2.3
From 52140da6cf766ce65a12e6de529f5eafdde0b91a Mon Sep 17 00:00:00 2001
From: Micael Karlberg
Date: Mon, 6 Dec 2010 18:30:40 +0100
Subject: Added central utility function for printing all "supported" tables
(that is for all functions that we currently have implemented the print
operation).
---
lib/snmp/src/agent/snmpa.erl | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
(limited to 'lib')
diff --git a/lib/snmp/src/agent/snmpa.erl b/lib/snmp/src/agent/snmpa.erl
index 87b191caed..ce208d870b 100644
--- a/lib/snmp/src/agent/snmpa.erl
+++ b/lib/snmp/src/agent/snmpa.erl
@@ -105,6 +105,8 @@
set_request_limit/1, set_request_limit/2
]).
+-export([print_tables/0, print_tables/1]).
+
-include("snmpa_atl.hrl").
-define(EXTRA_INFO, undefined).
@@ -281,6 +283,26 @@ whereis_mib(Agent, Mib) when is_atom(Mib) ->
snmpa_agent:whereis_mib(Agent, Mib).
+%% -
+
+print_tables() ->
+ Tables = [
+ {snmp_view_based_acm_mib, [vacmAccessTable,
+ vacmSecurityToGroupTable,
+ vacmViewTreeFamilyTable]},
+ {snmp_target_mib, [snmpTargetAddrTable, snmpTargetParamsTable]}
+ ],
+ print_tables(Tables).
+
+print_tables([]) ->
+ ok;
+print_tables([{Mod, Tables}|MibTables]) ->
+ [(catch Mod:Table(print)) || Table <- Tables],
+ print_tables(MibTables);
+print_tables([_|MibTables]) ->
+ print_tables(MibTables).
+
+
%% -
mib_of(Oid) ->
--
cgit v1.2.3
From 9401854175279040d3138b474226ceb4596f4aab Mon Sep 17 00:00:00 2001
From: Micael Karlberg
Date: Mon, 6 Dec 2010 18:38:10 +0100
Subject: Segmenting the printout using the mib names.
---
lib/snmp/src/agent/snmpa.erl | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
(limited to 'lib')
diff --git a/lib/snmp/src/agent/snmpa.erl b/lib/snmp/src/agent/snmpa.erl
index ce208d870b..ca6c02aabc 100644
--- a/lib/snmp/src/agent/snmpa.erl
+++ b/lib/snmp/src/agent/snmpa.erl
@@ -296,12 +296,24 @@ print_tables() ->
print_tables([]) ->
ok;
-print_tables([{Mod, Tables}|MibTables]) ->
- [(catch Mod:Table(print)) || Table <- Tables],
+print_tables([{Mod, Tables}|MibTables]) when is_atom(Mod) andalso is_list(Tables) ->
+ print_tables(Mod, Tables),
print_tables(MibTables);
print_tables([_|MibTables]) ->
print_tables(MibTables).
+print_tables(Mod, Tables) ->
+ io:format("~n** ~s ** ~n~n", [make_pretty_mib(Mod)]),
+ [(catch Mod:Table(print)) || Table <- Tables].
+
+
+make_pretty_mib(snmp_view_based_acm_mib) ->
+ "SNMP-VIEW-BASED-ACM-MIB";
+make_pretty_mib(snmp_target_mib) ->
+ "SNMP-TARGET-MIB";
+make_pretty_mib(Mod) ->
+ atom_to_list(Mod).
+
%% -
--
cgit v1.2.3
From ac4fd818bec3b79ce28e1bda3d79925dbf438914 Mon Sep 17 00:00:00 2001
From: Micael Karlberg
Date: Mon, 6 Dec 2010 20:54:44 +0100
Subject: Added tables from community, notification and user-based-sm mib(s).
---
lib/snmp/src/agent/snmpa.erl | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
(limited to 'lib')
diff --git a/lib/snmp/src/agent/snmpa.erl b/lib/snmp/src/agent/snmpa.erl
index ca6c02aabc..f10f425e6a 100644
--- a/lib/snmp/src/agent/snmpa.erl
+++ b/lib/snmp/src/agent/snmpa.erl
@@ -290,7 +290,10 @@ print_tables() ->
{snmp_view_based_acm_mib, [vacmAccessTable,
vacmSecurityToGroupTable,
vacmViewTreeFamilyTable]},
- {snmp_target_mib, [snmpTargetAddrTable, snmpTargetParamsTable]}
+ {snmp_target_mib, [snmpTargetAddrTable, snmpTargetParamsTable]},
+ {snmp_community_mib, [snmpCommunityTable]},
+ {snmp_notification_mib, [snmpNotifyTable]},
+ {snmp_user_based_sm_mib, [usmUserTable]}
],
print_tables(Tables).
--
cgit v1.2.3
From 339e1f1a3189a5a16dd1ba8c2a7137ff671f839b Mon Sep 17 00:00:00 2001
From: Micael Karlberg
Date: Mon, 6 Dec 2010 21:19:08 +0100
Subject: Added pretty printing of the added mib(s).
---
lib/snmp/src/agent/snmpa.erl | 6 ++++++
1 file changed, 6 insertions(+)
(limited to 'lib')
diff --git a/lib/snmp/src/agent/snmpa.erl b/lib/snmp/src/agent/snmpa.erl
index f10f425e6a..f109741759 100644
--- a/lib/snmp/src/agent/snmpa.erl
+++ b/lib/snmp/src/agent/snmpa.erl
@@ -314,6 +314,12 @@ make_pretty_mib(snmp_view_based_acm_mib) ->
"SNMP-VIEW-BASED-ACM-MIB";
make_pretty_mib(snmp_target_mib) ->
"SNMP-TARGET-MIB";
+make_pretty_mib(snmp_target_mib) ->
+ "SNMP-COMMUNITY-MIB";
+make_pretty_mib(snmp_target_mib) ->
+ "SNMP-NOTIFICATION-MIB";
+make_pretty_mib(snmp_target_mib) ->
+ "SNMP-USER-BASED-SM-MIB";
make_pretty_mib(Mod) ->
atom_to_list(Mod).
--
cgit v1.2.3
From e67b8b37c5aabe83f8872fcf71e865591af5552b Mon Sep 17 00:00:00 2001
From: Micael Karlberg
Date: Wed, 8 Dec 2010 16:05:42 +0100
Subject: Added preliminary veariable support.
---
lib/snmp/src/agent/snmp_view_based_acm_mib.erl | 6 ++
lib/snmp/src/agent/snmpa.erl | 103 ++++++++++++++++++++-----
2 files changed, 89 insertions(+), 20 deletions(-)
(limited to 'lib')
diff --git a/lib/snmp/src/agent/snmp_view_based_acm_mib.erl b/lib/snmp/src/agent/snmp_view_based_acm_mib.erl
index f91262ab57..f98b799631 100644
--- a/lib/snmp/src/agent/snmp_view_based_acm_mib.erl
+++ b/lib/snmp/src/agent/snmp_view_based_acm_mib.erl
@@ -781,6 +781,12 @@ split_cols([Col | Cols], PreCols) when Col =< 3 ->
split_cols(Cols, PreCols) ->
{PreCols, Cols}.
+vacmViewSpinLock(print) ->
+ case vacmViewSpinLock(get) of
+ {value, Val} -> io:format("vacmViewSpinLock => ~p~n", [Val]);
+ Error -> io:format("vacmViewSpinLock => ERROR: ~p~n", [Error])
+ end;
+
vacmViewSpinLock(new) ->
snmp_generic:variable_func(new, {vacmViewSpinLock, volatile}),
{A1,A2,A3} = erlang:now(),
diff --git a/lib/snmp/src/agent/snmpa.erl b/lib/snmp/src/agent/snmpa.erl
index f109741759..88417b19fe 100644
--- a/lib/snmp/src/agent/snmpa.erl
+++ b/lib/snmp/src/agent/snmpa.erl
@@ -105,7 +105,7 @@
set_request_limit/1, set_request_limit/2
]).
--export([print_tables/0, print_tables/1]).
+-export([print_mib_info/0, print_mib_tables/0, print_mib_variables/0]).
-include("snmpa_atl.hrl").
@@ -285,31 +285,94 @@ whereis_mib(Agent, Mib) when is_atom(Mib) ->
%% -
-print_tables() ->
- Tables = [
- {snmp_view_based_acm_mib, [vacmAccessTable,
- vacmSecurityToGroupTable,
- vacmViewTreeFamilyTable]},
- {snmp_target_mib, [snmpTargetAddrTable, snmpTargetParamsTable]},
- {snmp_community_mib, [snmpCommunityTable]},
- {snmp_notification_mib, [snmpNotifyTable]},
- {snmp_user_based_sm_mib, [usmUserTable]}
- ],
- print_tables(Tables).
-
-print_tables([]) ->
- ok;
-print_tables([{Mod, Tables}|MibTables]) when is_atom(Mod) andalso is_list(Tables) ->
+mibs_info() ->
+ [
+ {snmp_view_based_acm_mib,
+ [
+ vacmAccessTable,
+ vacmSecurityToGroupTable,
+ vacmViewTreeFamilyTable
+ ],
+ [
+ vacmViewSpinLock
+ ]},
+ {snmp_target_mib,
+ [
+ snmpTargetAddrTable,
+ snmpTargetParamsTable
+ ],
+ [
+ snmpTargetSpinLock
+ ]},
+ {snmp_community_mib,
+ [
+ snmpCommunityTable
+ ],
+ []},
+ {snmp_notification_mib,
+ [
+ snmpNotifyTable
+ ],
+ []},
+ {snmp_user_based_sm_mib,
+ [
+ usmUserTable
+ ],
+ [
+ usmUserSpinLock
+ ]}].
+
+print_mib_info() ->
+ MibsInfo = mibs_info(),
+ print_mib_info(MibsInfo).
+
+print_mib_info([{Mod, Tables, Variables} | MibsInfo]) ->
+ io:format("~n** ~s ** ~n~n", [make_pretty_mib(Mod)]),
+ print_variables(Mod, Variables),
print_tables(Mod, Tables),
- print_tables(MibTables);
-print_tables([_|MibTables]) ->
- print_tables(MibTables).
+ print_mib_info(MibsInfo).
-print_tables(Mod, Tables) ->
+
+print_mib_tables() ->
+ Tables = [{Mod, Tabs} || {Mod, Tabs, _Vars} <- mibs_info()],
+ print_mib_tables(Tables).
+
+print_mib_tables([]) ->
+ ok;
+print_mib_tables([{Mod, Tabs}|MibTabs]) when is_atom(Mod) andalso is_list(Tabs) ->
+ print_mib_tables(Mod, Tabs),
+ print_mib_tables(MibTabs);
+print_mib_tables([_|MibTabs]) ->
+ print_mib_tables(MibTabs).
+
+print_mib_tables(Mod, Tables) ->
io:format("~n** ~s ** ~n~n", [make_pretty_mib(Mod)]),
+ print_tables(Mod, Tables).
+
+print_tables(Mod, Tables) ->
[(catch Mod:Table(print)) || Table <- Tables].
+print_mib_variables() ->
+ Variables = [{Mod, Vars} || {Mod, _Tabs, Vars} <- mibs_info()],
+ print_mib_variables(Variables).
+
+print_mib_variables([]) ->
+ ok;
+print_mib_variables([{Mod, Vars}|MibVars]) when is_atom(Mod) andalso is_list(Vars) ->
+ print_mib_variables(Mod, Vars),
+ print_mib_variables(MibVars);
+print_mib_variables([_|MibVars]) ->
+ print_mib_variables(MibVars).
+
+print_mib_variables(Mod, Vars) ->
+ io:format("~n** ~s ** ~n~n", [make_pretty_mib(Mod)]),
+ print_variables(Mod, Vars).
+
+print_variables(Mod, Variables) ->
+ [(catch Mod:Variable(print)) || Variable <- Variables].
+
+
make_pretty_mib(snmp_view_based_acm_mib) ->
"SNMP-VIEW-BASED-ACM-MIB";
make_pretty_mib(snmp_target_mib) ->
--
cgit v1.2.3
From 9a5ba00578bd2b2d04d8814f8a228ff7bed1c18f Mon Sep 17 00:00:00 2001
From: Micael Karlberg
Date: Wed, 8 Dec 2010 18:42:41 +0100
Subject: Added utility variable print function, and utilized it in view-mib.
---
lib/snmp/src/agent/snmp_view_based_acm_mib.erl | 20 ++++++------
lib/snmp/src/agent/snmpa.erl | 18 ++++++-----
lib/snmp/src/agent/snmpa_mib_lib.erl | 44 +++++++++++++++++++++++++-
3 files changed, 63 insertions(+), 19 deletions(-)
(limited to 'lib')
diff --git a/lib/snmp/src/agent/snmp_view_based_acm_mib.erl b/lib/snmp/src/agent/snmp_view_based_acm_mib.erl
index f98b799631..659babaf94 100644
--- a/lib/snmp/src/agent/snmp_view_based_acm_mib.erl
+++ b/lib/snmp/src/agent/snmp_view_based_acm_mib.erl
@@ -782,32 +782,30 @@ split_cols(Cols, PreCols) ->
{PreCols, Cols}.
vacmViewSpinLock(print) ->
- case vacmViewSpinLock(get) of
- {value, Val} -> io:format("vacmViewSpinLock => ~p~n", [Val]);
- Error -> io:format("vacmViewSpinLock => ERROR: ~p~n", [Error])
- end;
+ VarAndValue = [{vacmViewSpinLock, vacmViewSpinLock(get)}],
+ snmpa_mib_lib:print_variables(VarAndValue);
vacmViewSpinLock(new) ->
- snmp_generic:variable_func(new, {vacmViewSpinLock, volatile}),
+ snmp_generic:variable_func(new, volatile_db(vacmViewSpinLock)),
{A1,A2,A3} = erlang:now(),
random:seed(A1,A2,A3),
Val = random:uniform(2147483648) - 1,
- snmp_generic:variable_func(set, Val, {vacmViewSpinLock, volatile});
+ snmp_generic:variable_func(set, Val, volatile_db(vacmViewSpinLock));
vacmViewSpinLock(delete) ->
ok;
vacmViewSpinLock(get) ->
- snmp_generic:variable_func(get, {vacmViewSpinLock, volatile}).
+ snmp_generic:variable_func(get, volatile_db(vacmViewSpinLock)).
vacmViewSpinLock(is_set_ok, NewVal) ->
- case snmp_generic:variable_func(get, {vacmViewSpinLock, volatile}) of
+ case snmp_generic:variable_func(get, volatile_db(vacmViewSpinLock)) of
{value, NewVal} -> noError;
_ -> inconsistentValue
end;
vacmViewSpinLock(set, NewVal) ->
snmp_generic:variable_func(set, (NewVal + 1) rem 2147483648,
- {vacmViewSpinLock, volatile}).
+ volatile_db(vacmViewSpinLock)).
vacmViewTreeFamilyTable(print) ->
@@ -942,7 +940,9 @@ do_get_vacmAccessTable(Key0, Acc) ->
-db(X) -> snmpa_agent:db(X).
+db(X) -> snmpa_agent:db(X).
+volatile_db(X) -> {X, volatile}.
+
fa(vacmSecurityToGroupTable) -> ?vacmGroupName;
fa(vacmViewTreeFamilyTable) -> ?vacmViewTreeFamilyMask.
diff --git a/lib/snmp/src/agent/snmpa.erl b/lib/snmp/src/agent/snmpa.erl
index 88417b19fe..8ad2a83de4 100644
--- a/lib/snmp/src/agent/snmpa.erl
+++ b/lib/snmp/src/agent/snmpa.erl
@@ -328,8 +328,8 @@ print_mib_info() ->
print_mib_info([{Mod, Tables, Variables} | MibsInfo]) ->
io:format("~n** ~s ** ~n~n", [make_pretty_mib(Mod)]),
- print_variables(Mod, Variables),
- print_tables(Mod, Tables),
+ print_mib_variables2(Mod, Variables),
+ print_mib_tables2(Mod, Tables),
print_mib_info(MibsInfo).
@@ -339,7 +339,8 @@ print_mib_tables() ->
print_mib_tables([]) ->
ok;
-print_mib_tables([{Mod, Tabs}|MibTabs]) when is_atom(Mod) andalso is_list(Tabs) ->
+print_mib_tables([{Mod, Tabs}|MibTabs])
+ when is_atom(Mod) andalso is_list(Tabs) ->
print_mib_tables(Mod, Tabs),
print_mib_tables(MibTabs);
print_mib_tables([_|MibTabs]) ->
@@ -347,9 +348,9 @@ print_mib_tables([_|MibTabs]) ->
print_mib_tables(Mod, Tables) ->
io:format("~n** ~s ** ~n~n", [make_pretty_mib(Mod)]),
- print_tables(Mod, Tables).
+ print_mib_tables2(Mod, Tables).
-print_tables(Mod, Tables) ->
+print_mib_tables2(Mod, Tables) ->
[(catch Mod:Table(print)) || Table <- Tables].
@@ -359,7 +360,8 @@ print_mib_variables() ->
print_mib_variables([]) ->
ok;
-print_mib_variables([{Mod, Vars}|MibVars]) when is_atom(Mod) andalso is_list(Vars) ->
+print_mib_variables([{Mod, Vars}|MibVars])
+ when is_atom(Mod) andalso is_list(Vars) ->
print_mib_variables(Mod, Vars),
print_mib_variables(MibVars);
print_mib_variables([_|MibVars]) ->
@@ -367,9 +369,9 @@ print_mib_variables([_|MibVars]) ->
print_mib_variables(Mod, Vars) ->
io:format("~n** ~s ** ~n~n", [make_pretty_mib(Mod)]),
- print_variables(Mod, Vars).
+ print_mib_variables2(Mod, Vars).
-print_variables(Mod, Variables) ->
+print_mib_variables2(Mod, Variables) ->
[(catch Mod:Variable(print)) || Variable <- Variables].
diff --git a/lib/snmp/src/agent/snmpa_mib_lib.erl b/lib/snmp/src/agent/snmpa_mib_lib.erl
index 441228b9ee..22057b4547 100644
--- a/lib/snmp/src/agent/snmpa_mib_lib.erl
+++ b/lib/snmp/src/agent/snmpa_mib_lib.erl
@@ -19,7 +19,8 @@
-module(snmpa_mib_lib).
-export([table_cre_row/3, table_del_row/2]).
--export([get_table/2, print_table/3, print_table/4, print_tables/1]).
+-export([get_table/2]).
+-export([print_variables/1, print_table/3, print_table/4, print_tables/1]).
-export([gc_tab/3, gc_tab/5]).
-include("SNMPv2-TC.hrl").
@@ -81,6 +82,47 @@ get_table(NameDb, FOI, Oid, Acc) ->
end.
+print_variables(Variables) when is_list(Variables) ->
+ Variables2 = print_variables_prefixify(Variables),
+ lists:foreach(fun({Variable, ValueResult, Prefix}) ->
+ print_variable(Variable, ValueResult, Prefix)
+ end, Variables2),
+ ok.
+
+print_variable(Variable, {value, Val}, Prefix) when is_atom(Variable) ->
+ io:format("~w~s => ~p~n", [Variable, Prefix, Val]);
+print_variable(Variable, Error, Prefix) when is_atom(Variable) ->
+ io:format("~w~s => ERROR: ~p~n", [Variable, Prefix, Error]).
+
+print_variables_prefixify(Variables) ->
+ MaxVarLength = print_variables_maxlength(Variables),
+ print_variables_prefixify(Variables, MaxVarLength, []).
+
+print_variables_prefixify([], _MaxVarLength, Acc) ->
+ lists:reverse(Acc);
+print_variables_prefixify([{Var, Res}|Variables], MaxVarLength, Acc) ->
+ Prefix = make_variable_print_prefix(Var, MaxVarLength),
+ print_variables_prefixify(Variables, MaxVarLength,
+ [{Var, Res, Prefix}|Acc]).
+
+make_variable_print_prefix(Var, MaxVarLength) ->
+ lists:duplicate(MaxVarLength - length(atom_to_list(Var)) + 1, $ ).
+
+print_variables_maxlength(Variables) ->
+ print_variables_maxlength(Variables, 0).
+
+print_variables_maxlength([], MaxLength) ->
+ MaxLength;
+print_variables_maxlength([{Var, _}|Variables], MaxLength) when is_atom(Var) ->
+ VarLen = length(atom_to_list(Var)),
+ if
+ VarLen > MaxLength ->
+ print_variables_maxlength(Variables, VarLen);
+ true ->
+ print_variables_maxlength(Variables, MaxLength)
+ end.
+
+
print_tables(Tables) when is_list(Tables) ->
lists:foreach(fun({Table, DB, FOI, PrintRow}) ->
print_table(Table, DB, FOI, PrintRow)
--
cgit v1.2.3
From 9a80a4f0064af1773bf73df86d3534049a61e373 Mon Sep 17 00:00:00 2001
From: Micael Karlberg
Date: Thu, 9 Dec 2010 12:19:36 +0100
Subject: First preliminary addition of the test config (there are still a
bunch of hard coded paths and stuff). No sed'ing yet...
---
lib/snmp/test/test_config/Makefile | 130 +++++++++++++++++++++
lib/snmp/test/test_config/agent/agent.conf.src | 20 ++++
lib/snmp/test/test_config/agent/community.conf.src | 16 +++
lib/snmp/test/test_config/agent/context.conf.src | 15 +++
lib/snmp/test/test_config/agent/notify.conf.src | 14 +++
lib/snmp/test/test_config/agent/standard.conf.src | 22 ++++
.../test/test_config/agent/target_addr.conf.src | 22 ++++
.../test/test_config/agent/target_params.conf.src | 12 ++
lib/snmp/test/test_config/agent/vacm.conf.src | 28 +++++
lib/snmp/test/test_config/manager/manager.conf.src | 16 +++
lib/snmp/test/test_config/manager/usm.conf.src | 8 ++
lib/snmp/test/test_config/modules.mk | 37 ++++++
lib/snmp/test/test_config/sys-agent.config.src | 42 +++++++
lib/snmp/test/test_config/sys-manager.config.src | 55 +++++++++
lib/snmp/test/test_config/sys.config.src | 67 +++++++++++
15 files changed, 504 insertions(+)
create mode 100644 lib/snmp/test/test_config/Makefile
create mode 100644 lib/snmp/test/test_config/agent/agent.conf.src
create mode 100644 lib/snmp/test/test_config/agent/community.conf.src
create mode 100644 lib/snmp/test/test_config/agent/context.conf.src
create mode 100644 lib/snmp/test/test_config/agent/notify.conf.src
create mode 100644 lib/snmp/test/test_config/agent/standard.conf.src
create mode 100644 lib/snmp/test/test_config/agent/target_addr.conf.src
create mode 100644 lib/snmp/test/test_config/agent/target_params.conf.src
create mode 100644 lib/snmp/test/test_config/agent/vacm.conf.src
create mode 100644 lib/snmp/test/test_config/manager/manager.conf.src
create mode 100644 lib/snmp/test/test_config/manager/usm.conf.src
create mode 100644 lib/snmp/test/test_config/modules.mk
create mode 100644 lib/snmp/test/test_config/sys-agent.config.src
create mode 100644 lib/snmp/test/test_config/sys-manager.config.src
create mode 100644 lib/snmp/test/test_config/sys.config.src
(limited to 'lib')
diff --git a/lib/snmp/test/test_config/Makefile b/lib/snmp/test/test_config/Makefile
new file mode 100644
index 0000000000..187a0ca901
--- /dev/null
+++ b/lib/snmp/test/test_config/Makefile
@@ -0,0 +1,130 @@
+#-*-makefile-*- ; force emacs to enter makefile-mode
+
+# %CopyrightBegin%
+#
+# Copyright Ericsson AB 1997-2009. 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
+# compliance with the License. You should have received a copy of the
+# Erlang Public License along with this software. If not, it can be
+# retrieved online at http://www.erlang.org/.
+#
+# Software distributed under the License is distributed on an "AS IS"
+# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+# the License for the specific language governing rights and limitations
+# under the License.
+#
+# %CopyrightEnd%
+
+include $(ERL_TOP)/make/target.mk
+include $(ERL_TOP)/make/$(TARGET)/otp.mk
+
+
+# ----------------------------------------------------
+# Application version
+# ----------------------------------------------------
+include ../../vsn.mk
+
+VSN = $(SNMP_VSN)
+
+
+# ----------------------------------------------------
+# Target Specs
+# ----------------------------------------------------
+
+include modules.mk
+
+SYS_CONFIG_SRCS = $(SYS_CONFIG_FILES:%=%.src)
+AGENT_CONFIG_SRCS = $(AGENT_CONFIG_FILES:%=%.src)
+MANAGER_CONFIG_SRCS = $(MANAGER_CONFIG_FILES:%=%.src)
+
+
+# ----------------------------------------------------
+# Release directory specification
+# ----------------------------------------------------
+RELSYSDIR = $(RELEASE_PATH)
+
+
+# ----------------------------------------------------
+# SNMP FLAGS
+# ----------------------------------------------------
+
+
+# ----------------------------------------------------
+# FLAGS
+# ----------------------------------------------------
+
+
+# ----------------------------------------------------
+# Targets
+# ----------------------------------------------------
+
+tests debug opt: $(SYS_CONFIG_FILES) $(AGENT_CONFIG_FILES) $(MANAGER_CONFIG_FILES)
+
+clean:
+ rm -f $(SYS_CONFIG_FILES)
+ rm -f $(AGENT_CONFIG_FILES)
+ rm -f $(MANAGER_CONFIG_FILES)
+ rm -f core
+
+docs:
+
+
+# ----------------------------------------------------
+# Release Target
+# ----------------------------------------------------
+include $(ERL_TOP)/make/otp_release_targets.mk
+
+release_spec:
+
+release_tests_spec: opt
+ $(INSTALL_DIR) $(RELSYSDIR)
+ chmod -f -R u+w $(RELSYSDIR)
+ $(INSTALL_DIR) $(RELSYSDIR)/agent
+ chmod -f -R u+w $(RELSYSDIR)/agent
+ $(INSTALL_DIR) $(RELSYSDIR)/agent/conf
+ chmod -f -R u+w $(RELSYSDIR)/agent/conf
+ $(INSTALL_DIR) $(RELSYSDIR)/agent/db
+ chmod -f -R u+w $(RELSYSDIR)/agent/db
+ $(INSTALL_DIR) $(RELSYSDIR)/agent/log
+ chmod -f -R u+w $(RELSYSDIR)/agent/log
+ $(INSTALL_DIR) $(RELSYSDIR)/manager
+ chmod -f -R u+w $(RELSYSDIR)/manager
+ $(INSTALL_DIR) $(RELSYSDIR)/manager/conf
+ chmod -f -R u+w $(RELSYSDIR)/manager/conf
+ $(INSTALL_DIR) $(RELSYSDIR)/manager/db
+ chmod -f -R u+w $(RELSYSDIR)/manager/db
+ $(INSTALL_DIR) $(RELSYSDIR)/manager/log
+ chmod -f -R u+w $(RELSYSDIR)/manager/log
+ $(INSTALL_DATA) $(SYS_CONFIG_FILES) $(RELSYSDIR)
+ $(INSTALL_DATA) $(AGENT_CONFIG_FILES) $(RELSYSDIR)/agent/conf
+ $(INSTALL_DATA) $(MANAGER_CONFIG_FILES) $(RELSYSDIR)/manager/conf
+
+release_docs_spec:
+
+
+info:
+ @echo "SNMP_DEBUG = $(SNMP_DEBUG)"
+ @echo "SNMP_FLAGS = $(SNMP_FLAGS)"
+ @echo ""
+ @echo "SNMP_MIB_DIR = $(SNMP_MIB_DIR)"
+ @echo "MIB_SOURCE = $(MIB_SOURCE)"
+ @echo "MIB_TARGETS = $(MIB_TARGETS)"
+ @echo "SNMP_MIB_FLAGS = $(SNMP_MIB_FLAGS)"
+ @echo ""
+ @echo "ERL_COMPILE_FLAGS = $(ERL_COMPILE_FLAGS)"
+ @echo ""
+ @echo "RELSYSDIR = $(RELSYSDIR)"
+ @echo ""
+ @echo "SOURCE = $(SOURCE)"
+ @echo ""
+ @echo "TARGET_FILES = $(TARGET_FILES)"
+ @echo ""
+ @echo "EMAKEFILE = $(EMAKEFILE)"
+ @echo "MAKE_EMAKE = $(MAKE_EMAKE)"
+ @echo "BUILDTARGET = $(BUILDTARGET)"
+ @echo "RELTEST_FILES = $(RELTEST_FILES)"
+ @echo ""
+
+
diff --git a/lib/snmp/test/test_config/agent/agent.conf.src b/lib/snmp/test/test_config/agent/agent.conf.src
new file mode 100644
index 0000000000..53830dbc3e
--- /dev/null
+++ b/lib/snmp/test/test_config/agent/agent.conf.src
@@ -0,0 +1,20 @@
+%% This file was generated by snmp_config (version-4.9.3) 2007-06-29 13:32:48
+%% This file defines the Agent local configuration info
+%% The data is inserted into the snmpEngine* variables defined
+%% in SNMP-FRAMEWORK-MIB, and the intAgent* variables defined
+%% in OTP-SNMPEA-MIB.
+%% Each row is a 2-tuple:
+%% {AgentVariable, Value}.
+%% For example
+%% {intAgentUDPPort, 4000}.
+%% The ip address for the agent is sent as id in traps.
+%% {intAgentIpAddress, [127,42,17,5]}.
+%% {snmpEngineID, "agentEngine"}.
+%% {snmpEngineMaxMessageSize, 484}.
+%%
+
+
+{intAgentUDPPort, 4000}.
+{intAgentIpAddress, [127,0,0,1]}.
+{snmpEngineID, "foo"}.
+{snmpEngineMaxMessageSize, 484}.
diff --git a/lib/snmp/test/test_config/agent/community.conf.src b/lib/snmp/test/test_config/agent/community.conf.src
new file mode 100644
index 0000000000..4661267950
--- /dev/null
+++ b/lib/snmp/test/test_config/agent/community.conf.src
@@ -0,0 +1,16 @@
+%% This file was generated by snmp_config (version-4.9.3) 2007-06-29 13:32:48
+%% This file defines the community info which maps to VACM parameters.
+%% The data is inserted into the snmpCommunityTable defined
+%% in SNMP-COMMUNITY-MIB.
+%% Each row is a 5-tuple:
+%% {CommunityIndex, CommunityName, SecurityName, ContextName, TransportTag}.
+%% For example
+%% {"1", "public", "initial", "", ""}.
+%% {"2", "secret", "secret_name", "", "tag"}.
+%% {"3", "bridge1", "initial", "bridge1", ""}.
+%%
+
+
+{"public", "public", "initial", "", ""}.
+{"all-rights", "all-rights", "all-rights", "", ""}.
+{"standard trap", "standard trap", "initial", "", ""}.
diff --git a/lib/snmp/test/test_config/agent/context.conf.src b/lib/snmp/test/test_config/agent/context.conf.src
new file mode 100644
index 0000000000..56000d0308
--- /dev/null
+++ b/lib/snmp/test/test_config/agent/context.conf.src
@@ -0,0 +1,15 @@
+%% This file was generated by snmp_config (version-4.9.3) 2007-06-29 13:32:48
+%% This file defines the contexts known to the agent.
+%% The data is inserted into the vacmContextTable defined
+%% in SNMP-VIEW-BASED-ACM-MIB.
+%% Each row is a string:
+%% ContextName.
+%%
+%% The empty string is the default context.
+%% For example
+%% "bridge1".
+%% "bridge2".
+%%
+
+
+"".
diff --git a/lib/snmp/test/test_config/agent/notify.conf.src b/lib/snmp/test/test_config/agent/notify.conf.src
new file mode 100644
index 0000000000..b63668f4fd
--- /dev/null
+++ b/lib/snmp/test/test_config/agent/notify.conf.src
@@ -0,0 +1,14 @@
+%% This file was generated by snmp_config (version-4.9.3) 2007-06-29 13:32:48
+%% This file defines the notification parameters.
+%% The data is inserted into the snmpNotifyTable defined
+%% in SNMP-NOTIFICATION-MIB.
+%% The Name is used as CommunityString for v1 and v2c.
+%% Each row is a 3-tuple:
+%% {Name, Tag, Type}.
+%% For example
+%% {"standard trap", "std_trap", trap}.
+%% {"standard inform", "std_inform", inform}.
+%%
+
+
+{"stadard_trap", "std_trap", trap}.
diff --git a/lib/snmp/test/test_config/agent/standard.conf.src b/lib/snmp/test/test_config/agent/standard.conf.src
new file mode 100644
index 0000000000..9bcca18b5e
--- /dev/null
+++ b/lib/snmp/test/test_config/agent/standard.conf.src
@@ -0,0 +1,22 @@
+%% This file was generated by snmp_config (version-4.9.3) 2007-06-29 13:32:48
+%% This file defines the STANDARD-MIB info.
+%% Each row is a 2-tuple:
+%% {StandardVariable, Value}.
+%% For example
+%% {sysDescr, "Erlang SNMP agent"}.
+%% {sysObjectID, [1,2,3]}.
+%% {sysContact, "{mbj,eklas}@erlang.ericsson.se"}.
+%% {sysName, "test"}.
+%% {sysLocation, "erlang"}.
+%% {sysServices, 72}.
+%% {snmpEnableAuthenTraps, enabled}.
+%%
+
+
+{sysDescr, "Erlang SNMP agent"}.
+{sysObjectID, [1,2,3]}.
+{sysContact, "{mbj,eklas}@erlang.ericsson.se"}.
+{sysLocation, "erlang"}.
+{sysServices, 72}.
+{snmpEnableAuthenTraps, disabled}.
+{sysName, "foo"}.
diff --git a/lib/snmp/test/test_config/agent/target_addr.conf.src b/lib/snmp/test/test_config/agent/target_addr.conf.src
new file mode 100644
index 0000000000..2c7a6a15ad
--- /dev/null
+++ b/lib/snmp/test/test_config/agent/target_addr.conf.src
@@ -0,0 +1,22 @@
+%% This file was generated by snmp_config (version-4.9.3) 2007-06-29 13:32:48
+%% This file defines the target address parameters.
+%% The data is inserted into the snmpTargetAddrTable defined
+%% in SNMP-TARGET-MIB, and in the snmpTargetAddrExtTable defined
+%% in SNMP-COMMUNITY-MIB.
+%% Each row is a 10-tuple:
+%% {Name, Ip, Udp, Timeout, RetryCount, TagList, ParamsName, EngineId,
+%% TMask, MaxMessageSize}.
+%% The EngineId value is only used if Inform-Requests are sent to this
+%% target. If Informs are not sent, this value is ignored, and can be
+%% e.g. an empty string. However, if Informs are sent, it is essential
+%% that the value of EngineId matches the value of the target's
+%% actual snmpEngineID.
+%% For example
+%% {"1.2.3.4 v1", [1,2,3,4], 162,
+%% 1500, 3, "std_inform", "otp_v2", "",
+%% [127,0,0,0], 2048}.
+%%
+
+
+{"127.0.0.1 v2", [127,0,0,1], 5000, 1500, 3, "std_trap", "target_v2", "", [], 2048}.
+{"127.0.0.1 v2.2", [127,0,0,1], 5000, 1500, 3, "std_inform", "target_v2", "", [], 2048}.
diff --git a/lib/snmp/test/test_config/agent/target_params.conf.src b/lib/snmp/test/test_config/agent/target_params.conf.src
new file mode 100644
index 0000000000..8e89b91d81
--- /dev/null
+++ b/lib/snmp/test/test_config/agent/target_params.conf.src
@@ -0,0 +1,12 @@
+%% This file was generated by snmp_config (version-4.9.3) 2007-06-29 13:32:48
+%% This file defines the target parameters.
+%% The data is inserted into the snmpTargetParamsTable defined
+%% in SNMP-TARGET-MIB.
+%% Each row is a 5-tuple:
+%% {Name, MPModel, SecurityModel, SecurityName, SecurityLevel}.
+%% For example
+%% {"target_v3", v3, usm, "", noAuthNoPriv}.
+%%
+
+
+{"target_v2", v2c, v2c, "initial", noAuthNoPriv}.
diff --git a/lib/snmp/test/test_config/agent/vacm.conf.src b/lib/snmp/test/test_config/agent/vacm.conf.src
new file mode 100644
index 0000000000..c7dc5170c2
--- /dev/null
+++ b/lib/snmp/test/test_config/agent/vacm.conf.src
@@ -0,0 +1,28 @@
+%% This file was generated by snmp_config (version-4.9.3) 2007-06-29 13:32:48
+%% This file defines the Mib Views.
+%% The data is inserted into the vacm* tables defined
+%% in SNMP-VIEW-BASED-ACM-MIB.
+%% Each row is one of 3 tuples; one for each table in the MIB:
+%% {vacmSecurityToGroup, SecModel, SecName, GroupName}.
+%% {vacmAccess, GroupName, Prefix, SecModel, SecLevel, Match, RV, WV, NV}.
+%% {vacmViewTreeFamily, ViewIndex, ViewSubtree, ViewStatus, ViewMask}.
+%% For example
+%% {vacmSecurityToGroup, v2c, "initial", "initial"}.
+%% {vacmSecurityToGroup, usm, "initial", "initial"}.
+%% read/notify access to system
+%% {vacmAccess, "initial", "", any, noAuthNoPriv, exact,
+%% "system", "", "system"}.
+%% {vacmViewTreeFamily, "system", [1,3,6,1,2,1,1], included, null}.
+%% {vacmViewTreeFamily, "exmib", [1,3,6,1,3], included, null}. % for EX1-MIB
+%% {vacmViewTreeFamily, "internet", [1,3,6,1], included, null}.
+%%
+
+
+{vacmSecurityToGroup, v2c, "initial", "initial"}.
+{vacmSecurityToGroup, v2c, "all-rights", "all-rights"}.
+{vacmAccess, "initial", "", any, noAuthNoPriv, exact, "restricted", "", "restricted"}.
+{vacmAccess, "initial", "", usm, authNoPriv, exact, "internet", "internet", "internet"}.
+{vacmAccess, "initial", "", usm, authPriv, exact, "internet", "internet", "internet"}.
+{vacmAccess, "all-rights", "", any, noAuthNoPriv, exact, "internet", "internet", "internet"}.
+{vacmViewTreeFamily, "restricted", [1,3,6,1], included, null}.
+{vacmViewTreeFamily, "internet", [1,3,6,1], included, null}.
diff --git a/lib/snmp/test/test_config/manager/manager.conf.src b/lib/snmp/test/test_config/manager/manager.conf.src
new file mode 100644
index 0000000000..164e5507c6
--- /dev/null
+++ b/lib/snmp/test/test_config/manager/manager.conf.src
@@ -0,0 +1,16 @@
+%% This file was generated by snmp_config (version-4.9.3) 2007-06-29 13:35:05
+%% This file defines the Manager local configuration info
+%% Each row is a 2-tuple:
+%% {Variable, Value}.
+%% For example
+%% {port, 5000}.
+%% {address, [127,42,17,5]}.
+%% {engine_id, "managerEngine"}.
+%% {max_message_size, 484}.
+%%
+
+
+{port, 5000}.
+{address, [127,0,0,1]}.
+{engine_id, "foo"}.
+{max_message_size, 484}.
diff --git a/lib/snmp/test/test_config/manager/usm.conf.src b/lib/snmp/test/test_config/manager/usm.conf.src
new file mode 100644
index 0000000000..39122cab5c
--- /dev/null
+++ b/lib/snmp/test/test_config/manager/usm.conf.src
@@ -0,0 +1,8 @@
+%% This file was generated by snmp_config (version-4.9.3) 2007-06-29 13:35:05
+%% This file defines the usm users the manager handles
+%% Each row is a 6 or 7-tuple:
+%% {EngineID, UserName, AuthP, AuthKey, PrivP, PrivKey}
+%% {EngineID, UserName, SecName, AuthP, AuthKey, PrivP, PrivKey}
+%%
+
+
diff --git a/lib/snmp/test/test_config/modules.mk b/lib/snmp/test/test_config/modules.mk
new file mode 100644
index 0000000000..54e6e22966
--- /dev/null
+++ b/lib/snmp/test/test_config/modules.mk
@@ -0,0 +1,37 @@
+#-*-makefile-*- ; force emacs to enter makefile-mode
+
+# %CopyrightBegin%
+#
+# Copyright Ericsson AB 2004-2010. 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
+# compliance with the License. You should have received a copy of the
+# Erlang Public License along with this software. If not, it can be
+# retrieved online at http://www.erlang.org/.
+#
+# Software distributed under the License is distributed on an "AS IS"
+# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+# the License for the specific language governing rights and limitations
+# under the License.
+#
+# %CopyrightEnd%
+
+SYS_CONFIG_FILES = \
+ sys.config \
+ sys-agent.config \
+ sys-manager.config
+
+AGENT_CONFIG_FILES = \
+ agent/agent.conf \
+ agent/community.conf \
+ agent/context.conf \
+ agent/notify.conf \
+ agent/standard.conf \
+ agent/target_addr.conf \
+ agent/target_params.conf \
+ agent/vacm.conf
+
+MANAGER_CONFIG_FILES = \
+ manager/manager.conf \
+ manager/usm.conf
diff --git a/lib/snmp/test/test_config/sys-agent.config.src b/lib/snmp/test/test_config/sys-agent.config.src
new file mode 100644
index 0000000000..9df2c6a6bc
--- /dev/null
+++ b/lib/snmp/test/test_config/sys-agent.config.src
@@ -0,0 +1,42 @@
+%% This file was generated by snmp_config (version-4.9.3) 2007-06-29 13:35:10
+[{snmp,
+ [
+ {agent,
+ [
+ {priority, normal},
+ {versions, [v2]},
+ {db_dir, "/ldisk/bmk/tests/snmp/seq10689/a/db"},
+ {mib_storage, ets},
+%% {agent_mib_storage, volatile},
+ {agent_mib_storage, persistent},
+ {target_cache, [{verbosity,silence}]},
+ {symbolic_store, [{verbosity,silence}]},
+ {local_db, [{repair,true},{auto_save,5000},{verbosity,silence}]},
+ {error_report_module, snmpa_error_logger},
+ {agent_type, master},
+ {agent_verbosity, trace},
+ {audit_trail_log, [{type, read},
+ {dir, "/ldisk/bmk/tests/snmp/seq10689/a/log"},
+ {size, {10240,10}}]},
+ {config, [{dir, "/ldisk/bmk/tests/snmp/seq10689/a/conf"},
+ {force_load, true},
+ {verbosity, trace}]},
+ {multi_threaded, true},
+ {mib_server, [{mibentry_override, false},
+ {trapentry_override, false},
+ {cache, true},
+ {verbosity, trace}]},
+ {note_store, [{timeout,30000}, {verbosity,silence}]},
+ {supervisor, [{verbosity,silence}]},
+ {net_if, [{module, snmpa_net_if},
+ {verbosity, silence},
+ {options, [{bind_to, true},
+ {no_reuse, false},
+ {req_limit, infinity},
+ {sndbuf, 32000},
+ {recbuf, 32000}]}]}
+ ]
+ }
+ ]
+ }
+].
diff --git a/lib/snmp/test/test_config/sys-manager.config.src b/lib/snmp/test/test_config/sys-manager.config.src
new file mode 100644
index 0000000000..dc795e31ab
--- /dev/null
+++ b/lib/snmp/test/test_config/sys-manager.config.src
@@ -0,0 +1,55 @@
+%% This file was generated by snmp_config (version-4.9.3) 2007-06-29 13:35:10
+[{snmp,
+ [
+%% {agent,
+%% [
+%% {priority, normal},
+%% {versions, [v2]},
+%% {db_dir, "/home/eklajoh/tmp/snmp-config-2/a/"},
+%% {mib_storage, ets},
+%% {agent_mib_storage, volatile},
+%% {target_cache, [{verbosity,silence}]},
+%% {symbolic_store, [{verbosity,silence}]},
+%% {local_db, [{repair,true},{auto_save,5000},{verbosity,silence}]},
+%% {error_report_module, snmpa_error_logger},
+%% {agent_type, master},
+%% {agent_verbosity, silence},
+%% {config, [{dir, "/home/eklajoh/tmp/snmp-config-2/a/"}, {force_load, true}, {verbosity, silence}]},
+%% {multi_threaded, false},
+%% {mib_server, [{mibentry_override,false},{trapentry_override,false},{verbosity,silence}]},
+%% {note_store, [{timeout,30000},{verbosity,silence}]},
+%% {net_if, [{module,snmpa_net_if},{verbosity,silence},{options,[{bind_to,true},{no_reuse,false},{req_limit,infinity}]}]}
+%% ]
+%% },
+ {manager,
+ [
+ {priority, normal},
+ {versions, [v1,v2,v3]},
+ {config, [{dir, "/ldisk/bmk/tests/snmp/seq10689/m/conf"},
+ {verbosity, trace},
+ {db_dir, "/ldisk/bmk/tests/snmp/seq10689/m/db"},
+ {repair, true},
+ {auto_save, 5000}]},
+ {inform_request_behaviour, user},
+ {mibs, []},
+ {server, [{timeout, 30000},
+ {verbosity, trace}]},
+ {note_store, [{timeout,30000},
+ {verbosity,silence}]},
+ {audit_trail_log, [{type, read},
+ {dir, "/ldisk/bmk/tests/snmp/seq10689/m/log"},
+ {size, {10240,10}}]},
+ {net_if, [{module,snmpm_net_if},
+ {verbosity, trace},
+ {options, [{bind_to, true},
+ {no_reuse, false},
+% {sndbuf, 32000},
+ {recbuf, 45000}
+]}]},
+ {def_user_mod, snmpm_user_default},
+ {def_user_data, undefined}
+ ]
+ }
+ ]
+ }
+].
diff --git a/lib/snmp/test/test_config/sys.config.src b/lib/snmp/test/test_config/sys.config.src
new file mode 100644
index 0000000000..5a0fa0624b
--- /dev/null
+++ b/lib/snmp/test/test_config/sys.config.src
@@ -0,0 +1,67 @@
+%% This file was generated by snmp_config (version-4.9.3) 2007-06-29 13:35:10
+[{snmp,
+ [
+ {agent,
+ [
+ {priority, normal},
+ {versions, [v2]},
+ {db_dir, "/ldisk/bmk/tests/snmp/seq10689/a/db"},
+ {mib_storage, ets},
+ {agent_mib_storage, volatile},
+ {target_cache, [{verbosity,silence}]},
+ {symbolic_store, [{verbosity,silence}]},
+ {local_db, [{repair,true},{auto_save,5000},{verbosity,silence}]},
+ {error_report_module, snmpa_error_logger},
+ {agent_type, master},
+ {agent_verbosity, silence},
+ {audit_trail_log, [{type, read},
+ {dir, "/ldisk/bmk/tests/snmp/seq10689/a/log"},
+ {size, {10240,10}}]},
+ {config, [{dir, "/ldisk/bmk/tests/snmp/seq10689/a/conf"},
+ {force_load, true},
+ {verbosity, silence}]},
+ {multi_threaded, false},
+ {mib_server, [{mibentry_override, false},
+ {trapentry_override, false},
+ {verbosity, silence}]},
+ {note_store, [{timeout,30000},{verbosity,silence}]},
+ {net_if, [{module, snmpa_net_if},
+ {verbosity, silence},
+ {options, [{bind_to, true},
+ {no_reuse, false},
+ {req_limit, infinity},
+ {sndbuf, 32000},
+ {recbuf, 32000}]}]}
+ ]
+ },
+ {manager,
+ [
+ {priority, normal},
+ {versions, [v2]},
+ {config, [{dir, "/ldisk/bmk/tests/snmp/seq10689/m/conf"},
+ {verbosity, silence},
+ {db_dir, "/ldisk/bmk/tests/snmp/seq10689/m/db"},
+ {repair, true},
+ {auto_save, 5000}]},
+ {inform_request_behaviour, auto},
+ {mibs, []},
+ {server, [{timeout, 30000},
+ {verbosity, silence}]},
+ {note_store, [{timeout, 30000},
+ {verbosity, silence}]},
+ {audit_trail_log, [{type, read},
+ {dir, "/ldisk/bmk/tests/snmp/seq10689/m/log"},
+ {size, {10240,10}}]},
+ {net_if, [{module,snmpm_net_if},
+ {verbosity, silence},
+ {options, [{bind_to, true},
+ {no_reuse, false},
+ {recbuf, 33000},
+ {sndbuf, 34000}]}]},
+ {def_user_mod, snmpm_user_default},
+ {def_user_data, undefined}
+ ]
+ }
+ ]
+ }
+].
--
cgit v1.2.3
From add572241ac6085f1dc1062ae6ca351737ec43eb Mon Sep 17 00:00:00 2001
From: Micael Karlberg
Date: Thu, 9 Dec 2010 12:30:02 +0100
Subject: Added preliminary make targets for config file building (sed'ing).
---
lib/snmp/test/test_config/Makefile | 33 +++++++++++++++------------------
1 file changed, 15 insertions(+), 18 deletions(-)
(limited to 'lib')
diff --git a/lib/snmp/test/test_config/Makefile b/lib/snmp/test/test_config/Makefile
index 187a0ca901..250c594af6 100644
--- a/lib/snmp/test/test_config/Makefile
+++ b/lib/snmp/test/test_config/Makefile
@@ -70,6 +70,15 @@ clean:
docs:
+$(SYS_CONFIG_FILES): $(SYS_CONFIG_SRCS)
+ @echo "sys: $< -> $@"
+
+$(AGENT_CONFIG_FILES): $(AGENT_CONFIG_SRCS)
+ @echo "agent: $< -> $@"
+
+$(MANAGER_CONFIG_FILES): $(MANAGER_CONFIG_SRCS)
+ @echo "manager: $< -> $@"
+
# ----------------------------------------------------
# Release Target
@@ -105,26 +114,14 @@ release_docs_spec:
info:
- @echo "SNMP_DEBUG = $(SNMP_DEBUG)"
- @echo "SNMP_FLAGS = $(SNMP_FLAGS)"
- @echo ""
- @echo "SNMP_MIB_DIR = $(SNMP_MIB_DIR)"
- @echo "MIB_SOURCE = $(MIB_SOURCE)"
- @echo "MIB_TARGETS = $(MIB_TARGETS)"
- @echo "SNMP_MIB_FLAGS = $(SNMP_MIB_FLAGS)"
- @echo ""
- @echo "ERL_COMPILE_FLAGS = $(ERL_COMPILE_FLAGS)"
- @echo ""
- @echo "RELSYSDIR = $(RELSYSDIR)"
- @echo ""
- @echo "SOURCE = $(SOURCE)"
+ @echo "SYS_CONFIG_SRCS = $(SYS_CONFIG_SRCS)"
+ @echo "SYS_CONFIG_FILES = $(SYS_CONFIG_FILES)"
@echo ""
- @echo "TARGET_FILES = $(TARGET_FILES)"
+ @echo "AGENT_CONFIG_SRCS = $(AGENT_CONFIG_SRCS)"
+ @echo "AGENT_CONFIG_FILES = $(AGENT_CONFIG_FILES)"
@echo ""
- @echo "EMAKEFILE = $(EMAKEFILE)"
- @echo "MAKE_EMAKE = $(MAKE_EMAKE)"
- @echo "BUILDTARGET = $(BUILDTARGET)"
- @echo "RELTEST_FILES = $(RELTEST_FILES)"
+ @echo "MANAGER_CONFIG_SRCS = $(MANAGER_CONFIG_SRCS)"
+ @echo "MANAGER_CONFIG_FILES = $(MANAGER_CONFIG_FILES)"
@echo ""
--
cgit v1.2.3
From ec857328b0ece6a676633a3bd647a4ce37703469 Mon Sep 17 00:00:00 2001
From: Micael Karlberg
Date: Thu, 9 Dec 2010 18:44:04 +0100
Subject: First preliminary sedding...
---
lib/snmp/test/test_config/.gitignore | 18 ++++++++
lib/snmp/test/test_config/Makefile | 56 +++++++++++++++++++-----
lib/snmp/test/test_config/agent/agent.conf.src | 2 +-
lib/snmp/test/test_config/modules.mk | 3 ++
lib/snmp/test/test_config/sys-agent.config.src | 9 ++--
lib/snmp/test/test_config/sys-manager.config.src | 32 +++-----------
lib/snmp/test/test_config/sys.config.src | 15 ++++---
lib/snmp/test/test_config/test_config.erl | 27 ++++++++++++
8 files changed, 112 insertions(+), 50 deletions(-)
create mode 100644 lib/snmp/test/test_config/.gitignore
create mode 100644 lib/snmp/test/test_config/test_config.erl
(limited to 'lib')
diff --git a/lib/snmp/test/test_config/.gitignore b/lib/snmp/test/test_config/.gitignore
new file mode 100644
index 0000000000..60d564fe4d
--- /dev/null
+++ b/lib/snmp/test/test_config/.gitignore
@@ -0,0 +1,18 @@
+# Sys config files (Generated)
+/sys.config
+/sys-agent.config
+/sys-manager.config
+
+# Agent config files (Generated)
+/agent/agent.conf
+/agent/community.conf
+/agent/context.conf
+/agent/notify.conf
+/agent/standard.conf
+/agent/target_addr.conf
+/agent/target_params.conf
+/agent/vacm.conf
+
+# Manager config files (Generated)
+/manager/manager.conf
+/manager/usm.conf
diff --git a/lib/snmp/test/test_config/Makefile b/lib/snmp/test/test_config/Makefile
index 250c594af6..064c9f4689 100644
--- a/lib/snmp/test/test_config/Makefile
+++ b/lib/snmp/test/test_config/Makefile
@@ -29,55 +29,82 @@ include ../../vsn.mk
VSN = $(SNMP_VSN)
+# ----------------------------------------------------
+# Configured variables
+# ----------------------------------------------------
+# PERL = @PERL@
+PERL = perl
+
+
# ----------------------------------------------------
# Target Specs
# ----------------------------------------------------
include modules.mk
+ERL_TARGETS = $(MODULES:%=$(EBIN)/%.$(EMULATOR))
+
SYS_CONFIG_SRCS = $(SYS_CONFIG_FILES:%=%.src)
AGENT_CONFIG_SRCS = $(AGENT_CONFIG_FILES:%=%.src)
MANAGER_CONFIG_SRCS = $(MANAGER_CONFIG_FILES:%=%.src)
+CONFIG_FILES = \
+ $(SYS_CONFIG_FILES) \
+ $(AGENT_CONFIG_FILES) \
+ $(MANAGER_CONFIG_FILES)
-# ----------------------------------------------------
-# Release directory specification
-# ----------------------------------------------------
-RELSYSDIR = $(RELEASE_PATH)
+TARGETS = \
+ $(ERL_TARGETS) \
+ $(CONFIG_FILES)
# ----------------------------------------------------
-# SNMP FLAGS
+# Release directory specification
# ----------------------------------------------------
+ifeq ($(TESTROOT),)
+TESTROOT=/tmp
+endif
+RELSYSDIR = $(TESTROOT)
# ----------------------------------------------------
# FLAGS
# ----------------------------------------------------
+EBIN = .
+
+ERL_COMPILE_FLAGS += +'{parse_transform,sys_pre_attributes}' \
+ +'{attribute,insert,app_vsn,$(APP_VSN)}'
+
+ifeq ($(ADDR),)
+ADDR = $(shell erl -noshell -s test_config ip_address -s init stop)
+endif
+
# ----------------------------------------------------
# Targets
# ----------------------------------------------------
-tests debug opt: $(SYS_CONFIG_FILES) $(AGENT_CONFIG_FILES) $(MANAGER_CONFIG_FILES)
+tests debug opt: $(TARGETS)
clean:
- rm -f $(SYS_CONFIG_FILES)
- rm -f $(AGENT_CONFIG_FILES)
- rm -f $(MANAGER_CONFIG_FILES)
+ rm -f $(CONFIG_FILES)
+ rm -f $(ERL_TARGETS)
rm -f core
docs:
$(SYS_CONFIG_FILES): $(SYS_CONFIG_SRCS)
- @echo "sys: $< -> $@"
+ @echo "$< -> $@"
+ $(PERL) -p -e 's?%DIR%?$(RELSYSDIR)? ' < $< > $@
$(AGENT_CONFIG_FILES): $(AGENT_CONFIG_SRCS)
- @echo "agent: $< -> $@"
+ @echo "$< -> $@"
+ $(PERL) -p -e 's?%ADDR%?$(ADDR)? ' < $< > $@
$(MANAGER_CONFIG_FILES): $(MANAGER_CONFIG_SRCS)
- @echo "manager: $< -> $@"
+ @echo "$< -> $@"
+ $(PERL) -p -e 's?%ADDR%?$(ADDR)? ' < $< > $@
# ----------------------------------------------------
@@ -114,6 +141,9 @@ release_docs_spec:
info:
+ @echo ""
+ @echo "RELSYSDIR = $(RELSYSDIR)"
+ @echo ""
@echo "SYS_CONFIG_SRCS = $(SYS_CONFIG_SRCS)"
@echo "SYS_CONFIG_FILES = $(SYS_CONFIG_FILES)"
@echo ""
@@ -123,5 +153,7 @@ info:
@echo "MANAGER_CONFIG_SRCS = $(MANAGER_CONFIG_SRCS)"
@echo "MANAGER_CONFIG_FILES = $(MANAGER_CONFIG_FILES)"
@echo ""
+ @echo "ADDR = $(ADDR)"
+ @echo ""
diff --git a/lib/snmp/test/test_config/agent/agent.conf.src b/lib/snmp/test/test_config/agent/agent.conf.src
index 53830dbc3e..900e6a4282 100644
--- a/lib/snmp/test/test_config/agent/agent.conf.src
+++ b/lib/snmp/test/test_config/agent/agent.conf.src
@@ -15,6 +15,6 @@
{intAgentUDPPort, 4000}.
-{intAgentIpAddress, [127,0,0,1]}.
+{intAgentIpAddress, %ADDR%}.
{snmpEngineID, "foo"}.
{snmpEngineMaxMessageSize, 484}.
diff --git a/lib/snmp/test/test_config/modules.mk b/lib/snmp/test/test_config/modules.mk
index 54e6e22966..956bb54af3 100644
--- a/lib/snmp/test/test_config/modules.mk
+++ b/lib/snmp/test/test_config/modules.mk
@@ -35,3 +35,6 @@ AGENT_CONFIG_FILES = \
MANAGER_CONFIG_FILES = \
manager/manager.conf \
manager/usm.conf
+
+MODULES = \
+ test_config
diff --git a/lib/snmp/test/test_config/sys-agent.config.src b/lib/snmp/test/test_config/sys-agent.config.src
index 9df2c6a6bc..eb6b0916ff 100644
--- a/lib/snmp/test/test_config/sys-agent.config.src
+++ b/lib/snmp/test/test_config/sys-agent.config.src
@@ -1,11 +1,12 @@
-%% This file was generated by snmp_config (version-4.9.3) 2007-06-29 13:35:10
+%% This is an example sys config file for starting the snmp application
+%% with only a agent running.
[{snmp,
[
{agent,
[
{priority, normal},
{versions, [v2]},
- {db_dir, "/ldisk/bmk/tests/snmp/seq10689/a/db"},
+ {db_dir, "%DIR%/agent/db"},
{mib_storage, ets},
%% {agent_mib_storage, volatile},
{agent_mib_storage, persistent},
@@ -16,9 +17,9 @@
{agent_type, master},
{agent_verbosity, trace},
{audit_trail_log, [{type, read},
- {dir, "/ldisk/bmk/tests/snmp/seq10689/a/log"},
+ {dir, "%DIR%/agent/log"},
{size, {10240,10}}]},
- {config, [{dir, "/ldisk/bmk/tests/snmp/seq10689/a/conf"},
+ {config, [{dir, "%DIR%/agent/conf"},
{force_load, true},
{verbosity, trace}]},
{multi_threaded, true},
diff --git a/lib/snmp/test/test_config/sys-manager.config.src b/lib/snmp/test/test_config/sys-manager.config.src
index dc795e31ab..4366263084 100644
--- a/lib/snmp/test/test_config/sys-manager.config.src
+++ b/lib/snmp/test/test_config/sys-manager.config.src
@@ -1,33 +1,14 @@
-%% This file was generated by snmp_config (version-4.9.3) 2007-06-29 13:35:10
+%% This is an example sys config file for starting the snmp application
+%% with only a manager running.
[{snmp,
[
-%% {agent,
-%% [
-%% {priority, normal},
-%% {versions, [v2]},
-%% {db_dir, "/home/eklajoh/tmp/snmp-config-2/a/"},
-%% {mib_storage, ets},
-%% {agent_mib_storage, volatile},
-%% {target_cache, [{verbosity,silence}]},
-%% {symbolic_store, [{verbosity,silence}]},
-%% {local_db, [{repair,true},{auto_save,5000},{verbosity,silence}]},
-%% {error_report_module, snmpa_error_logger},
-%% {agent_type, master},
-%% {agent_verbosity, silence},
-%% {config, [{dir, "/home/eklajoh/tmp/snmp-config-2/a/"}, {force_load, true}, {verbosity, silence}]},
-%% {multi_threaded, false},
-%% {mib_server, [{mibentry_override,false},{trapentry_override,false},{verbosity,silence}]},
-%% {note_store, [{timeout,30000},{verbosity,silence}]},
-%% {net_if, [{module,snmpa_net_if},{verbosity,silence},{options,[{bind_to,true},{no_reuse,false},{req_limit,infinity}]}]}
-%% ]
-%% },
{manager,
[
{priority, normal},
{versions, [v1,v2,v3]},
- {config, [{dir, "/ldisk/bmk/tests/snmp/seq10689/m/conf"},
+ {config, [{dir, "%DIR%/manager/conf"},
{verbosity, trace},
- {db_dir, "/ldisk/bmk/tests/snmp/seq10689/m/db"},
+ {db_dir, "%DIR%/manager/db"},
{repair, true},
{auto_save, 5000}]},
{inform_request_behaviour, user},
@@ -37,15 +18,14 @@
{note_store, [{timeout,30000},
{verbosity,silence}]},
{audit_trail_log, [{type, read},
- {dir, "/ldisk/bmk/tests/snmp/seq10689/m/log"},
+ {dir, "%DIR%/manager/log"},
{size, {10240,10}}]},
{net_if, [{module,snmpm_net_if},
{verbosity, trace},
{options, [{bind_to, true},
{no_reuse, false},
% {sndbuf, 32000},
- {recbuf, 45000}
-]}]},
+ {recbuf, 45000}]}]},
{def_user_mod, snmpm_user_default},
{def_user_data, undefined}
]
diff --git a/lib/snmp/test/test_config/sys.config.src b/lib/snmp/test/test_config/sys.config.src
index 5a0fa0624b..7e4e3b0acd 100644
--- a/lib/snmp/test/test_config/sys.config.src
+++ b/lib/snmp/test/test_config/sys.config.src
@@ -1,11 +1,12 @@
-%% This file was generated by snmp_config (version-4.9.3) 2007-06-29 13:35:10
+%% This is an example sys config file for starting the snmp application
+%% with both an agent and a manager running.
[{snmp,
[
{agent,
[
{priority, normal},
{versions, [v2]},
- {db_dir, "/ldisk/bmk/tests/snmp/seq10689/a/db"},
+ {db_dir, "%DIR%/agent/db"},
{mib_storage, ets},
{agent_mib_storage, volatile},
{target_cache, [{verbosity,silence}]},
@@ -15,9 +16,9 @@
{agent_type, master},
{agent_verbosity, silence},
{audit_trail_log, [{type, read},
- {dir, "/ldisk/bmk/tests/snmp/seq10689/a/log"},
+ {dir, "%DIR%/agent/log"},
{size, {10240,10}}]},
- {config, [{dir, "/ldisk/bmk/tests/snmp/seq10689/a/conf"},
+ {config, [{dir, "%DIR%/agent/conf"},
{force_load, true},
{verbosity, silence}]},
{multi_threaded, false},
@@ -38,9 +39,9 @@
[
{priority, normal},
{versions, [v2]},
- {config, [{dir, "/ldisk/bmk/tests/snmp/seq10689/m/conf"},
+ {config, [{dir, "%DIR%/manager/conf"},
{verbosity, silence},
- {db_dir, "/ldisk/bmk/tests/snmp/seq10689/m/db"},
+ {db_dir, "%DIR%/manager/db"},
{repair, true},
{auto_save, 5000}]},
{inform_request_behaviour, auto},
@@ -50,7 +51,7 @@
{note_store, [{timeout, 30000},
{verbosity, silence}]},
{audit_trail_log, [{type, read},
- {dir, "/ldisk/bmk/tests/snmp/seq10689/m/log"},
+ {dir, "%DIR%/manager/log"},
{size, {10240,10}}]},
{net_if, [{module,snmpm_net_if},
{verbosity, silence},
diff --git a/lib/snmp/test/test_config/test_config.erl b/lib/snmp/test/test_config/test_config.erl
new file mode 100644
index 0000000000..2a94bf5e8d
--- /dev/null
+++ b/lib/snmp/test/test_config/test_config.erl
@@ -0,0 +1,27 @@
+%%
+%% %CopyrightBegin%
+%%
+%% Copyright Ericsson AB 2002-2010. 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
+%% compliance with the License. You should have received a copy of the
+%% Erlang Public License along with this software. If not, it can be
+%% retrieved online at http://www.erlang.org/.
+%%
+%% Software distributed under the License is distributed on an "AS IS"
+%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+%% the License for the specific language governing rights and limitations
+%% under the License.
+%%
+%% %CopyrightEnd%
+%%
+
+-module(test_config).
+
+-export([ip_address/0]).
+
+ip_address() ->
+ {ok, Hostname} = inet:gethostname(),
+ {ok, Address} = inet:getaddr(Hostname, inet),
+ io:format("~w", [tuple_to_list(Address)]).
--
cgit v1.2.3
From d49bdb7c372c93d5b8007cbc016a587d91539fe9 Mon Sep 17 00:00:00 2001
From: Micael Karlberg
Date: Fri, 10 Dec 2010 13:41:38 +0100
Subject: "Completed" sed'ing of config files.
---
lib/snmp/test/test_config/Makefile | 36 +++++++++++++++++-----
lib/snmp/test/test_config/agent/agent.conf.src | 1 -
lib/snmp/test/test_config/agent/community.conf.src | 1 -
lib/snmp/test/test_config/agent/context.conf.src | 1 -
lib/snmp/test/test_config/agent/notify.conf.src | 1 -
lib/snmp/test/test_config/agent/standard.conf.src | 15 +++++----
.../test/test_config/agent/target_addr.conf.src | 5 ++-
.../test/test_config/agent/target_params.conf.src | 1 -
lib/snmp/test/test_config/agent/vacm.conf.src | 1 -
lib/snmp/test/test_config/manager/manager.conf.src | 2 +-
lib/snmp/test/test_config/snmp_test_config.erl | 32 +++++++++++++++++++
lib/snmp/test/test_config/test_config.erl | 27 ----------------
12 files changed, 71 insertions(+), 52 deletions(-)
create mode 100644 lib/snmp/test/test_config/snmp_test_config.erl
delete mode 100644 lib/snmp/test/test_config/test_config.erl
(limited to 'lib')
diff --git a/lib/snmp/test/test_config/Makefile b/lib/snmp/test/test_config/Makefile
index 064c9f4689..446e7d8adf 100644
--- a/lib/snmp/test/test_config/Makefile
+++ b/lib/snmp/test/test_config/Makefile
@@ -68,7 +68,7 @@ RELSYSDIR = $(TESTROOT)
# ----------------------------------------------------
-# FLAGS
+# FLAGS AND VARIABLES
# ----------------------------------------------------
EBIN = .
@@ -77,9 +77,26 @@ ERL_COMPILE_FLAGS += +'{parse_transform,sys_pre_attributes}' \
+'{attribute,insert,app_vsn,$(APP_VSN)}'
ifeq ($(ADDR),)
-ADDR = $(shell erl -noshell -s test_config ip_address -s init stop)
+ADDR = $(shell erl -noshell -s snmp_test_config ip_address -s init stop)
endif
+ifeq ($(TARGET_NAME_PRE),)
+TARGET_NAME_PRE = $(shell erl -noshell -s snmp_test_config ip_address2 -s init stop)
+endif
+
+ifeq ($(SYS_CONTACT),)
+SYS_CONTACT = foo@bar.ericsson.se
+endif
+
+ifeq ($(SYS_LOCATION),)
+SYS_LOCATION = Erlang/OTP
+endif
+
+ifeq ($(SYS_NAME),)
+SYS_NAME = FOO
+endif
+
+
# ----------------------------------------------------
# Targets
@@ -94,15 +111,19 @@ clean:
docs:
-$(SYS_CONFIG_FILES): $(SYS_CONFIG_SRCS)
+%.config: %.config.src
@echo "$< -> $@"
$(PERL) -p -e 's?%DIR%?$(RELSYSDIR)? ' < $< > $@
-$(AGENT_CONFIG_FILES): $(AGENT_CONFIG_SRCS)
+agent/%.conf: agent/%.conf.src
@echo "$< -> $@"
- $(PERL) -p -e 's?%ADDR%?$(ADDR)? ' < $< > $@
+ sed -e 's?%ADDR%?$(ADDR)? ' \
+ -e 's?%SYS_CONTACT%?$(SYS_CONTACT)? ' \
+ -e 's?%SYS_LOCATION%?$(SYS_LOCATION)? ' \
+ -e 's?%SYS_NAME%?$(SYS_NAME)? ' \
+ -e 's?%TARGET_NAME_PRE%?$(TARGET_NAME_PRE)? ' < $< > $@
-$(MANAGER_CONFIG_FILES): $(MANAGER_CONFIG_SRCS)
+manager/%.conf: manager/%.conf.src
@echo "$< -> $@"
$(PERL) -p -e 's?%ADDR%?$(ADDR)? ' < $< > $@
@@ -153,7 +174,8 @@ info:
@echo "MANAGER_CONFIG_SRCS = $(MANAGER_CONFIG_SRCS)"
@echo "MANAGER_CONFIG_FILES = $(MANAGER_CONFIG_FILES)"
@echo ""
- @echo "ADDR = $(ADDR)"
+ @echo "ADDR = $(ADDR)"
+ @echo "TARGET_NAME_PRE = $(TARGET_NAME_PRE)"
@echo ""
diff --git a/lib/snmp/test/test_config/agent/agent.conf.src b/lib/snmp/test/test_config/agent/agent.conf.src
index 900e6a4282..2977cd49f8 100644
--- a/lib/snmp/test/test_config/agent/agent.conf.src
+++ b/lib/snmp/test/test_config/agent/agent.conf.src
@@ -1,4 +1,3 @@
-%% This file was generated by snmp_config (version-4.9.3) 2007-06-29 13:32:48
%% This file defines the Agent local configuration info
%% The data is inserted into the snmpEngine* variables defined
%% in SNMP-FRAMEWORK-MIB, and the intAgent* variables defined
diff --git a/lib/snmp/test/test_config/agent/community.conf.src b/lib/snmp/test/test_config/agent/community.conf.src
index 4661267950..8dccb929c9 100644
--- a/lib/snmp/test/test_config/agent/community.conf.src
+++ b/lib/snmp/test/test_config/agent/community.conf.src
@@ -1,4 +1,3 @@
-%% This file was generated by snmp_config (version-4.9.3) 2007-06-29 13:32:48
%% This file defines the community info which maps to VACM parameters.
%% The data is inserted into the snmpCommunityTable defined
%% in SNMP-COMMUNITY-MIB.
diff --git a/lib/snmp/test/test_config/agent/context.conf.src b/lib/snmp/test/test_config/agent/context.conf.src
index 56000d0308..ea8b5a97eb 100644
--- a/lib/snmp/test/test_config/agent/context.conf.src
+++ b/lib/snmp/test/test_config/agent/context.conf.src
@@ -1,4 +1,3 @@
-%% This file was generated by snmp_config (version-4.9.3) 2007-06-29 13:32:48
%% This file defines the contexts known to the agent.
%% The data is inserted into the vacmContextTable defined
%% in SNMP-VIEW-BASED-ACM-MIB.
diff --git a/lib/snmp/test/test_config/agent/notify.conf.src b/lib/snmp/test/test_config/agent/notify.conf.src
index b63668f4fd..164fd25b95 100644
--- a/lib/snmp/test/test_config/agent/notify.conf.src
+++ b/lib/snmp/test/test_config/agent/notify.conf.src
@@ -1,4 +1,3 @@
-%% This file was generated by snmp_config (version-4.9.3) 2007-06-29 13:32:48
%% This file defines the notification parameters.
%% The data is inserted into the snmpNotifyTable defined
%% in SNMP-NOTIFICATION-MIB.
diff --git a/lib/snmp/test/test_config/agent/standard.conf.src b/lib/snmp/test/test_config/agent/standard.conf.src
index 9bcca18b5e..31e04e7695 100644
--- a/lib/snmp/test/test_config/agent/standard.conf.src
+++ b/lib/snmp/test/test_config/agent/standard.conf.src
@@ -1,11 +1,10 @@
-%% This file was generated by snmp_config (version-4.9.3) 2007-06-29 13:32:48
%% This file defines the STANDARD-MIB info.
%% Each row is a 2-tuple:
%% {StandardVariable, Value}.
%% For example
%% {sysDescr, "Erlang SNMP agent"}.
%% {sysObjectID, [1,2,3]}.
-%% {sysContact, "{mbj,eklas}@erlang.ericsson.se"}.
+%% {sysContact, "foo@bar.ericsson.se"}.
%% {sysName, "test"}.
%% {sysLocation, "erlang"}.
%% {sysServices, 72}.
@@ -13,10 +12,10 @@
%%
-{sysDescr, "Erlang SNMP agent"}.
-{sysObjectID, [1,2,3]}.
-{sysContact, "{mbj,eklas}@erlang.ericsson.se"}.
-{sysLocation, "erlang"}.
-{sysServices, 72}.
+{sysDescr, "Erlang SNMP agent"}.
+{sysObjectID, [1,2,3]}.
+{sysContact, "%SYS_CONTACT%"}.
+{sysLocation, "%SYS_LOCATION%"}.
+{sysServices, 72}.
{snmpEnableAuthenTraps, disabled}.
-{sysName, "foo"}.
+{sysName, "%SYS_NAME%"}.
diff --git a/lib/snmp/test/test_config/agent/target_addr.conf.src b/lib/snmp/test/test_config/agent/target_addr.conf.src
index 2c7a6a15ad..740df74ecf 100644
--- a/lib/snmp/test/test_config/agent/target_addr.conf.src
+++ b/lib/snmp/test/test_config/agent/target_addr.conf.src
@@ -1,4 +1,3 @@
-%% This file was generated by snmp_config (version-4.9.3) 2007-06-29 13:32:48
%% This file defines the target address parameters.
%% The data is inserted into the snmpTargetAddrTable defined
%% in SNMP-TARGET-MIB, and in the snmpTargetAddrExtTable defined
@@ -18,5 +17,5 @@
%%
-{"127.0.0.1 v2", [127,0,0,1], 5000, 1500, 3, "std_trap", "target_v2", "", [], 2048}.
-{"127.0.0.1 v2.2", [127,0,0,1], 5000, 1500, 3, "std_inform", "target_v2", "", [], 2048}.
+{"%TARGET_NAME_PRE% v2", %ADDR%, 5000, 1500, 3, "std_trap", "target_v2", "", [], 2048}.
+{"%TARGET_NAME_PRE% v2.2", %ADDR%, 5000, 1500, 3, "std_inform", "target_v2", "", [], 2048}.
diff --git a/lib/snmp/test/test_config/agent/target_params.conf.src b/lib/snmp/test/test_config/agent/target_params.conf.src
index 8e89b91d81..a4a535baa2 100644
--- a/lib/snmp/test/test_config/agent/target_params.conf.src
+++ b/lib/snmp/test/test_config/agent/target_params.conf.src
@@ -1,4 +1,3 @@
-%% This file was generated by snmp_config (version-4.9.3) 2007-06-29 13:32:48
%% This file defines the target parameters.
%% The data is inserted into the snmpTargetParamsTable defined
%% in SNMP-TARGET-MIB.
diff --git a/lib/snmp/test/test_config/agent/vacm.conf.src b/lib/snmp/test/test_config/agent/vacm.conf.src
index c7dc5170c2..86271443ad 100644
--- a/lib/snmp/test/test_config/agent/vacm.conf.src
+++ b/lib/snmp/test/test_config/agent/vacm.conf.src
@@ -1,4 +1,3 @@
-%% This file was generated by snmp_config (version-4.9.3) 2007-06-29 13:32:48
%% This file defines the Mib Views.
%% The data is inserted into the vacm* tables defined
%% in SNMP-VIEW-BASED-ACM-MIB.
diff --git a/lib/snmp/test/test_config/manager/manager.conf.src b/lib/snmp/test/test_config/manager/manager.conf.src
index 164e5507c6..7d4104ded2 100644
--- a/lib/snmp/test/test_config/manager/manager.conf.src
+++ b/lib/snmp/test/test_config/manager/manager.conf.src
@@ -11,6 +11,6 @@
{port, 5000}.
-{address, [127,0,0,1]}.
+{address, %ADDR%}.
{engine_id, "foo"}.
{max_message_size, 484}.
diff --git a/lib/snmp/test/test_config/snmp_test_config.erl b/lib/snmp/test/test_config/snmp_test_config.erl
new file mode 100644
index 0000000000..8d2005d061
--- /dev/null
+++ b/lib/snmp/test/test_config/snmp_test_config.erl
@@ -0,0 +1,32 @@
+%%
+%% %CopyrightBegin%
+%%
+%% Copyright Ericsson AB 2002-2010. 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
+%% compliance with the License. You should have received a copy of the
+%% Erlang Public License along with this software. If not, it can be
+%% retrieved online at http://www.erlang.org/.
+%%
+%% Software distributed under the License is distributed on an "AS IS"
+%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+%% the License for the specific language governing rights and limitations
+%% under the License.
+%%
+%% %CopyrightEnd%
+%%
+
+-module(test_config).
+
+-export([ip_address/0, ip_address2/0]).
+
+ip_address() ->
+ {ok, Hostname} = inet:gethostname(),
+ {ok, Address} = inet:getaddr(Hostname, inet),
+ io:format("~w", [tuple_to_list(Address)]).
+
+ip_address2() ->
+ {ok, Hostname} = inet:gethostname(),
+ {ok, {A1, A2, A3, A4}} = inet:getaddr(Hostname, inet),
+ io:format("~w.~w.~w.~w", [A1, A2, A3, A4]).
diff --git a/lib/snmp/test/test_config/test_config.erl b/lib/snmp/test/test_config/test_config.erl
deleted file mode 100644
index 2a94bf5e8d..0000000000
--- a/lib/snmp/test/test_config/test_config.erl
+++ /dev/null
@@ -1,27 +0,0 @@
-%%
-%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 2002-2010. 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
-%% compliance with the License. You should have received a copy of the
-%% Erlang Public License along with this software. If not, it can be
-%% retrieved online at http://www.erlang.org/.
-%%
-%% Software distributed under the License is distributed on an "AS IS"
-%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
-%% the License for the specific language governing rights and limitations
-%% under the License.
-%%
-%% %CopyrightEnd%
-%%
-
--module(test_config).
-
--export([ip_address/0]).
-
-ip_address() ->
- {ok, Hostname} = inet:gethostname(),
- {ok, Address} = inet:getaddr(Hostname, inet),
- io:format("~w", [tuple_to_list(Address)]).
--
cgit v1.2.3
From 58620c2052e07490beb44a4bd1a8fbb5ebc028ac Mon Sep 17 00:00:00 2001
From: Micael Karlberg
Date: Fri, 10 Dec 2010 14:17:30 +0100
Subject: Various cosmetic (print) fixes. Wrong module names used for the
utility module in the test_config dir.
---
lib/snmp/src/agent/snmp_community_mib.erl | 4 +++-
lib/snmp/src/agent/snmpa.erl | 7 +++++--
lib/snmp/src/agent/snmpa_mib_lib.erl | 9 ++++++---
lib/snmp/test/test_config/Makefile | 2 --
lib/snmp/test/test_config/modules.mk | 2 +-
lib/snmp/test/test_config/snmp_test_config.erl | 2 +-
6 files changed, 16 insertions(+), 10 deletions(-)
(limited to 'lib')
diff --git a/lib/snmp/src/agent/snmp_community_mib.erl b/lib/snmp/src/agent/snmp_community_mib.erl
index 8f0f4cad73..5644a43345 100644
--- a/lib/snmp/src/agent/snmp_community_mib.erl
+++ b/lib/snmp/src/agent/snmp_community_mib.erl
@@ -336,6 +336,8 @@ get_target_addr_ext_mms(TDomain, TAddress, Key) ->
get_target_addr_ext_mms(TDomain, TAddress, NextKey)
end
end.
+
+
%%-----------------------------------------------------------------
%% Instrumentation Functions
%%-----------------------------------------------------------------
@@ -347,7 +349,7 @@ snmpCommunityTable(print) ->
PrintRow =
fun(Prefix, Row) ->
lists:flatten(
- io_lib:format("~sIndex: ~p"
+ io_lib:format("~sIndex: ~p"
"~n~sName: ~p"
"~n~sSecurityName: ~p"
"~n~sContextEngineID: ~p"
diff --git a/lib/snmp/src/agent/snmpa.erl b/lib/snmp/src/agent/snmpa.erl
index 8ad2a83de4..c09435c03b 100644
--- a/lib/snmp/src/agent/snmpa.erl
+++ b/lib/snmp/src/agent/snmpa.erl
@@ -326,6 +326,9 @@ print_mib_info() ->
MibsInfo = mibs_info(),
print_mib_info(MibsInfo).
+print_mib_info([]) ->
+ io:format("~n", []),
+ ok;
print_mib_info([{Mod, Tables, Variables} | MibsInfo]) ->
io:format("~n** ~s ** ~n~n", [make_pretty_mib(Mod)]),
print_mib_variables2(Mod, Variables),
@@ -379,9 +382,9 @@ make_pretty_mib(snmp_view_based_acm_mib) ->
"SNMP-VIEW-BASED-ACM-MIB";
make_pretty_mib(snmp_target_mib) ->
"SNMP-TARGET-MIB";
-make_pretty_mib(snmp_target_mib) ->
+make_pretty_mib(snmp_community_mib) ->
"SNMP-COMMUNITY-MIB";
-make_pretty_mib(snmp_target_mib) ->
+make_pretty_mib(snmp_notification_mib) ->
"SNMP-NOTIFICATION-MIB";
make_pretty_mib(snmp_target_mib) ->
"SNMP-USER-BASED-SM-MIB";
diff --git a/lib/snmp/src/agent/snmpa_mib_lib.erl b/lib/snmp/src/agent/snmpa_mib_lib.erl
index 22057b4547..700bdd1a6e 100644
--- a/lib/snmp/src/agent/snmpa_mib_lib.erl
+++ b/lib/snmp/src/agent/snmpa_mib_lib.erl
@@ -90,9 +90,9 @@ print_variables(Variables) when is_list(Variables) ->
ok.
print_variable(Variable, {value, Val}, Prefix) when is_atom(Variable) ->
- io:format("~w~s => ~p~n", [Variable, Prefix, Val]);
+ io:format("~w~s=> ~p~n", [Variable, Prefix, Val]);
print_variable(Variable, Error, Prefix) when is_atom(Variable) ->
- io:format("~w~s => ERROR: ~p~n", [Variable, Prefix, Error]).
+ io:format("~w~s=> [e] ~p~n", [Variable, Prefix, Error]).
print_variables_prefixify(Variables) ->
MaxVarLength = print_variables_maxlength(Variables),
@@ -139,10 +139,13 @@ print_table(Table, DB, FOI, PrintRow) ->
print_table(Table, TableInfo, PrintRow).
print_table(Table, TableInfo, PrintRow) when is_function(PrintRow, 2) ->
- io:format("~w => ~n", [Table]),
+ io:format("~w =>", [Table]),
do_print_table(TableInfo, PrintRow).
+do_print_table({ok, [] = _TableInfo}, _PrintRow) ->
+ io:format(" -~n", []);
do_print_table({ok, TableInfo}, PrintRow) when is_function(PrintRow, 2) ->
+ io:format("~n", []),
lists:foreach(fun({RowIdx, Row}) ->
io:format(" ~w => ~n~s~n",
[RowIdx, PrintRow(" ", Row)])
diff --git a/lib/snmp/test/test_config/Makefile b/lib/snmp/test/test_config/Makefile
index 446e7d8adf..c02bb5c601 100644
--- a/lib/snmp/test/test_config/Makefile
+++ b/lib/snmp/test/test_config/Makefile
@@ -32,8 +32,6 @@ VSN = $(SNMP_VSN)
# ----------------------------------------------------
# Configured variables
# ----------------------------------------------------
-# PERL = @PERL@
-PERL = perl
# ----------------------------------------------------
diff --git a/lib/snmp/test/test_config/modules.mk b/lib/snmp/test/test_config/modules.mk
index 956bb54af3..ee8b68d4eb 100644
--- a/lib/snmp/test/test_config/modules.mk
+++ b/lib/snmp/test/test_config/modules.mk
@@ -37,4 +37,4 @@ MANAGER_CONFIG_FILES = \
manager/usm.conf
MODULES = \
- test_config
+ snmp_test_config
diff --git a/lib/snmp/test/test_config/snmp_test_config.erl b/lib/snmp/test/test_config/snmp_test_config.erl
index 8d2005d061..550a276c4c 100644
--- a/lib/snmp/test/test_config/snmp_test_config.erl
+++ b/lib/snmp/test/test_config/snmp_test_config.erl
@@ -17,7 +17,7 @@
%% %CopyrightEnd%
%%
--module(test_config).
+-module(snmp_test_config).
-export([ip_address/0, ip_address2/0]).
--
cgit v1.2.3
From fee3f48c37432c7ea28f2e8c9eb4eacac4422db9 Mon Sep 17 00:00:00 2001
From: Micael Karlberg
Date: Fri, 10 Dec 2010 15:54:25 +0100
Subject: Added variables from STANDARD-MIB (including counters). Also some
minor fixes.
---
lib/snmp/src/agent/snmp_standard_mib.erl | 266 ++++++++++++++++++++++++++
lib/snmp/src/agent/snmp_target_mib.erl | 4 +
lib/snmp/src/agent/snmp_user_based_sm_mib.erl | 5 +
lib/snmp/src/agent/snmpa.erl | 57 +++++-
4 files changed, 327 insertions(+), 5 deletions(-)
(limited to 'lib')
diff --git a/lib/snmp/src/agent/snmp_standard_mib.erl b/lib/snmp/src/agent/snmp_standard_mib.erl
index 639172401d..7292d5b98e 100644
--- a/lib/snmp/src/agent/snmp_standard_mib.erl
+++ b/lib/snmp/src/agent/snmp_standard_mib.erl
@@ -40,6 +40,28 @@
sys_object_id/1, sys_object_id/2, sys_or_table/3,
variable_func/1, variable_func/2,
inc/1, inc/2]).
+-export([sysDescr/1, sysContact/1, sysName/1, sysLocation/1,
+ sysServices/1, sysUpTime/1, snmpEnableAuthenTraps/1,
+ sysObjectID/1,
+ snmpInPkts/1, snmpOutPkts/1,
+ snmpInBadVersions/1,
+ snmpInBadCommunityNames/1, snmpInBadCommunityUses/1,
+ snmpInASNParseErrs/1,
+ snmpInTooBigs/1,
+ snmpInNoSuchNames/1, snmpInBadValues/1,
+ snmpInReadOnlys/1, snmpInGenErrs/1,
+ snmpInTotalReqVars/1, snmpInTotalSetVars/1,
+ snmpInGetRequests/1, snmpInSetRequests/1,
+ snmpInGetNexts/1,
+ snmpInGetResponses/1, snmpInTraps/1,
+ snmpOutTooBigs/1,
+ snmpOutNoSuchNames/1,
+ snmpOutBadValues/1,
+ snmpOutGenErrs/1,
+ snmpOutGetRequests/1, snmpOutSetRequests/1,
+ snmpOutGetNexts/1,
+ snmpOutGetResponses/1,
+ snmpOutTraps/1]).
-export([dummy/1, snmp_set_serial_no/1, snmp_set_serial_no/2]).
-export([add_agent_caps/2, del_agent_caps/1, get_agent_caps/0]).
-export([check_standard/1]).
@@ -202,18 +224,252 @@ variable_func(get, Name) ->
inc(Name) -> inc(Name, 1).
inc(Name, N) -> ets:update_counter(snmp_agent_table, Name, N).
+
+sysDescr(print) ->
+ VarAndValue = [{sysDescr, sysDescr(get)}],
+ snmpa_mib_lib:print_variables(VarAndValue);
+
+sysDescr(get) ->
+ VarDB = db(sysDescr),
+ snmp_generic:variable_get(VarDB).
+
+
+sysContact(print) ->
+ VarAndValue = [{sysContact, sysContact(get)}],
+ snmpa_mib_lib:print_variables(VarAndValue);
+
+sysContact(get) ->
+ VarDB = db(sysContact),
+ snmp_generic:variable_get(VarDB).
+
+
+sysName(print) ->
+ VarAndValue = [{sysName, sysName(get)}],
+ snmpa_mib_lib:print_variables(VarAndValue);
+
+sysName(get) ->
+ VarDB = db(sysName),
+ snmp_generic:variable_get(VarDB).
+
+
+sysLocation(print) ->
+ VarAndValue = [{sysLocation, sysLocation(get)}],
+ snmpa_mib_lib:print_variables(VarAndValue);
+
+sysLocation(get) ->
+ VarDB = db(sysLocation),
+ snmp_generic:variable_get(VarDB).
+
+
+sysServices(print) ->
+ VarAndValue = [{sysServices, sysServices(get)}],
+ snmpa_mib_lib:print_variables(VarAndValue);
+
+sysServices(get) ->
+ VarDB = db(sysServices),
+ snmp_generic:variable_get(VarDB).
+
+
+snmpInPkts(print) ->
+ gen_counter(print, snmpInPkts);
+snmpInPkts(get) ->
+ gen_counter(get, snmpInPkts).
+
+
+snmpOutPkts(print) ->
+ gen_counter(print, snmpOutPkts);
+snmpOutPkts(get) ->
+ gen_counter(get, snmpOutPkts).
+
+
+snmpInASNParseErrs(print) ->
+ gen_counter(print, snmpInASNParseErrs);
+snmpInASNParseErrs(get) ->
+ gen_counter(get, snmpInASNParseErrs).
+
+
+snmpInBadCommunityNames(print) ->
+ gen_counter(print, snmpInBadCommunityNames);
+snmpInBadCommunityNames(get) ->
+ gen_counter(get, snmpInBadCommunityNames).
+
+
+snmpInBadCommunityUses(print) ->
+ gen_counter(print, snmpInBadCommunityUses);
+
+snmpInBadCommunityUses(get) ->
+ gen_counter(get, snmpInBadCommunityUses).
+
+
+snmpInBadVersions(print) ->
+ gen_counter(print, snmpInBadVersions);
+snmpInBadVersions(get) ->
+ gen_counter(get, snmpInBadVersions).
+
+
+snmpInTooBigs(print) ->
+ gen_counter(print, snmpInTooBigs);
+snmpInTooBigs(get) ->
+ gen_counter(get, snmpInTooBigs).
+
+
+snmpInNoSuchNames(print) ->
+ gen_counter(print, snmpInNoSuchNames);
+snmpInNoSuchNames(get) ->
+ gen_counter(get, snmpInNoSuchNames).
+
+
+snmpInBadValues(print) ->
+ gen_counter(print, snmpInBadValues);
+snmpInBadValues(get) ->
+ gen_counter(get, snmpInBadValues).
+
+
+snmpInReadOnlys(print) ->
+ gen_counter(print, snmpInReadOnlys);
+snmpInReadOnlys(get) ->
+ gen_counter(get, snmpInReadOnlys).
+
+
+snmpInGenErrs(print) ->
+ gen_counter(print, snmpInGenErrs);
+snmpInGenErrs(get) ->
+ gen_counter(get, snmpInGenErrs).
+
+
+snmpInTotalReqVars(print) ->
+ gen_counter(print, snmpInTotalReqVars);
+snmpInTotalReqVars(get) ->
+ gen_counter(get, snmpInTotalReqVars).
+
+
+snmpInTotalSetVars(print) ->
+ gen_counter(print, snmpInTotalSetVars);
+snmpInTotalSetVars(get) ->
+ gen_counter(get, snmpInTotalSetVars).
+
+
+snmpInGetRequests(print) ->
+ gen_counter(print, snmpInGetRequests);
+snmpInGetRequests(get) ->
+ gen_counter(get, snmpInGetRequests).
+
+
+snmpInSetRequests(print) ->
+ gen_counter(print, snmpInSetRequests);
+snmpInSetRequests(get) ->
+ gen_counter(get, snmpInSetRequests).
+
+
+snmpInGetNexts(print) ->
+ gen_counter(print, snmpInGetNexts);
+snmpInGetNexts(get) ->
+ gen_counter(get, snmpInGetNexts).
+
+
+snmpInGetResponses(print) ->
+ gen_counter(print, snmpInGetResponses);
+snmpInGetResponses(get) ->
+ gen_counter(get, snmpInGetResponses).
+
+
+snmpInTraps(print) ->
+ gen_counter(print, snmpInTraps);
+snmpInTraps(get) ->
+ gen_counter(get, snmpInTraps).
+
+
+snmpOutTooBigs(print) ->
+ gen_counter(print, snmpOutTooBigs);
+snmpOutTooBigs(get) ->
+ gen_counter(get, snmpOutTooBigs).
+
+
+snmpOutNoSuchNames(print) ->
+ gen_counter(print, snmpOutNoSuchNames);
+snmpOutNoSuchNames(get) ->
+ gen_counter(get, snmpOutNoSuchNames).
+
+
+snmpOutBadValues(print) ->
+ gen_counter(print, snmpOutBadValues);
+snmpOutBadValues(get) ->
+ gen_counter(get, snmpOutBadValues).
+
+
+snmpOutGenErrs(print) ->
+ gen_counter(print, snmpOutGenErrs);
+snmpOutGenErrs(get) ->
+ gen_counter(get, snmpOutGenErrs).
+
+
+snmpOutGetRequests(print) ->
+ gen_counter(print, snmpOutGetRequests);
+snmpOutGetRequests(get) ->
+ gen_counter(get, snmpOutGetRequests).
+
+
+snmpOutSetRequests(print) ->
+ gen_counter(print, snmpOutSetRequests);
+snmpOutSetRequests(get) ->
+ gen_counter(get, snmpOutSetRequests).
+
+
+snmpOutGetNexts(print) ->
+ gen_counter(print, snmpOutGetNexts);
+snmpOutGetNexts(get) ->
+ gen_counter(get, snmpOutGetNexts).
+
+
+snmpOutGetResponses(print) ->
+ gen_counter(print, snmpOutGetResponses);
+snmpOutGetResponses(get) ->
+ gen_counter(get, snmpOutGetResponses).
+
+
+snmpOutTraps(print) ->
+ gen_counter(print, snmpOutTraps);
+snmpOutTraps(get) ->
+ gen_counter(get, snmpOutTraps).
+
+
+gen_counter(print, Counter) ->
+ Val = gen_counter(get, Counter),
+ VarAndValue = [{Counter, Val}],
+ snmpa_mib_lib:print_variables(VarAndValue);
+
+gen_counter(get, Counter) ->
+ variable_func(get, Counter).
+
+
%%-----------------------------------------------------------------
%% This is the instrumentation function for sysUpTime.
%%-----------------------------------------------------------------
+sysUpTime(print) ->
+ sys_up_time(print).
+
sys_up_time() ->
snmpa:sys_up_time().
+sys_up_time(print) ->
+ VarAndValue = [{sysUpTime, sys_up_time(get)}],
+ snmpa_mib_lib:print_variables(VarAndValue);
+
sys_up_time(get) ->
{value, snmpa:sys_up_time()}.
+
%%-----------------------------------------------------------------
%% This is the instrumentation function for snmpEnableAuthenTraps
%%-----------------------------------------------------------------
+
+snmpEnableAuthenTraps(print) ->
+ snmp_enable_authen_traps(print).
+
+snmp_enable_authen_traps(print) ->
+ VarAndValue = [{snmpEnableAuthenTraps, snmp_enable_authen_traps(get)}],
+ snmpa_mib_lib:print_variables(VarAndValue);
+
snmp_enable_authen_traps(new) ->
snmp_generic:variable_func(new, db(snmpEnableAuthenTraps));
@@ -226,9 +482,17 @@ snmp_enable_authen_traps(get) ->
snmp_enable_authen_traps(set, NewVal) ->
snmp_generic:variable_func(set, NewVal, db(snmpEnableAuthenTraps)).
+
%%-----------------------------------------------------------------
%% This is the instrumentation function for sysObjectId
%%-----------------------------------------------------------------
+sysObjectID(print) ->
+ sys_object_id(print).
+
+sys_object_id(print) ->
+ VarAndValue = [{sysObjectID, sys_object_id(get)}],
+ snmpa_mib_lib:print_variables(VarAndValue);
+
sys_object_id(new) ->
snmp_generic:variable_func(new, db(sysObjectID));
@@ -241,6 +505,7 @@ sys_object_id(get) ->
sys_object_id(set, NewVal) ->
snmp_generic:variable_func(set, NewVal, db(sysObjectID)).
+
%%-----------------------------------------------------------------
%% This is a dummy instrumentation function for objects like
%% snmpTrapOID, that is accessible-for-notify, with different
@@ -249,6 +514,7 @@ sys_object_id(set, NewVal) ->
%%-----------------------------------------------------------------
dummy(_Op) -> ok.
+
%%-----------------------------------------------------------------
%% This is the instrumentation function for snmpSetSerialNo.
%% It is always volatile.
diff --git a/lib/snmp/src/agent/snmp_target_mib.erl b/lib/snmp/src/agent/snmp_target_mib.erl
index 033dfdd92e..270a5fd5b6 100644
--- a/lib/snmp/src/agent/snmp_target_mib.erl
+++ b/lib/snmp/src/agent/snmp_target_mib.erl
@@ -511,6 +511,10 @@ set_target_engine_id(TargetAddrName, EngineId) ->
%%-----------------------------------------------------------------
%% Instrumentation Functions
%%-----------------------------------------------------------------
+snmpTargetSpinLock(print) ->
+ VarAndValue = [{snmpTargetSpinLock, snmpTargetSpinLock(get)}],
+ snmpa_mib_lib:print_variables(VarAndValue);
+
snmpTargetSpinLock(new) ->
snmp_generic:variable_func(new, {snmpTargetSpinLock, volatile}),
{A1,A2,A3} = erlang:now(),
diff --git a/lib/snmp/src/agent/snmp_user_based_sm_mib.erl b/lib/snmp/src/agent/snmp_user_based_sm_mib.erl
index f40bb1a5b9..4c3f27c4ef 100644
--- a/lib/snmp/src/agent/snmp_user_based_sm_mib.erl
+++ b/lib/snmp/src/agent/snmp_user_based_sm_mib.erl
@@ -374,6 +374,11 @@ get_user_from_security_name(EngineID, SecName) ->
%%-----------------------------------------------------------------
%% Instrumentation Functions
%%-----------------------------------------------------------------
+
+usmUserSpinLock(print) ->
+ VarAndValue = [{usmUserSpinLock, usmUserSpinLock(get)}],
+ snmpa_mib_lib:print_variables(VarAndValue);
+
usmUserSpinLock(new) ->
snmp_generic:variable_func(new, {usmUserSpinLock, volatile}),
{A1,A2,A3} = erlang:now(),
diff --git a/lib/snmp/src/agent/snmpa.erl b/lib/snmp/src/agent/snmpa.erl
index c09435c03b..8ca057892c 100644
--- a/lib/snmp/src/agent/snmpa.erl
+++ b/lib/snmp/src/agent/snmpa.erl
@@ -287,6 +287,46 @@ whereis_mib(Agent, Mib) when is_atom(Mib) ->
mibs_info() ->
[
+ {snmp_standard_mib,
+ [],
+ [
+ sysDescr,
+ sysObjectID,
+ sysContact,
+ sysName,
+ sysLocation,
+ sysServices,
+ snmpEnableAuthenTraps,
+ sysUpTime,
+ snmpInPkts,
+ snmpOutPkts,
+ snmpInBadVersions,
+ snmpInBadCommunityNames,
+ snmpInBadCommunityUses,
+ snmpInASNParseErrs,
+ snmpInTooBigs,
+ snmpInNoSuchNames,
+ snmpInBadValues,
+ snmpInReadOnlys,
+ snmpInGenErrs,
+ snmpInTotalReqVars,
+ snmpInTotalSetVars,
+ snmpInGetRequests,
+ snmpInSetRequests,
+ snmpInGetNexts,
+ snmpInGetResponses,
+ snmpInTraps,
+ snmpOutTooBigs,
+ snmpOutNoSuchNames,
+ snmpOutBadValues,
+ snmpOutGenErrs,
+ snmpOutGetRequests,
+ snmpOutSetRequests,
+ snmpOutGetNexts,
+ snmpOutGetResponses,
+ snmpOutTraps
+ ]
+ },
{snmp_view_based_acm_mib,
[
vacmAccessTable,
@@ -295,7 +335,8 @@ mibs_info() ->
],
[
vacmViewSpinLock
- ]},
+ ]
+ },
{snmp_target_mib,
[
snmpTargetAddrTable,
@@ -303,12 +344,14 @@ mibs_info() ->
],
[
snmpTargetSpinLock
- ]},
+ ]
+ },
{snmp_community_mib,
[
snmpCommunityTable
],
- []},
+ []
+ },
{snmp_notification_mib,
[
snmpNotifyTable
@@ -320,7 +363,9 @@ mibs_info() ->
],
[
usmUserSpinLock
- ]}].
+ ]
+ }
+ ].
print_mib_info() ->
MibsInfo = mibs_info(),
@@ -386,8 +431,10 @@ make_pretty_mib(snmp_community_mib) ->
"SNMP-COMMUNITY-MIB";
make_pretty_mib(snmp_notification_mib) ->
"SNMP-NOTIFICATION-MIB";
-make_pretty_mib(snmp_target_mib) ->
+make_pretty_mib(snmp_user_based_sm_mib) ->
"SNMP-USER-BASED-SM-MIB";
+make_pretty_mib(snmp_standard_mib) ->
+ "STANDARD-MIB";
make_pretty_mib(Mod) ->
atom_to_list(Mod).
--
cgit v1.2.3
From a0e4728a5e8e366c83e8229cefc63ba92151a86d Mon Sep 17 00:00:00 2001
From: Micael Karlberg
Date: Fri, 10 Dec 2010 16:21:08 +0100
Subject: Cosmetic stuff (when to newline, intending, ..).
---
lib/snmp/src/agent/snmp_standard_mib.erl | 15 +++++++++++----
lib/snmp/src/agent/snmpa.erl | 14 +++++++++++---
lib/snmp/src/agent/snmpa_mib_lib.erl | 8 +-------
3 files changed, 23 insertions(+), 14 deletions(-)
(limited to 'lib')
diff --git a/lib/snmp/src/agent/snmp_standard_mib.erl b/lib/snmp/src/agent/snmp_standard_mib.erl
index 7292d5b98e..b6834d278c 100644
--- a/lib/snmp/src/agent/snmp_standard_mib.erl
+++ b/lib/snmp/src/agent/snmp_standard_mib.erl
@@ -446,7 +446,9 @@ gen_counter(get, Counter) ->
%% This is the instrumentation function for sysUpTime.
%%-----------------------------------------------------------------
sysUpTime(print) ->
- sys_up_time(print).
+ sys_up_time(print);
+sysUpTime(get) ->
+ sys_up_time(get).
sys_up_time() ->
snmpa:sys_up_time().
@@ -464,7 +466,10 @@ sys_up_time(get) ->
%%-----------------------------------------------------------------
snmpEnableAuthenTraps(print) ->
- snmp_enable_authen_traps(print).
+ snmp_enable_authen_traps(print);
+snmpEnableAuthenTraps(get) ->
+ snmp_enable_authen_traps(get).
+
snmp_enable_authen_traps(print) ->
VarAndValue = [{snmpEnableAuthenTraps, snmp_enable_authen_traps(get)}],
@@ -484,10 +489,12 @@ snmp_enable_authen_traps(set, NewVal) ->
%%-----------------------------------------------------------------
-%% This is the instrumentation function for sysObjectId
+%% This is the instrumentation function for sysObjectID
%%-----------------------------------------------------------------
sysObjectID(print) ->
- sys_object_id(print).
+ sys_object_id(print);
+sysObjectID(get) ->
+ sys_object_id(get).
sys_object_id(print) ->
VarAndValue = [{sysObjectID, sys_object_id(get)}],
diff --git a/lib/snmp/src/agent/snmpa.erl b/lib/snmp/src/agent/snmpa.erl
index 8ca057892c..3c214874fe 100644
--- a/lib/snmp/src/agent/snmpa.erl
+++ b/lib/snmp/src/agent/snmpa.erl
@@ -378,6 +378,7 @@ print_mib_info([{Mod, Tables, Variables} | MibsInfo]) ->
io:format("~n** ~s ** ~n~n", [make_pretty_mib(Mod)]),
print_mib_variables2(Mod, Variables),
print_mib_tables2(Mod, Tables),
+ io:format("~n", []),
print_mib_info(MibsInfo).
@@ -394,9 +395,12 @@ print_mib_tables([{Mod, Tabs}|MibTabs])
print_mib_tables([_|MibTabs]) ->
print_mib_tables(MibTabs).
+print_mib_tables(_Mod, [] = _Tables) ->
+ ok;
print_mib_tables(Mod, Tables) ->
io:format("~n** ~s ** ~n~n", [make_pretty_mib(Mod)]),
- print_mib_tables2(Mod, Tables).
+ print_mib_tables2(Mod, Tables),
+ io:format("~n", []).
print_mib_tables2(Mod, Tables) ->
[(catch Mod:Table(print)) || Table <- Tables].
@@ -415,12 +419,16 @@ print_mib_variables([{Mod, Vars}|MibVars])
print_mib_variables([_|MibVars]) ->
print_mib_variables(MibVars).
+print_mib_variables(_Mod, [] = _Vars) ->
+ ok;
print_mib_variables(Mod, Vars) ->
io:format("~n** ~s ** ~n~n", [make_pretty_mib(Mod)]),
- print_mib_variables2(Mod, Vars).
+ print_mib_variables2(Mod, Vars),
+ io:format("~n", []).
print_mib_variables2(Mod, Variables) ->
- [(catch Mod:Variable(print)) || Variable <- Variables].
+ Vars = [{Var, (catch Mod:Var(get))} || Var <- Variables],
+ snmpa_mib_lib:print_variables(Vars).
make_pretty_mib(snmp_view_based_acm_mib) ->
diff --git a/lib/snmp/src/agent/snmpa_mib_lib.erl b/lib/snmp/src/agent/snmpa_mib_lib.erl
index 700bdd1a6e..cb96ff8056 100644
--- a/lib/snmp/src/agent/snmpa_mib_lib.erl
+++ b/lib/snmp/src/agent/snmpa_mib_lib.erl
@@ -129,11 +129,6 @@ print_tables(Tables) when is_list(Tables) ->
end, Tables),
ok.
-%% print_table(Table, DB, FOI, PrintRow) ->
-%% TableInfo = get_table(DB(Table), FOI(Table)),
-%% print_table(Table, TableInfo, PrintRow),
-%% ok.
-
print_table(Table, DB, FOI, PrintRow) ->
TableInfo = get_table(DB, FOI),
print_table(Table, TableInfo, PrintRow).
@@ -149,8 +144,7 @@ do_print_table({ok, TableInfo}, PrintRow) when is_function(PrintRow, 2) ->
lists:foreach(fun({RowIdx, Row}) ->
io:format(" ~w => ~n~s~n",
[RowIdx, PrintRow(" ", Row)])
- end, TableInfo),
- io:format("~n", []);
+ end, TableInfo);
do_print_table({error, {invalid_rowindex, BadRowIndex, []}}, _PrintRow) ->
io:format("Error: Bad rowindex ~w~n", [BadRowIndex]);
do_print_table({error, {invalid_rowindex, BadRowIndex, TableInfo}}, PrintRow) ->
--
cgit v1.2.3
From 8e9ef38dd36c771dff0d477fa7999d34b72e8a7a Mon Sep 17 00:00:00 2001
From: Micael Karlberg
Date: Fri, 10 Dec 2010 17:50:38 +0100
Subject: Added counter (variables) for usm. Also added config file for usm.
And more sed'ing...
---
lib/snmp/src/agent/snmp_framework_mib.erl | 12 +++++
lib/snmp/src/agent/snmp_user_based_sm_mib.erl | 55 ++++++++++++++++++++++
lib/snmp/src/agent/snmp_view_based_acm_mib.erl | 4 ++
lib/snmp/src/agent/snmpa.erl | 22 +++++++--
lib/snmp/test/test_config/.gitignore | 1 +
lib/snmp/test/test_config/Makefile | 26 ++++++++--
lib/snmp/test/test_config/agent/agent.conf.src | 2 +-
lib/snmp/test/test_config/agent/usm.conf.src | 17 +++++++
lib/snmp/test/test_config/manager/manager.conf.src | 2 +-
lib/snmp/test/test_config/manager/usm.conf.src | 1 +
lib/snmp/test/test_config/modules.mk | 1 +
lib/snmp/test/test_config/sys-agent.config.src | 2 +-
lib/snmp/test/test_config/sys.config.src | 4 +-
13 files changed, 138 insertions(+), 11 deletions(-)
create mode 100644 lib/snmp/test/test_config/agent/usm.conf.src
(limited to 'lib')
diff --git a/lib/snmp/src/agent/snmp_framework_mib.erl b/lib/snmp/src/agent/snmp_framework_mib.erl
index d9bf7e8551..0d7866d94d 100644
--- a/lib/snmp/src/agent/snmp_framework_mib.erl
+++ b/lib/snmp/src/agent/snmp_framework_mib.erl
@@ -373,15 +373,27 @@ intAgentUDPPort(Op) ->
intAgentIpAddress(Op) ->
snmp_generic:variable_func(Op, db(intAgentIpAddress)).
+snmpEngineID(print) ->
+ VarAndValue = [{snmpEngineID, snmpEngineID(get)}],
+ snmpa_mib_lib:print_variables(VarAndValue);
snmpEngineID(Op) ->
snmp_generic:variable_func(Op, db(snmpEngineID)).
+snmpEngineMaxMessageSize(print) ->
+ VarAndValue = [{snmpEngineMaxMessageSize, snmpEngineMaxMessageSize(get)}],
+ snmpa_mib_lib:print_variables(VarAndValue);
snmpEngineMaxMessageSize(Op) ->
snmp_generic:variable_func(Op, db(snmpEngineMaxMessageSize)).
+snmpEngineBoots(print) ->
+ VarAndValue = [{snmpEngineBoots, snmpEngineBoots(get)}],
+ snmpa_mib_lib:print_variables(VarAndValue);
snmpEngineBoots(Op) ->
snmp_generic:variable_func(Op, db(snmpEngineBoots)).
+snmpEngineTime(print) ->
+ VarAndValue = [{snmpEngineTime, snmpEngineTime(get)}],
+ snmpa_mib_lib:print_variables(VarAndValue);
snmpEngineTime(get) ->
{value, get_engine_time()}.
diff --git a/lib/snmp/src/agent/snmp_user_based_sm_mib.erl b/lib/snmp/src/agent/snmp_user_based_sm_mib.erl
index 4c3f27c4ef..69cebc858b 100644
--- a/lib/snmp/src/agent/snmp_user_based_sm_mib.erl
+++ b/lib/snmp/src/agent/snmp_user_based_sm_mib.erl
@@ -26,6 +26,12 @@
table_next/2,
is_engine_id_known/1, get_user/2, get_user_from_security_name/2,
mk_key_change/3, mk_key_change/5, extract_new_key/3, mk_random/1]).
+-export([usmStatsUnsupportedSecLevels/1,
+ usmStatsNotInTimeWindows/1,
+ usmStatsUnknownUserNames/1,
+ usmStatsUnknownEngineIDs/1,
+ usmStatsWrongDigests/1,
+ usmStatsDecryptionErrors/1]).
-export([add_user/1, add_user/13, delete_user/1]).
%% Internal
@@ -303,6 +309,54 @@ gc_tabs() ->
%%-----------------------------------------------------------------
%% Counter functions
%%-----------------------------------------------------------------
+
+usmStatsUnsupportedSecLevels(print) ->
+ VarAndValue = [{usmStatsUnsupportedSecLevels,
+ usmStatsUnsupportedSecLevels(get)}],
+ snmpa_mib_lib:print_variables(VarAndValue);
+usmStatsUnsupportedSecLevels(get) ->
+ get_counter(usmStatsUnsupportedSecLevels).
+
+usmStatsNotInTimeWindows(print) ->
+ VarAndValue = [{usmStatsNotInTimeWindows, usmStatsNotInTimeWindows(get)}],
+ snmpa_mib_lib:print_variables(VarAndValue);
+usmStatsNotInTimeWindows(get) ->
+ get_counter(usmStatsNotInTimeWindows).
+
+usmStatsUnknownUserNames(print) ->
+ VarAndValue = [{usmStatsUnknownUserNames, usmStatsUnknownUserNames(get)}],
+ snmpa_mib_lib:print_variables(VarAndValue);
+usmStatsUnknownUserNames(get) ->
+ get_counter(usmStatsUnknownUserNames).
+
+usmStatsUnknownEngineIDs(print) ->
+ VarAndValue = [{usmStatsUnknownEngineIDs, usmStatsUnknownEngineIDs(get)}],
+ snmpa_mib_lib:print_variables(VarAndValue);
+usmStatsUnknownEngineIDs(get) ->
+ get_counter(usmStatsUnknownEngineIDs).
+
+usmStatsWrongDigests(print) ->
+ VarAndValue = [{usmStatsWrongDigests, usmStatsWrongDigests(get)}],
+ snmpa_mib_lib:print_variables(VarAndValue);
+usmStatsWrongDigests(get) ->
+ get_counter(usmStatsWrongDigests).
+
+usmStatsDecryptionErrors(print) ->
+ VarAndValue = [{usmStatsDecryptionErrors, usmStatsDecryptionErrors(get)}],
+ snmpa_mib_lib:print_variables(VarAndValue);
+usmStatsDecryptionErrors(get) ->
+ get_counter(usmStatsDecryptionErrors).
+
+
+get_counter(Name) ->
+ case (catch ets:lookup(snmp_agent_table, Name)) of
+ [{_, Val}] ->
+ {value, Val};
+ _ ->
+ genErr
+ end.
+
+
init_vars() -> lists:map(fun maybe_create_var/1, vars()).
maybe_create_var(Var) ->
@@ -323,6 +377,7 @@ vars() ->
usmStatsDecryptionErrors
].
+
%%-----------------------------------------------------------------
%% API functions
%%-----------------------------------------------------------------
diff --git a/lib/snmp/src/agent/snmp_view_based_acm_mib.erl b/lib/snmp/src/agent/snmp_view_based_acm_mib.erl
index 659babaf94..74acda2f21 100644
--- a/lib/snmp/src/agent/snmp_view_based_acm_mib.erl
+++ b/lib/snmp/src/agent/snmp_view_based_acm_mib.erl
@@ -749,6 +749,7 @@ do_get_next(RowIndex, Cols) ->
end
end.
+
%%-----------------------------------------------------------------
%% Functions to manipulate vacmAccessRows.
%%-----------------------------------------------------------------
@@ -939,6 +940,9 @@ do_get_vacmAccessTable(Key0, Acc) ->
end.
+%%-----------------------------------------------------------------
+%% Wrappers
+%%-----------------------------------------------------------------
db(X) -> snmpa_agent:db(X).
volatile_db(X) -> {X, volatile}.
diff --git a/lib/snmp/src/agent/snmpa.erl b/lib/snmp/src/agent/snmpa.erl
index 3c214874fe..22fbd33add 100644
--- a/lib/snmp/src/agent/snmpa.erl
+++ b/lib/snmp/src/agent/snmpa.erl
@@ -327,6 +327,16 @@ mibs_info() ->
snmpOutTraps
]
},
+ {snmp_framework_mib,
+ [
+ ],
+ [
+ snmpEngineID,
+ snmpEngineBoots,
+ snmpEngineTime,
+ snmpEngineMaxMessageSize
+ ]
+ },
{snmp_view_based_acm_mib,
[
vacmAccessTable,
@@ -362,7 +372,13 @@ mibs_info() ->
usmUserTable
],
[
- usmUserSpinLock
+ usmUserSpinLock,
+ usmStatsUnsupportedSecLevels,
+ usmStatsNotInTimeWindows,
+ usmStatsUnknownUserNames,
+ usmStatsUnknownEngineIDs,
+ usmStatsWrongDigests,
+ usmStatsDecryptionErrors
]
}
].
@@ -441,8 +457,8 @@ make_pretty_mib(snmp_notification_mib) ->
"SNMP-NOTIFICATION-MIB";
make_pretty_mib(snmp_user_based_sm_mib) ->
"SNMP-USER-BASED-SM-MIB";
-make_pretty_mib(snmp_standard_mib) ->
- "STANDARD-MIB";
+make_pretty_mib(snmp_framework_mib) ->
+ "SNMP-FRAMEWORK-MIB";
make_pretty_mib(Mod) ->
atom_to_list(Mod).
diff --git a/lib/snmp/test/test_config/.gitignore b/lib/snmp/test/test_config/.gitignore
index 60d564fe4d..fc2d5dbadf 100644
--- a/lib/snmp/test/test_config/.gitignore
+++ b/lib/snmp/test/test_config/.gitignore
@@ -11,6 +11,7 @@
/agent/standard.conf
/agent/target_addr.conf
/agent/target_params.conf
+/agent/usm.conf
/agent/vacm.conf
# Manager config files (Generated)
diff --git a/lib/snmp/test/test_config/Makefile b/lib/snmp/test/test_config/Makefile
index c02bb5c601..4953de7fe8 100644
--- a/lib/snmp/test/test_config/Makefile
+++ b/lib/snmp/test/test_config/Makefile
@@ -94,6 +94,22 @@ ifeq ($(SYS_NAME),)
SYS_NAME = FOO
endif
+ifeq ($(AGENT_ENGINE_ID),)
+AGENT_ENGINE_ID = Agent engine of $(USER)
+endif
+
+ifeq ($(AGENT_USM_ENGINE_ID),)
+AGENT_USM_ENGINE_ID = $(AGENT_ENGINE_ID)
+endif
+
+ifeq ($(MANAGER_ENGINE_ID),)
+MANAGER_ENGINE_ID = Manager engine of $(USER)
+endif
+
+ifeq ($(MANAGER_USM_ENGINE_ID),)
+MANAGER_USM_ENGINE_ID = $(MANAGER_ENGINE_ID)
+endif
+
# ----------------------------------------------------
@@ -119,11 +135,15 @@ agent/%.conf: agent/%.conf.src
-e 's?%SYS_CONTACT%?$(SYS_CONTACT)? ' \
-e 's?%SYS_LOCATION%?$(SYS_LOCATION)? ' \
-e 's?%SYS_NAME%?$(SYS_NAME)? ' \
- -e 's?%TARGET_NAME_PRE%?$(TARGET_NAME_PRE)? ' < $< > $@
+ -e 's?%TARGET_NAME_PRE%?$(TARGET_NAME_PRE)? ' \
+ -e 's?%ENGINE_ID%?\"$(AGENT_ENGINE_ID)\"? ' \
+ -e 's?%USM_ENGINE_ID%?\"$(AGENT_USM_ENGINE_ID)\"? ' < $< > $@
manager/%.conf: manager/%.conf.src
@echo "$< -> $@"
- $(PERL) -p -e 's?%ADDR%?$(ADDR)? ' < $< > $@
+ sed -e 's?%ADDR%?$(ADDR)? ' \
+ -e 's?%ENGINE_ID%?\"$(MANAGER_ENGINE_ID)\"? ' \
+ -e 's?%USM_ENGINE_ID%?\"$(MANAGER_USM_ENGINE_ID)\"? ' < $< > $@
# ----------------------------------------------------
@@ -133,7 +153,7 @@ include $(ERL_TOP)/make/otp_release_targets.mk
release_spec:
-release_tests_spec: opt
+release_tests_spec: clean opt
$(INSTALL_DIR) $(RELSYSDIR)
chmod -f -R u+w $(RELSYSDIR)
$(INSTALL_DIR) $(RELSYSDIR)/agent
diff --git a/lib/snmp/test/test_config/agent/agent.conf.src b/lib/snmp/test/test_config/agent/agent.conf.src
index 2977cd49f8..1fe95cc72d 100644
--- a/lib/snmp/test/test_config/agent/agent.conf.src
+++ b/lib/snmp/test/test_config/agent/agent.conf.src
@@ -15,5 +15,5 @@
{intAgentUDPPort, 4000}.
{intAgentIpAddress, %ADDR%}.
-{snmpEngineID, "foo"}.
+{snmpEngineID, %ENGINE_ID%}.
{snmpEngineMaxMessageSize, 484}.
diff --git a/lib/snmp/test/test_config/agent/usm.conf.src b/lib/snmp/test/test_config/agent/usm.conf.src
new file mode 100644
index 0000000000..0409084048
--- /dev/null
+++ b/lib/snmp/test/test_config/agent/usm.conf.src
@@ -0,0 +1,17 @@
+%% This file defines the security parameters for the user-based
+%% security model.
+%% The data is inserted into the usmUserTable defined
+%% in SNMP-USER-BASED-SM-MIB.
+%% Each row is a 13-tuple:
+%% {EngineID, UserName, SecName, Clone, AuthP, AuthKeyC, OwnAuthKeyC,
+%% PrivP, PrivKeyC, OwnPrivKeyC, Public, AuthKey, PrivKey}.
+%% For example
+%% {"agentEngine", "initial", "initial", zeroDotZero,
+%% usmNoAuthProtocol, "", "", usmNoPrivProtocol, "", "", "",
+%% "", ""}.
+%%
+
+
+{%USM_ENGINE_ID%, "initial", "initial", zeroDotZero, usmHMACMD5AuthProtocol, "", "", usmNoPrivProtocol, "", "", "", [160,66,33,136,178,59,246,214,102,63,131,131,54,14,221,177], ""}.
+{%USM_ENGINE_ID%, "templateMD5", "templateMD5", zeroDotZero, usmHMACMD5AuthProtocol, "", "", usmNoPrivProtocol, "", "", "", [160,66,33,136,178,59,246,214,102,63,131,131,54,14,221,177], ""}.
+{%USM_ENGINE_ID%, "templateSHA", "templateSHA", zeroDotZero, usmHMACSHAAuthProtocol, "", "", usmNoPrivProtocol, "", "", "", [199,94,239,13,229,135,141,77,124,129,65,189,230,240,115,163,239,15,13,242], ""}.
diff --git a/lib/snmp/test/test_config/manager/manager.conf.src b/lib/snmp/test/test_config/manager/manager.conf.src
index 7d4104ded2..c38a61b13c 100644
--- a/lib/snmp/test/test_config/manager/manager.conf.src
+++ b/lib/snmp/test/test_config/manager/manager.conf.src
@@ -12,5 +12,5 @@
{port, 5000}.
{address, %ADDR%}.
-{engine_id, "foo"}.
+{engine_id, %ENGINE_ID%}.
{max_message_size, 484}.
diff --git a/lib/snmp/test/test_config/manager/usm.conf.src b/lib/snmp/test/test_config/manager/usm.conf.src
index 39122cab5c..a558c86710 100644
--- a/lib/snmp/test/test_config/manager/usm.conf.src
+++ b/lib/snmp/test/test_config/manager/usm.conf.src
@@ -5,4 +5,5 @@
%% {EngineID, UserName, SecName, AuthP, AuthKey, PrivP, PrivKey}
%%
+{%USM_ENGINE_ID%, "initial", usmNoAuthProtocol, "", usmNoPrivProtocol, ""}.
diff --git a/lib/snmp/test/test_config/modules.mk b/lib/snmp/test/test_config/modules.mk
index ee8b68d4eb..3d084cef01 100644
--- a/lib/snmp/test/test_config/modules.mk
+++ b/lib/snmp/test/test_config/modules.mk
@@ -30,6 +30,7 @@ AGENT_CONFIG_FILES = \
agent/standard.conf \
agent/target_addr.conf \
agent/target_params.conf \
+ agent/usm.conf \
agent/vacm.conf
MANAGER_CONFIG_FILES = \
diff --git a/lib/snmp/test/test_config/sys-agent.config.src b/lib/snmp/test/test_config/sys-agent.config.src
index eb6b0916ff..46a458203d 100644
--- a/lib/snmp/test/test_config/sys-agent.config.src
+++ b/lib/snmp/test/test_config/sys-agent.config.src
@@ -5,7 +5,7 @@
{agent,
[
{priority, normal},
- {versions, [v2]},
+ {versions, [v1,v2,v3]},
{db_dir, "%DIR%/agent/db"},
{mib_storage, ets},
%% {agent_mib_storage, volatile},
diff --git a/lib/snmp/test/test_config/sys.config.src b/lib/snmp/test/test_config/sys.config.src
index 7e4e3b0acd..b2cd399883 100644
--- a/lib/snmp/test/test_config/sys.config.src
+++ b/lib/snmp/test/test_config/sys.config.src
@@ -5,7 +5,7 @@
{agent,
[
{priority, normal},
- {versions, [v2]},
+ {versions, [v1,v2,v3]},
{db_dir, "%DIR%/agent/db"},
{mib_storage, ets},
{agent_mib_storage, volatile},
@@ -38,7 +38,7 @@
{manager,
[
{priority, normal},
- {versions, [v2]},
+ {versions, [v1,v2,v3]},
{config, [{dir, "%DIR%/manager/conf"},
{verbosity, silence},
{db_dir, "%DIR%/manager/db"},
--
cgit v1.2.3
From fe1a4d17ee6558f466c49bfaea25c3a0b4ca9936 Mon Sep 17 00:00:00 2001
From: Micael Karlberg
Date: Wed, 23 Feb 2011 11:58:16 +0100
Subject: Initial fix of release notes (bad notes for version 4.18).
---
lib/snmp/doc/src/notes.xml | 17 +++++++----------
1 file changed, 7 insertions(+), 10 deletions(-)
(limited to 'lib')
diff --git a/lib/snmp/doc/src/notes.xml b/lib/snmp/doc/src/notes.xml
index 493e7aa092..015e2628f4 100644
--- a/lib/snmp/doc/src/notes.xml
+++ b/lib/snmp/doc/src/notes.xml
@@ -1,10 +1,10 @@
-
+
- 19962010
+ 19962011
Ericsson AB. All Rights Reserved.
@@ -37,18 +37,14 @@
Fixed Bugs and Malfunctions
-
-
- When the function FilterMod:accept_recv/2 returned false
- the SNMP agent stopped collecting messages from UDP.
-
- Own Id: OTP-8761
+ Cosmetic prep for R14B (plain) release.
-
+
-
+
SNMP Development Toolkit 4.17.1
Version 4.17.1 supports code replacement in runtime from/to
version 4.17, 4.16.2, 4.16.1, 4.16, 4.15, 4.14 and 4.13.5.
@@ -63,7 +59,8 @@
-
When the function FilterMod:accept_recv/2
- returned false the SNMP agent stopped collecting messages from UDP.
+ returned false the SNMP agent stopped collecting
+ messages from UDP.
Own Id: OTP-8761
--
cgit v1.2.3
From ae806f1663d47569876b3abc0998ee3387c7abd2 Mon Sep 17 00:00:00 2001
From: Micael Karlberg
Date: Wed, 23 Feb 2011 16:12:36 +0100
Subject: Updated release notes and the documentation. Also added entry in the
appup file.
---
lib/snmp/doc/src/notes.xml | 52 +++++++++++++++++-
lib/snmp/doc/src/snmp_config.xml | 42 ++++-----------
lib/snmp/doc/src/snmpa.xml | 37 ++++++++++++-
lib/snmp/src/app/snmp.appup.src | 114 +++++++++++++++------------------------
4 files changed, 139 insertions(+), 106 deletions(-)
(limited to 'lib')
diff --git a/lib/snmp/doc/src/notes.xml b/lib/snmp/doc/src/notes.xml
index 015e2628f4..3d76fdeaf6 100644
--- a/lib/snmp/doc/src/notes.xml
+++ b/lib/snmp/doc/src/notes.xml
@@ -32,6 +32,56 @@
notes.xml
+
+ SNMP Development Toolkit 4.19
+ Version 4.19 supports code replacement in runtime from/to
+ version 4.18.
+
+
+ Improvements and new features
+
+
+ -
+
[agent] Added a "complete" set of (snmp) table and variable
+ print functions, for each mib handled by the SNMP (agent)
+ application. This will be usefull when debugging a running agent.
+ See
+ print_mib_info/0,
+ print_mib_tables/0
+ and
+ print_mib_variables/0
+ for more info.
+ Own Id: OTP-8977
+
+
+
+
+
+
+
+ Reported Fixed Bugs and Malfunctions
+ -
+
+
+
+
+ Incompatibilities
+ -
+
+
+
+
SNMP 4.18
Fixed Bugs and Malfunctions
@@ -42,7 +92,7 @@
-
+
SNMP Development Toolkit 4.17.1
diff --git a/lib/snmp/doc/src/snmp_config.xml b/lib/snmp/doc/src/snmp_config.xml
index 769b908adc..4e41cb5037 100644
--- a/lib/snmp/doc/src/snmp_config.xml
+++ b/lib/snmp/doc/src/snmp_config.xml
@@ -1,4 +1,4 @@
-
+
@@ -1004,36 +1004,16 @@ ok
Another usefull way to debug the agent is to pretty-print the content of
- some of the (MIB-) tables handled directly by the agent. This can be done
- for the following tables:
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
-
+ all the tables and/or variables handled directly by the agent.
+ This can be done by simply calling:
+
+ See
+ print_mib_info/0,
+ print_mib_tables/0
+ or
+ print_mib_variables/0
+ for more info.
+
diff --git a/lib/snmp/doc/src/snmpa.xml b/lib/snmp/doc/src/snmpa.xml
index f546724a78..1d680e80f5 100644
--- a/lib/snmp/doc/src/snmpa.xml
+++ b/lib/snmp/doc/src/snmpa.xml
@@ -1,10 +1,10 @@
-
+