Closed awksedgreep closed 1 year ago
Hi, @awksedgreep. Thanks for contributing!
I've created 95b3c8d to address this. Can you try making your mix.exs
look like the following, then run mix deps.get deps.update
and let me know how it goes?
defp deps do
[ { :snmp_ex,
git: "https://github.com/jonnystorm/snmp-elixir",
branch: "fix-issue-57",
},
]
end
Thanks!
That's awfully kind of you. I'm still learning mix and this will help. I'll test and let you know what I'm able to figure out.
'njoy, Mark
On Thu, May 11, 2023 at 9:03 PM Jonathan Storm @.***> wrote:
Hi, @awksedgreep https://github.com/awksedgreep. Thanks for contributing!
I've created 95b3c8d https://github.com/jonnystorm/snmp-elixir/commit/95b3c8db3668b2322967677736a689535e35587a to address this. Can you try making your mix.exs look like the following, then run mix deps.get deps.update and let me know how it goes?
defp deps do [ { :snmp_ex, git: "https://github.com/jonnystorm/snmp-elixir", branch: "fix-issue-57", }, ]end
Thanks!
— Reply to this email directly, view it on GitHub https://github.com/jonnystorm/snmp-elixir/issues/57#issuecomment-1544956042, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAE5KOMT2XXBCNN34CMLHTXFWD7JANCNFSM6AAAAAAX5QLV74 . You are receiving this because you were mentioned.Message ID: @.***>
-- "Keynes observed that pragmatic businessmen often could not imagine that they were the slaves of defunct economists, but ironically, never is this more true than today of Keynes himself." -- John Train
I feel like I'm not helping but I can report that the ifX mib returns an empty set now. I can't understand well enough to tell you why.
iex(1)> Snmptest.test_big_walk
21:58:08.249 [debug] Will register agent snmp://192.168.1.87 with target [212, 193, 95, 233, 174, 102, 243, 45, 61, 135, 151, 111, 112, 173, 107, 2, 99, 224, 108, 150] and config [engine_id: [128, 0, 31, 136, 128, 141, 23, 76, 69, 96, 82, 92, 100, 0, 0, 0, 0], address: [192, 168, 1, 87], port: 161, tdomain: :transportDomainUdpIpv4, community: 'public', sec_model: :v2c, version: :v2]. []
Def an improvement from before but it isn't polling. Your logic seems very sound to me. I'm puzzled on this one. It occurs to me the agent is responding within the tree when sending end of mib. Perhaps that's the answer the "and" clause. Let me verify and respond.
'njoy, Mark
Hmm, the udp packet returned def is within the same tree and has the end of mib, which means your clause should work perfectly.
%{oid: [1, 3, 6, 1, 2, 1, 31, 0], type: :NULL, value: :endOfMibView}
I'll continue to test and see what I can grok from what we're seeing.
I think it's 895 appending the .0 for a walk.
%{oid: base_oid ++ [0]}
It's confusing the agent and it immediately sends end of mib.
192.168.1.99.5000 > 192.168.1.87.161: [udp sum ok] { SNMPv2c {
GetNextRequest(27) R=822035858 .1.3.6.1.2.1.31.0 } } 07:37:23.620278 IP (tos 0x0, ttl 64, id 14395, offset 0, flags [DF], proto UDP (17), length 70) 192.168.1.87.161 > 192.168.1.99.5000: [bad udp cksum 0x844e -> 0x6c3b!] { SNMPv2c { GetResponse(27) R=822035858 .1.3.6.1.2.1.31.0=[endOfMibView] } }
I can duplicate this on the command line with.
@.:~# snmpbulkwalk -v2c -c public localhost .1.3.6.1.2.1.31 iso.3.6.1.2.1.31.1.1.1.1.1 = STRING: "lo" iso.3.6.1.2.1.31.1.1.1.1.2 = STRING: "enp1s0" iso.3.6.1.2.1.31.1.1.1.1.3 = STRING: "wlp0s20f3" ... vs. @.:~# snmpbulkwalk -v2c -c public localhost .1.3.6.1.2.1.31.0 iso.3.6.1.2.1.31.0 = No Such Object available on this agent at this OID
'njoy, Mark
On Thu, May 11, 2023 at 9:53 PM Mark Cotner @.***> wrote:
That's awfully kind of you. I'm still learning mix and this will help. I'll test and let you know what I'm able to figure out.
'njoy, Mark
On Thu, May 11, 2023 at 9:03 PM Jonathan Storm @.***> wrote:
Hi, @awksedgreep https://github.com/awksedgreep. Thanks for contributing!
I've created 95b3c8d https://github.com/jonnystorm/snmp-elixir/commit/95b3c8db3668b2322967677736a689535e35587a to address this. Can you try making your mix.exs look like the following, then run mix deps.get deps.update and let me know how it goes?
defp deps do [ { :snmp_ex, git: "https://github.com/jonnystorm/snmp-elixir", branch: "fix-issue-57", }, ]end
Thanks!
— Reply to this email directly, view it on GitHub https://github.com/jonnystorm/snmp-elixir/issues/57#issuecomment-1544956042, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAE5KOMT2XXBCNN34CMLHTXFWD7JANCNFSM6AAAAAAX5QLV74 . You are receiving this because you were mentioned.Message ID: @.***>
-- "Keynes observed that pragmatic businessmen often could not imagine that they were the slaves of defunct economists, but ironically, never is this more true than today of Keynes himself." -- John Train
-- "Keynes observed that pragmatic businessmen often could not imagine that they were the slaves of defunct economists, but ironically, never is this more true than today of Keynes himself." -- John Train
@awksedgreep Thanks for digging into this, Mark.
I've committed that change to the same branch. Just run mix deps.update snmp_ex
to pull the update, and let me know if matters improve. If all is well, I'll run it through CI and publish a new version to hex.pm.
Here's what I get after that change.
(Mix) Could not start application snmp_ex: exited in: SNMP.start(:normal, []) (EXIT) an exception was raised: ** (MatchError) no match of right hand side value: {:error, {:shutdown, {:failed_to_start_child, :snmpm_supervisor, {:shutdown, {:failed_to_start_child, :snmpm_server_sup, {:shutdown, {:failed_to_start_child, :snmpm_server, {:failed_starting_net_if, {:eaddrinuse, {:child, :undefined, :net_if, {:snmpm_net_if, :start_link, [#PID<0.313.0>, #PID<0.315.0>]}, :temporary, false, 2000, :worker, [:snmpm_net_if]}}}}}}}}}} (snmp_ex 0.5.0) lib/snmp.ex:231: SNMP.start/2 (kernel 8.5.4) application_master.erl:293: :application_master.start_it_old/4
It's not clear to me what the cause might be.
'njoy, Mark
On Fri, May 12, 2023 at 12:41 PM Jonathan Storm @.***> wrote:
@awksedgreep https://github.com/awksedgreep Thanks for digging into this, Mark.
I've committed that change to the same branch. Just run mix deps.update snmp_ex to pull update, and let me know if matters improve. If all is well, I'll run it through CI publish a new version to hex.pm.
— Reply to this email directly, view it on GitHub https://github.com/jonnystorm/snmp-elixir/issues/57#issuecomment-1546013239, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAE5KKLU43CG47TRJHE5TTXFZR37ANCNFSM6AAAAAAX5QLV74 . You are receiving this because you were mentioned.Message ID: @.***>
-- "Keynes observed that pragmatic businessmen often could not imagine that they were the slaves of defunct economists, but ironically, never is this more true than today of Keynes himself." -- John Train
@awksedgreep The {:eaddrinuse, {:child, :undefined, :net_if, {:snmp_m_net_if, :start_link, ...
error suggests an already running listener. You may need to shut down any existing iex
sessions and retry. Let me know if you continue to see that error.
Sorry for the delay. I wanted to educate myself before wasting any more of your time. I did have a second iex session running and it was bound to the port.
That fix worked for me. It successfully detected the end of the mib.
... %{oid: [1, 3, 6, 1, 2, 1, 31, 1, 1, 1, 17, 2], type: :INTEGER, value: 1}, %{ oid: [1, 3, 6, 1, 2, 1, 31, 1, 1, 1, 18, 1], type: :"OCTET STRING", value: "" }, %{ oid: [1, 3, 6, 1, 2, 1, 31, 1, 1, 1, 18, 2], type: :"OCTET STRING", value: "" }, %{oid: [1, 3, 6, 1, 2, 1, 31, 1, 1, 1, 19, 1], type: :TimeTicks, value: 0}, %{oid: [1, 3, 6, 1, 2, 1, 31, 1, 1, 1, 19, 2], type: :TimeTicks, value: 0}, %{oid: [1, 3, 6, 1, 2, 1, 31, 1, 5, 0], type: :TimeTicks, value: 0} ]
'njoy, Mark
On Sun, May 14, 2023 at 3:09 PM Jonathan Storm @.***> wrote:
@awksedgreep https://github.com/awksedgreep The {:eaddrinuse, {:child, :undefined, :net_if, {:snmp_m_net_if, :start_link, ... error suggests an already running listener. You may need to shut down any existing iex sessions and retry. Let me know if you continue to see that error.
— Reply to this email directly, view it on GitHub https://github.com/jonnystorm/snmp-elixir/issues/57#issuecomment-1546978415, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAE5KPI36RHUX2UBKYIUATXGEUW3ANCNFSM6AAAAAAX5QLV74 . You are receiving this because you were mentioned.Message ID: @.***>
-- "Keynes observed that pragmatic businessmen often could not imagine that they were the slaves of defunct economists, but ironically, never is this more true than today of Keynes himself." -- John Train
@awksedgreep You're certainly not wasting my time, Mark. And thank you for contributing your own time and energy!
This fix is published in Hex.pm as version 0.6.0. Just change your mix.exs deps
section to the following, then run mix deps.update snmp_ex
and mix deps.compile
.
defp deps do
[ {:snmp_ex, "~> 0.6.0"},
]
end
Let me know how it goes.
Working great. I've even crafted some custom PDUs and sent 100k request/minute. Should be handy when our target is 500k to 1m cable modems per polling cycle. Biggest challenge so far has been udp buffers on Linux and our test Mac machines. I think I mentioned getbulk already works(just send multiple OIDs to get), but bulkwalk does not. You may see a pull request when I'm comfortable enough to attempt.
@awksedgreep Thanks, Mark! It sounds like you're making good progress.
Let me know if you run into trouble. I'll be happy to help where I can.
Looks like walk isn't detecting the end of the tree. Polling net-snmp on Linux. Looks like line 906 should detect either a null type or :endOfMibView value(more likely). Been using Elixir for < 1 week now. Maybe I can contribute when my skills improve. Great library. Thank you for putting this together. I've been maintaining a thread safe SNMP4J wrapper for JRuby for 14+ years. Anxious to play with Elixir and Erlang. I ran a tcpdump on the get request with multiple oids and you probably already know this, but getbulk is fully supported.
Here's my test code in case it would help . . .
23:00:25.497 [debug] Will register agent snmp://192.168.1.87 with target [212, 193, 95, 233, 174, 102, 243, 45, 61, 135, 151, 111, 112, 173, 107, 2, 99, 224, 108, 150] and config [engine_id: [128, 0, 31, 136, 128, 141, 23, 76, 69, 96, 82, 92, 100, 0, 0, 0, 0], address: [192, 168, 1, 87], port: 161, tdomain: :transportDomainUdpIpv4, community: 'public', sec_model: :v2c, version: :v2]. %{oid: [1, 3, 6, 1, 2, 1, 31, 0], type: :NULL, value: :endOfMibView}
23:00:25.509 [debug] Will register agent snmp://192.168.1.87 with target [212, 193, 95, 233, 174, 102, 243, 45, 61, 135, 151, 111, 112, 173, 107, 2, 99, 224, 108, 150] and config [engine_id: [128, 0, 31, 136, 128, 141, 23, 76, 69, 96, 82, 92, 100, 0, 0, 0, 0], address: [192, 168, 1, 87], port: 161, tdomain: :transportDomainUdpIpv4, community: 'public', sec_model: :v2c, version: :v2]. %{oid: [1, 3, 6, 1, 2, 1, 31, 0], type: :NULL, value: :endOfMibView}
23:00:25.521 [debug] Will register agent snmp://192.168.1.87 with target [212, 193, 95, 233, 174, 102, 243, 45, 61, 135, 151, 111, 112, 173, 107, 2, 99, 224, 108, 150] and config [engine_id: [128, 0, 31, 136, 128, 141, 23, 76, 69, 96, 82, 92, 100, 0, 0, 0, 0], address: [192, 168, 1, 87], port: 161, tdomain: :transportDomainUdpIpv4, community: 'public', sec_model: :v2c, version: :v2]. %{oid: [1, 3, 6, 1, 2, 1, 31, 0], type: :NULL, value: :endOfMibView}
23:00:25.536 [debug] Will register agent snmp://192.168.1.87 with target [212, 193, 95, 233, 174, 102, 243, 45, 61, 135, 151, 111, 112, 173, 107, 2, 99, 224, 108, 150] and config [engine_id: [128, 0, 31, 136, 128, 141, 23, 76, 69, 96, 82, 92, 100, 0, 0, 0, 0], address: [192, 168, 1, 87], port: 161, tdomain: :transportDomainUdpIpv4, community: 'public', sec_model: :v2c, version: :v2]. %{oid: [1, 3, 6, 1, 2, 1, 31, 0], type: :NULL, value: :endOfMibView}
23:00:25.550 [debug] Will register agent snmp://192.168.1.87 with target [212, 193, 95, 233, 174, 102, 243, 45, 61, 135, 151, 111, 112, 173, 107, 2, 99, 224, 108, 150] and config [engine_id: [128, 0, 31, 136, 128, 141, 23, 76, 69, 96, 82, 92, 100, 0, 0, 0, 0], address: [192, 168, 1, 87], port: 161, tdomain: :transportDomainUdpIpv4, community: 'public', sec_model: :v2c, version: :v2].