<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
p
{mso-style-priority:99;
mso-margin-top-alt:auto;
margin-right:0in;
mso-margin-bottom-alt:auto;
margin-left:0in;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
span.EmailStyle18
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>The original mail is at <a href="http://erlang.org/pipermail/erlang-questions/2012-July/067981.html">http://erlang.org/pipermail/erlang-questions/2012-July/067981.html</a> and is included in this reply.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Thanks for the advice on the {force_load, true} option in agent.config. It got the target address loaded.<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>I am continuing to investigate why the snmpa:send_notification/6 tries to get the target address from snmpa_target_cache (which contains only {state, invalid}) rather than a table that contains the target address (observer Table Viewer shows that table snmp_local_db1_shadow contains the target address and params).<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> DefacedVR [mailto:vladislav.chugunov@gmail.com] <br><b>Sent:</b> Friday, July 27, 2012 6:35 AM<br><b>To:</b> erlang-programming@googlegroups.com<br><b>Cc:</b> Dick Oyen; erlang-questions@erlang.org; Dick Oyen<br><b>Subject:</b> Re: [erlang-questions] SNMP Notify Target<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><br><br>пятница, 27 июля 2012 г., 0:12:14 UTC+4 пользователь Dick Oyen написал:<o:p></o:p></p><div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='color:#1F497D'>></span>Unfortunately there were no responses to my original question, but I have been<o:p></o:p></p></div></div><div><p class=MsoNormal> Can you provide link to the previous mail?<o:p></o:p></p></div><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in'><div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>using debugger to step through Erlang snmp code to see what is happening.<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>The snmpa:send_notification/6 (indirectly) calls <o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>snmpa_target_cache:get_targets/1, which returns [].<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>That seems to be because start:application(snmp) decided not to read <o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>target_addr.conf or target_params.conf; the reason for its decision was that <o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>snmp_target_mib:configure/2 finds that the target params table already exists. <o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>It exists because start:application(snmp) had created, but not populated it. <o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>QUESTION: Can someone tell me if there is some option and where I should use <o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>the option to get the target_addr.conf to be read into the table?<o:p></o:p></p></div></div></blockquote><div><p class=MsoNormal>There is option {force_load, true} from <a href="http://www.erlang.org/doc/man/snmp_app.html">http://www.erlang.org/doc/man/snmp_app.html</a><o:p></o:p></p></div><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in'><div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Next I experimented with forcing the file to be read into the table by running <o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>the following from my agent erl command window:<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> snmp_target_mib:reconfigure("snmp/agent/conf").<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>The effects of this showed up two tables in the Table Viewer of 'observer':<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>First, snmpa_target_cache contained a single record shown as a 2-tuple of column values:<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>{state, valid}<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Second, snmp_local_db_shadow contained (among 26 rows) the following 4 rows <o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>shown as 2-tuples of column values below:<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>{{snmpTargetAddrTable,first}, {undef,"testMIBMyFirstCoolTrap","testMIBMyFirstCoolTrap"}}<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>{{snmpTargetAddrTable,"testMIBMyFirstCoolTrap"}, {{"testMIBMyFirstCoolTrap",[1,3,6,1,2,1,100,1,1],[127,0,0,1,0,162],5000,3,"tag1","MyCoolTrapParams",3,1,"agent's engine",[],2048},first,first}}<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>{{snmpTargetParamsTable,first}, {undef,"MyCoolTrapParams","MyCoolTrapParams"}}<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>{{snmpTargetParamsTable,"MyCoolTrapParams"}, {{"MyCoolTrapParams",1,2,"initial",1,3,1},first,first}}<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Wow, that's great, so I called snmpa:send_notification/6 again.<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Unfortunately, snmpa_target_cache:get_targets/1 still returns [] because <o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>ets:match(?CACHE, {{'_','$1'},'$2'} is looking at the table that contains only <o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>{state,valid}.<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Thus, the information from target_addr.conf and target_params.conf is in some <o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>rows in a table, but not the table that the code seems to be looking at. <o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>QUESTION: Can someone tell me what I am doing wrong?<o:p></o:p></p><p> <o:p></o:p></p><p>>I am trying to get an SNMP example to send an SNPM trap, but am not succeeding. Any example would do. I am using the tutorial in <o:p></o:p></p><p>><a href="http://www.trapexit.org/SNMP_Quick_Start" target="_blank">http://www.trapexit.org/SNMP_Quick_Start</a> because it is easiest for me to understand. The tutorial says to enter:<o:p></o:p></p><p>> <o:p></o:p></p><p>>snmpa:send_notification(snmp_master_agent, testMIBMyFirstCoolTrap, no_receiver, "DrpManager", "", []).<o:p></o:p></p><p>> <o:p></o:p></p><p>>It returns 'ok', but there is no evidence in Wireshark, the agent's Erlang SNMP log, or the SNMP manager that the trap was actually sent.<o:p></o:p></p><p>> <o:p></o:p></p><p>>Using the Erlang debugger, I step through 'snmpa' code and find that the list of notify targets is empty.<o:p></o:p></p><p>> <o:p></o:p></p><p>>Please tell me how snmpa should know the notify targets.<o:p></o:p></p><p>> <o:p></o:p></p><p>>Here is what I have tried:<o:p></o:p></p><p>> <o:p></o:p></p><p>>I tried changing the NotifyName argument from "DrpManager" to "", because "DrpManager" does not appear in anywhere in the conf or mib files and the doc says that empty string should cause it to send to all targets, but my debugger stepping shows that the list is still empty.<o:p></o:p></p><p>> <o:p></o:p></p><p>>I tried changing NotifyName to "MyFirstCoolTrap" because notify.conf contains {"MyFirstCoolTrap", "tag1", trap}, but the list is still empty.<o:p></o:p></p><p>> <o:p></o:p></p><p>>I wonder if the agent is supposed to know about the manager (before the send_notification/6) because of the manager's call to<o:p></o:p></p><p>>snmpm:sync_get("simple_user", "otp agent", [[erlNodeName,1]]), which does appear in the agent's SNMP log.<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p></div></div></blockquote></div></body></html>