SNMP & Mnesia
Dietmar Admin Schaefer
dietmar@REDACTED
Thu Jan 6 12:26:31 CET 2005
HI !
How to initialize MIB-Tables managed by mnesia ?
Lets say I have this MIB table:
-- Table of the HRA processes
processesHrAList OBJECT-TYPE
SYNTAX SEQUENCE OF ProcessesHrAEntry
ACCESS not-accessible
STATUS mandatory
DESCRIPTION
"Table of the 4D-Planner processes (HRA)"
::= { processes 3 }
processesHrAEntry OBJECT-TYPE
SYNTAX ProcessesHrAEntry
ACCESS not-accessible
STATUS mandatory
DESCRIPTION
"A list of the HRA processes "
INDEX { processHrAIndex }
::= { processesHrAList 1 }
ProcessesHrAEntry ::= SEQUENCE {
processHrAIndex INTEGER (1.. 30),
processHrAIdent DisplayString (SIZE(0..10)),
processHrAStatus INTEGER,
processHrARowStatus RowStatus
}
processHrAIndex OBJECT-TYPE
SYNTAX INTEGER (1.. 30)
ACCESS read-only
STATUS mandatory
DESCRIPTION
"A index that uniquely identifies an entry in the
processesHrAList table. "
::= { processesHrAEntry 1 }
processHrAIdent OBJECT-TYPE
SYNTAX DisplayString (SIZE(0..10))
ACCESS read-only
STATUS mandatory
DESCRIPTION
"The identifaction (name) of the respective process, e.g. D4AP,
Plandisp, etc.
Erlaeuterung/Ergaenzung von SH/CD erforderlich !!!"
::= { processesHrAEntry 2 }
processHrAStatus OBJECT-TYPE
SYNTAX CmmcStateType
ACCESS read-only
STATUS mandatory
DESCRIPTION
"The valid status of the processes are operational, standby, alert and
unknown"
::= { processesHrAEntry 3 }
processHrARowStatus OBJECT-TYPE
SYNTAX RowStatus
ACCESS read-write
STATUS mandatory
DESCRIPTION
"The status of this conceptual row."
::= { processesHrAEntry 4}
which results to this mnesia table def.
-record(processesHrAList,
{processHrAIndex,processHrAIdent,processHrAStatus,processHrARowStatus}).
???
for which I need to initialize at startup with approx. 10
processHrAIdents [4DAP,4DSUP,HARP,...]
I init my mnesia table as follows:
insertHrARecord() ->
HrAListRecord1 = #processesHrAList{processHrAIndex=1,
processHrAIdent='D4AP',processHrAStatus=1,processHrARowStatus=4},
F = fun() ->
case mnesia:write(HrAListRecord1) of
ok -> io:format("success writing HrAListRecord
to mnesia~n") , ok;
_ -> io:format("error writing mnesia~n")
end
end,
case mnesia:transaction(F) of
{atomic,_} -> io:format("transaction completet~n"),ok;
{aborted,_} -> io:format("transaction aborted ~n"),aborted;
_ -> io:format("transaction error~n"),error
end.
Asking the agent now gives me:
** SNMP A-NET-IF INFO: time in agent: 5803 mysec
** SNMP MASTER-AGENT LOG:
apply:
snmp_generic,table_func,[get_next,[],[0],{processesHrAList,mnesia}]
** SNMP MASTER-AGENT LOG:
returned: [{[1,1],1}]
** SNMP A-NET-IF INFO: time in agent: 6691 mysec
** SNMP MASTER-AGENT LOG:
apply:
snmp_generic,table_func,[get_next,[1],[1],{processesHrAList,mnesia}]
** SNMP MASTER-AGENT LOG:
returned: [{[2,1],'D4AP'}]
=ERROR REPORT==== 6-Jan-2005::12:19:33 ===
** User error: Got 'D4AP' from
{snmp_generic,table_func,[{processesHrAList,mnesia}]}. Using wrongType
What's wronh here ??
Any advices ?
Regards
Dietmar
More information about the erlang-questions
mailing list