hallidave / ruby-snmp Goto Github PK
View Code? Open in Web Editor NEWA Ruby implementation of SNMP (the Simple Network Management Protocol).
License: MIT License
A Ruby implementation of SNMP (the Simple Network Management Protocol).
License: MIT License
Regarding v1.0.4 of SNMP I have an issue.
On line 680 of manager.rb for trap_listener we see..
if @community == message.community <-------------------------
trap = message.pdu
if trap.kind_of?(InformRequest)
@transport.send(message.response.encode, source_ip, source_port)
end
trap.source_ip = source_ip
select_handler(trap).call(trap)
end
Which is causing an issue in my environment where we have multiple comm strings used by different parts of my company.
It would be nice to set the community string to nil or some other value in order to accept all SNMP traps regardless of which string they use.
Can we get this incorporated into the next release? Thank you for writing a great GEM as ruby-SNMP has served us quite well.
Hi,
in my case,I'm use manager.get("some oid for return a octet-string")
got result is ValueDecoderMap.
look like decode to integer. but my octet-string have mix of some integer and ascii.
so, how I get just raw octet-string?
ps.
takz.
Many network switches do not return a list of OIDs in ascending order. When we
use ruby-snmp for these devices, processing is aborted.
We cannot go to every device maker and get them to change their SNMP agents.
Also, note that snmpwalk has an option to ignore out-of-order OIDs.
Can you make this "OIDs are not increasing" logic configurable to allow us to ignore
out-of-order OIDs?
When I do an SNMP walk or an SNMP get using the numeric OID form I always get the translated form of the OID returned to me. I would like to deal with only numeric form going both ways. Can I get a option added to the Manager.new/open methods to do this? Perhaps a :translate_oid => true|false capability?
In other words when I send "1.3.6.1.2.1.1.2.0" I get back "SNMPv2-MIB::sysObjectID.0". I would like to disable this behavior and free myself from having to maintain many vendor MIBs (we have hundreds of MIBs worth of OIDs we want to poll).
If you would like me to provide some code suggestions can you suggest where I should look to get started?
I did not found MIB of LLDP. This protocol is userful to NOC
Hi.
Is this planned?
[1] pry(main)> s=SNMP::Manager.new(:Host=>'10.20.1.86', :Community=>'public')
[2] pry(main)> s.get_bulk(0, 34, '1.0.8802.1.1.2.1.1.7.1.1.1.4.5.79.68.188')
/var/lib/gems/1.9.1/gems/snmp-1.1.1/lib/snmp/manager.rb:491: warning: nil
/var/lib/gems/1.9.1/gems/snmp-1.1.1/lib/snmp/manager.rb:491: warning: nil
/var/lib/gems/1.9.1/gems/snmp-1.1.1/lib/snmp/manager.rb:491: warning: nil
/var/lib/gems/1.9.1/gems/snmp-1.1.1/lib/snmp/manager.rb:491: warning: nil
/var/lib/gems/1.9.1/gems/snmp-1.1.1/lib/snmp/manager.rb:491: warning: nil
/var/lib/gems/1.9.1/gems/snmp-1.1.1/lib/snmp/manager.rb:491: warning: nil
SNMP::RequestTimeout: host 10.20.1.86 not responding
from /var/lib/gems/1.9.1/gems/snmp-1.1.1/lib/snmp/manager.rb:282:in `get_bulk'
[3] pry(main)> s.get_bulk(0, 33, '1.0.8802.1.1.2.1.1.7.1.1.1.4.5.79.68.188')
=> #<SNMP::Response:0x9e1fb50
@error_index=0,
@error_status=0,
....
....
Completely reproducible, not sure what is going on. From CLI snmpbulkget with -Cr 34 works great.
snmp (1.1.1)
ruby 1.9.3p194 (2012-04-20 revision 35410) [i686-linux]
iso.3.6.1.2.1.1.1.0 = STRING: "Arista Networks EOS version 4.12.5.1 running on an Arista Networks DCS-7508"
As it stands, you can only pass one mib folder into TrapManager.new(...)
so either you use the YAML mibs that ship with ruby-snmp, or your own
(you can't have both).
If load_module wasn't private, I'd be able to call it after
the trap handler was initialized and load extra MIBs in.
[ have tested this with a monkey patch and it does work, is there
a reason that can't be tweaked? ]
When a object is compared with SNMP::Integer to_i is called on this object, which doesn't seem like correct behaviour.
For example:
When comparing a SNMP::Integer object with SNMP::NoSuchInstance on the right side an error is produced and when comparing a SNMP::Integer object with SNMP::NoSuchInstance on the left side the expected result false is returned.
See proof in rails console:
> irb(main):043:0> r = snmp_manager.get_value('IF-MIB::ifIndex.43')
> => #<SNMP::Integer:0x39c4f5c @value=43>
> irb(main):044:0> r == SNMP::NoSuchInstance
> NoMethodError: undefined method `to_i' for SNMP::NoSuchInstance:Class
> irb(main):045:0> SNMP::NoSuchInstance == r
> => false
This is seen in snmp version 1.2.0
I am using ruby-snmp to send traps however we are experiencing issues passing through firewalls, the vendor have recommended that we try to increase the initial TTL on the host originating the traffic to 'TTL > 30'. Is it possible to change the TTL setting used by ruby-snmp?
To make Manager load_module more flexible and consistent with MIB load_module, I suggest the following change, this will not impact current code
change -
def load_module(name)
@mib.load_module(name)
end
to -
def load_module(name, mib_dir=MIB::DEFAULT_MIB_PATH)
@mib.load_module(name, mib_dir)
end
manager.get(["1.3.6.1.4.1.674.10892.5.4.600.60.1.7.1.1"]) works
manager.walk(["1.3.6.1.4.1.674.10892.5.4.600.60.1.7.1.1"]) has no results (same oid)
manager.walk(["1.3.6.1.4.1.674.10892.5.4.600.60.1.7.1"]) works too, giving one result. (oid less last .1)
I noticed this a while ago, and changed to using get for the leaf node oids. Then forgot all about it and spent hours yesterday trying to work out why my code wouldn't work, then remembered coming across this a long time ago.
SNMP version 1.2.0
If get_bulk is called with a non_repeaters parameter greater than 18 it fails with
pdu.rb:181:in `error_status=': 19 (SNMP::InvalidErrorStatus)
get_bulk calls GetBulkRequest.new with the non_repeaters count in the error_status parameter. When PDU.initialize tries to assign it to self.error_status the error_status= routine tries to decode it and since it is our of range (max valid error_status is 18) it throws the exception.
When I load a custom mib file provided by enterprise, I got an error from smidump:
smidump: module `/media/sf_Documents/marmot/fortigate/monit-ng/data/APACHE-MIB.mib' contains errors, expect flawed output
I tried several mib files from different enterprises, the message are same.
What's more critical is that, I found all oids loaded by SNMP:MIB.load_module are incorrect, they are as following:
...
"groups" : {
"apScoreBoardGroup" : {
"nodetype" : "group",
"moduleName" : "APACHE-MIB",
"oid" : "0.4.2.2.1",
"status" : "current",
"members" : {
"apScoreBoardProcessId" : {
"nodetype" : "member",
"module" : "APACHE-MIB"
},
...
The oid is missing prefix of ' 1.3.6.1.4.1.', which indicates the tree iso.org.xxxx.private.enterprises
I'm not sure why it is, I just followed the example code as it is in the github.
Thanks for your attention.
Hi guys
I want to add some error handling to my code - I'm only looking for specific OIDs so if they aren't present, either the application isn't running, or it isn't installed - What's the best way to test for this, and prevent my code from spazzing out?
At the moment I just get a fatal timeout when issuing a get or a get-next, which isn't ideal. I'd rather just break or exit cleanly.
Hi, is your license the same as Ruby 1.8 (GPLv2+ or Ruby) or Ruby 1.9 (BSD or Ruby)?
Thanks for the clarification,
Bohuslav.
snmptrapd
from net-snmp offers a configuration option wherein traps are not checked for any authorization information, thereby enabling reception and processing of all traps. It appears that this option is not supported by ruby-snmp.
I have a program that uses ruby threads to open a large number of SNMP::Manager threads for simultaneous snmpget from different hosts. The program fails with the error below:
/usr/local/Cellar/ruby/1.9.2-p290/lib/ruby/gems/1.9.1/gems/snmp-1.0.4/lib/snmp/mib.rb:147:in initialize': Too many open files - /usr/local/Cellar/ruby/1.9.2-p290/lib/ruby/gems/1.9.1/gems/snmp-1.0.4/data/ruby/snmp/mibs/TCP-MIB.yaml (Errno::EMFILE) from /usr/local/Cellar/ruby/1.9.2-p290/lib/ruby/gems/1.9.1/gems/snmp-1.0.4/lib/snmp/mib.rb:147:in
open'
from /usr/local/Cellar/ruby/1.9.2-p290/lib/ruby/gems/1.9.1/gems/snmp-1.0.4/lib/snmp/mib.rb:147:in load_module' from /usr/local/Cellar/ruby/1.9.2-p290/lib/ruby/gems/1.9.1/gems/snmp-1.0.4/lib/snmp/manager.rb:483:in
block in load_modules'
from /usr/local/Cellar/ruby/1.9.2-p290/lib/ruby/gems/1.9.1/gems/snmp-1.0.4/lib/snmp/manager.rb:483:in each' from /usr/local/Cellar/ruby/1.9.2-p290/lib/ruby/gems/1.9.1/gems/snmp-1.0.4/lib/snmp/manager.rb:483:in
load_modules'
from /usr/local/Cellar/ruby/1.9.2-p290/lib/ruby/gems/1.9.1/gems/snmp-1.0.4/lib/snmp/manager.rb:191:in initialize' from /usr/local/Cellar/ruby/1.9.2-p290/lib/ruby/gems/1.9.1/gems/snmp-1.0.4/lib/snmp/manager.rb:201:in
new'
from /usr/local/Cellar/ruby/1.9.2-p290/lib/ruby/gems/1.9.1/gems/snmp-1.0.4/lib/snmp/manager.rb:201:in `open'
I do realize that I am not using the latest version of ruby-snmp, but I believe the problem also exists in the latest version because SNMP::Manager constructor always creates a new SNMP::MIB instance, which includes a call to load_modules. This is very inefficient when a large number of SNMP::Manager instances need to be created simultaneously.
I suggest that you make it possible for different SNMP::Manager instances to share one SNMP::MIB instance across different threads. To maintain backward compatibility, you can add a new optional argument, say :mib, for SNMP::Manager constructor. The default value for :mib would be nil, for which the SNMP::Manager constructor will create a new SNMP::MIB instance. If :mib is not nil, then SNMP::Manager will try to use it and throw an exception if the :mib value is not an SNMP::MIB object.
Please let me know what you think of this suggestion.
Thank you for the excellent gem.
manager.rb file has a logic error on line 136:
config.use_IPv6 ? UDPTransport.new : UDPTransport.new(Socket::AF_INET6)
should be changed to:
config.use_IPv6 ? UDPTransport.new(Socket::AF_INET6) : UDPTransport.new
It seems, that although the MIBS are found when I start logstash in Debug, the OIDs are not translated correctly.
"FSC-SERVERCONTROL2-MIB::sc2TrapInfoServerName.0" => "XXXXXX",
"@timestamp" => 2017-06-22T12:45:53.984Z,
"SNMPv2-SMI::snmpModules.1.1.4.3.0" => "FSC-SERVERCONTROL2-MIB::sc2Notifications",
"DISMAN-EVENT-MIB::sysUpTimeInstance" => "11:45:22.43",
"FSC-SERVERCONTROL2-MIB::sc2TrapInfoTime.0" => "0",
"host" => "XXXXXX",
"@version" => "1",
"SNMPv2-SMI::snmpModules.1.1.4.1.0" => "FSC-SERVERCONTROL2-MIB::sc2TrapTest",
"message" => .........
The SNMPv2-SMI::snmpModules.1.1.4.3.0 and SNMPv2-SMI::snmpModules.1.1.4.1.0 doesn't seem to be correct, as when I log with snmptrapd it is called:
2017-06-22 10:15:52 SNMPv: 1 Host: XXXXXX [UDP: [XXXXXX]:60992->[XXXXX]:162]:DISMAN-EXPRESSION-MIB::sysUpTimeInstance = Timeticks: (4216045) 11:42:40.45 SNMPv2-MIB::snmpTrapOID.0 = OID: FSC-SERVERCONTROL2-MIB::sc2TrapTest FSC-SERVERCONTROL2-MIB::sc2TrapInfoServerName.0 = STRING: "XXXXXXX" FSC-SERVERCONTROL2-MIB::sc2TrapInfoTime.0 = INTEGER: 0 SNMPv2-MIB::snmpTrapEnterprise.0 = OID: FSC-SERVERCONTROL2-MIB::sc2Notifications
Anybody know to fix this?
I'm a ruby beginner, "gem install snmp" is executed successfully, and after execute "gem list", I can find right result "snmp 1.1.0".
When I execute a sample,it print "in 'require': no such file to load--snmp "
I don't know the reason.
Please help me,thank you very much!
Hi, does ruby-snmp
support AgentX
?
I think about writing a small daemon using dbus
+ agentx
to monitor systemd
-services. Something similar to https://github.com/joonty/systemd_mon.
I've found a serious memory leak with opening snmp manager. Tested with latest version 1.0.4.
The easiest to demonstrate is to run irb and type:
1000.times {SNMP::Manager.open(:Host => '192.168.6.66', :Version => :SNMPv1) {|x| }}
Now watch the memory consumption, it just keeps increasing. The host does not even have to exist to demonstrate this leak.
The current behavior is:
ruby-1.9.2-p290 :039 > manager.get(["sysServices.0"])
=> #<SNMP::Response:0x87aa104 @request_id=1640585410, @error_status=0, @error_index=0, @varbind_list=[[name=1.3.6.1.2.1.1.7.0, value=72 (INTEGER)]]>
The name "sysServices.0" has been translated to its OID in the response. I'm wondering if it could be possible to add an optional argument to get so names would be returned in the response, not OIDs.
Same would apply to walk, ie. well known OIDs would be returned as their human-friendly names.
Thanks!
For example:
def test
manager.walk(['test']) do |row|
row.each {|vb| return vb}
end
end
vb = test()
Now I'm able to run to_s and see the name there, so far so good:
[6] pry(main)> vb.to_s
=> "[name=TEST-COMMON-MIB::testGeneralIndex.3, value=3 (INTEGER)]"
[7] pry(main)>
Great, now I want to get just the name, or "TEST-COMMON-MIB::testGeneralIndex.3":
[7] pry(main)> vb.name
=> [1, 3, 6, 1, 4, 1, 6548, 2, 1, 1, 1, 1, 3]
But it returns the "oid" representation, not the string name as above :( -- Any way to get the name?
In discovery situations, it's quite common to make a broadcast request to find which devices are available in the network. At the moment ruby-snmp doesn't support it.
As far as I can see, three things need to happen for discovery to be possible with ruby-snmp. VarBind objects need to have an origin field, which contains the IP address of the reply, new transport needs to be created (based on UDPTransport) which sets SO_BROADCAST socket option and finally get needs to be updated to allow multiple replies.
Here is some example code and the response to illustrate the problem. I am trying to use this code within a much larger telemetry collection system that isn't designed to deal with snmp. I would like to walk a table and then handle an array of the varbinds from the table with the upper level telemetry collection process verses call the parser every time.
require 'snmp'
include SNMP
all_resp = []
SNMP::Manager.open(:host => "172.31.100.111", :Community => "Amal-ups", :Version => :SNMPv1) do |manager|
manager.walk("1.3.6.1.4.1.534.1.3.4", 0) do |response|
puts ">> #{response.name}, value = #{response.value}"
if response.is_a? VarBind
p "I think I found a VarBind!"
end
if response.is_a? SNMP::Response
puts "I found an SNMP::Response!"
end
all_resp.push(response)
puts response
end
all_resp.each do | varbind |
p varbind # This will show the value is null!
p varbind.name
p varbind.value
end
end
> -bash-4.2$ ruby snmp_test.rb
>> SNMPv2-SMI::enterprises.534.1.3.4.1.1.1, value = 1
"I think I found a VarBind!"
[name=SNMPv2-SMI::enterprises.534.1.3.4.1.1.1, value=1 (INTEGER)]
>> SNMPv2-SMI::enterprises.534.1.3.4.1.1.2, value = 2
"I think I found a VarBind!"
[name=SNMPv2-SMI::enterprises.534.1.3.4.1.1.2, value=2 (INTEGER)]
>> SNMPv2-SMI::enterprises.534.1.3.4.1.1.3, value = 3
"I think I found a VarBind!"
[name=SNMPv2-SMI::enterprises.534.1.3.4.1.1.3, value=3 (INTEGER)]
>> SNMPv2-SMI::enterprises.534.1.3.4.1.2.1, value = 118
"I think I found a VarBind!"
[name=SNMPv2-SMI::enterprises.534.1.3.4.1.2.1, value=118 (INTEGER)]
>> SNMPv2-SMI::enterprises.534.1.3.4.1.2.2, value = 119
"I think I found a VarBind!"
[name=SNMPv2-SMI::enterprises.534.1.3.4.1.2.2, value=119 (INTEGER)]
>> SNMPv2-SMI::enterprises.534.1.3.4.1.2.3, value = 119
"I think I found a VarBind!"
[name=SNMPv2-SMI::enterprises.534.1.3.4.1.2.3, value=119 (INTEGER)]
>> SNMPv2-SMI::enterprises.534.1.3.4.1.3.1, value = 15
"I think I found a VarBind!"
[name=SNMPv2-SMI::enterprises.534.1.3.4.1.3.1, value=15 (INTEGER)]
>> SNMPv2-SMI::enterprises.534.1.3.4.1.3.2, value = 11
"I think I found a VarBind!"
[name=SNMPv2-SMI::enterprises.534.1.3.4.1.3.2, value=11 (INTEGER)]
>> SNMPv2-SMI::enterprises.534.1.3.4.1.3.3, value = 14
"I think I found a VarBind!"
[name=SNMPv2-SMI::enterprises.534.1.3.4.1.3.3, value=14 (INTEGER)]
#<SNMP::VarBind:0x00000000022b1068 @name=[1.3.6.1.4.1.534.1.3.4.1.1.1], @value=SNMP::Null>
[1.3.6.1.4.1.534.1.3.4.1.1.1]
SNMP::Null
#<SNMP::VarBind:0x0000000002295e30 @name=[1.3.6.1.4.1.534.1.3.4.1.1.2], @value=SNMP::Null>
[1.3.6.1.4.1.534.1.3.4.1.1.2]
SNMP::Null
#<SNMP::VarBind:0x000000000228cbf0 @name=[1.3.6.1.4.1.534.1.3.4.1.1.3], @value=SNMP::Null>
[1.3.6.1.4.1.534.1.3.4.1.1.3]
SNMP::Null
#<SNMP::VarBind:0x00000000025887a0 @name=[1.3.6.1.4.1.534.1.3.4.1.2.1], @value=SNMP::Null>
[1.3.6.1.4.1.534.1.3.4.1.2.1]
SNMP::Null
#<SNMP::VarBind:0x00000000025522b8 @name=[1.3.6.1.4.1.534.1.3.4.1.2.2], @value=SNMP::Null>
[1.3.6.1.4.1.534.1.3.4.1.2.2]
SNMP::Null
#<SNMP::VarBind:0x000000000253d480 @name=[1.3.6.1.4.1.534.1.3.4.1.2.3], @value=SNMP::Null>
[1.3.6.1.4.1.534.1.3.4.1.2.3]
SNMP::Null
#<SNMP::VarBind:0x0000000002533a70 @name=[1.3.6.1.4.1.534.1.3.4.1.3.1], @value=SNMP::Null>
[1.3.6.1.4.1.534.1.3.4.1.3.1]
SNMP::Null
#<SNMP::VarBind:0x00000000024b3c30 @name=[1.3.6.1.4.1.534.1.3.4.1.3.2], @value=SNMP::Null>
[1.3.6.1.4.1.534.1.3.4.1.3.2]
SNMP::Null
#<SNMP::VarBind:0x000000000248d260 @name=[1.3.6.1.4.1.534.1.3.4.1.3.3], @value=SNMP::Null>
[1.3.6.1.4.1.534.1.3.4.1.3.3]
SNMP::Null
-bash-4.2$
I configured an snmp trap with: snmptrap -c public -v 2c 127.0.0.1:1062 "" 1.3.6.1.4.1.5815.1.7.1.2.1.2 1.3.6.1.4.1.5815.1.7.1.2.1.2 x "07 e4 0a 0e 12 09 21 00 2b 00 00"
so the data type for "07 e4 0a 0e 12 09 21 00 2b 00 00" is hex string and is decoded to something like: \a\xE4\n\x0E\x12\t!\x00+\x00\x00.. could anyone help on this?
For some hosts, if :ignore_oid_order=>true, I'm getting an infinite loop from walk, with the last oid being returned over and over, but with a NULL value, after the first time.
When :ignore_oid_order=>false, then for these same hosts, I get "warning: OIDs are not increasing, ...', and the oid given in the error is the last one I got.
Comparing the output with the snmpwalk client, I get 'End of MIB' at the end of the output for the hosts that the gem loops infinitely for, but not for the hosts that work with the snmp gem.
snmpwalk only prints 'End of MIB' when it gets a no such name response.
Ruby test code
ifTable_columns = ["SNMPv2-SMI::enterprises.41112.1.4.7.1"] #Newer firmware on rest of routers. SNMP::Manager.open(:host => host_ip, :community => "#{community}", :version => :SNMPv1, :ignore_oid_order=>true ) do |manager| manager.walk(ifTable_columns) do |row| puts row end end
Outputting:
[name=SNMPv2-SMI::enterprises.41112.1.4.7.1.1.1.0.21.109.26.46.109, value=m.m (OCTET STRING)] [name=SNMPv2-SMI::enterprises.41112.1.4.7.1.2.1.0.21.109.26.46.109, value=wikk-b17 (OCTET STRING)] [name=SNMPv2-SMI::enterprises.41112.1.4.7.1.3.1.0.21.109.26.46.109, value=-60 (INTEGER)] [name=SNMPv2-SMI::enterprises.41112.1.4.7.1.4.1.0.21.109.26.46.109, value=-86 (INTEGER)] [name=SNMPv2-SMI::enterprises.41112.1.4.7.1.5.1.0.21.109.26.46.109, value=1350 (INTEGER)] [name=SNMPv2-SMI::enterprises.41112.1.4.7.1.6.1.0.21.109.26.46.109, value=98 (INTEGER)] [name=SNMPv2-SMI::enterprises.41112.1.4.7.1.7.1.0.21.109.26.46.109, value=0 (INTEGER)] [name=SNMPv2-SMI::enterprises.41112.1.4.7.1.8.1.0.21.109.26.46.109, value=95 (INTEGER)] [name=SNMPv2-SMI::enterprises.41112.1.4.7.1.9.1.0.21.109.26.46.109, value=86 (INTEGER)] [name=SNMPv2-SMI::enterprises.41112.1.4.7.1.10.1.0.21.109.26.46.109, value=100.64.0.241 (IpAddress)] [name=SNMPv2-SMI::enterprises.41112.1.4.7.1.11.1.0.21.109.26.46.109, value=175500000 (INTEGER)] [name=SNMPv2-SMI::enterprises.41112.1.4.7.1.12.1.0.21.109.26.46.109, value=195000000 (INTEGER)] [name=SNMPv2-SMI::enterprises.41112.1.4.7.1.13.1.0.21.109.26.46.109, value=85369496756 (Counter64)] [name=SNMPv2-SMI::enterprises.41112.1.4.7.1.14.1.0.21.109.26.46.109, value=11572287085 (Counter64)] [name=SNMPv2-SMI::enterprises.41112.1.4.7.1.15.1.0.21.109.26.46.109, value=3 days, 20:01:47.00 (TimeTicks)] [name=SNMPv2-SMI::enterprises.41112.1.4.7.1.15.1.0.21.109.26.46.109, value=Null (Null)] [name=SNMPv2-SMI::enterprises.41112.1.4.7.1.15.1.0.21.109.26.46.109, value=Null (Null)] [name=SNMPv2-SMI::enterprises.41112.1.4.7.1.15.1.0.21.109.26.46.109, value=Null (Null)] ...
The command line snmpwalk output.
Note 'End of MIB' is printed. See (https://github.com/winlibs/net-snmp/blob/master/apps/snmpwalk.c)
root@db:/tmp # snmpwalk -c xxxxx -v 1 xxxxxx SNMPv2-SMI::enterprises.41112.1.4.7.1 SNMPv2-SMI::enterprises.41112.1.4.7.1.1.1.0.21.109.26.46.109 = Hex-STRING: 00 15 6D 1A 2E 6D SNMPv2-SMI::enterprises.41112.1.4.7.1.2.1.0.21.109.26.46.109 = STRING: "wikk-b17" SNMPv2-SMI::enterprises.41112.1.4.7.1.3.1.0.21.109.26.46.109 = INTEGER: -59 SNMPv2-SMI::enterprises.41112.1.4.7.1.4.1.0.21.109.26.46.109 = INTEGER: -86 SNMPv2-SMI::enterprises.41112.1.4.7.1.5.1.0.21.109.26.46.109 = INTEGER: 1350 SNMPv2-SMI::enterprises.41112.1.4.7.1.6.1.0.21.109.26.46.109 = INTEGER: 98 SNMPv2-SMI::enterprises.41112.1.4.7.1.7.1.0.21.109.26.46.109 = INTEGER: 0 SNMPv2-SMI::enterprises.41112.1.4.7.1.8.1.0.21.109.26.46.109 = INTEGER: 95 SNMPv2-SMI::enterprises.41112.1.4.7.1.9.1.0.21.109.26.46.109 = INTEGER: 89 SNMPv2-SMI::enterprises.41112.1.4.7.1.10.1.0.21.109.26.46.109 = IpAddress: 100.64.0.241 SNMPv2-SMI::enterprises.41112.1.4.7.1.11.1.0.21.109.26.46.109 = INTEGER: 195000000 SNMPv2-SMI::enterprises.41112.1.4.7.1.12.1.0.21.109.26.46.109 = INTEGER: 195000000 SNMPv2-SMI::enterprises.41112.1.4.7.1.13.1.0.21.109.26.46.109 = Counter64: 85737329070 SNMPv2-SMI::enterprises.41112.1.4.7.1.14.1.0.21.109.26.46.109 = Counter64: 11594182988 SNMPv2-SMI::enterprises.41112.1.4.7.1.15.1.0.21.109.26.46.109 = Timeticks: (33290500) 3 days, 20:28:25.00 End of MIB
The following piece of code has been running in an application which survived transitioning from Ruby 1.9 to 2.0, 2.1 and now 2.2.
# SNMP has a mechanism for letting us know if we've hit the end of
# a walk. If that's true, then we'll return
if last_value == SNMP::EndOfMibView
return
end
After the upgrade to Ruby 2.2, however, I started observing the following warnings in our logs:
/path/to/protocol.rb:448: warning: Comparable#== will no more rescue exceptions of #<=> in the next release.
/path/to/protocol.rb:448: warning: Return nil in #<=> if the comparison is inappropriate or avoid such comparison.
This seems to be related to this Ruby change, which made it to Ruby 2.2 -- https://bugs.ruby-lang.org/issues/7688. Other projects have been affected as well (I found a nice drill down on this on RubyMoney/money#469).
I can avoid the warning if we use if last_value.is_a?(SNMP::EndOfMibView)
instead of the previous idiom, but a proper 2.2-compatible update to snmp
would be more desirable. I tried digging down the source code to submit a pull request, but it's not clear to me what exactly would need to be touched.
The -k
option is only available in libsmi-0.4.6
, and should be noted somewhere as a requirement.
I'm having no luck at all using the win32 versions of smidump - it packs a sad as we're got a huge number imports in our various mibs -
Net-SNMP has no problem reading them, and they're successfully imported, but I'm getting regular crashes trying anything else more clever
Any thoughts on deploying manually created yaml files (or deploying them with the app) so that I can just import them onto a vanilla system?
I'm trying to pull back some reasonably sized tables of data, and chunter through them with ruby-snmp so thought that the processing of the data would be the hardest part.
Attached is a diff patch that uses some code from IPAddr to add the IpAddressV6 to varbind. You are welcome to use this code as you please.
Jeff F>
varbind-IpAddressV6.zip
In SNMPv1 trap handler, I couldn't get symbolic name from enterprise
attribute of SNMPv1_Trap
with ObjectId#to_s
method.
I assume that the enterprise
attribute is initialized without MIB information.
https://github.com/hallidave/ruby-snmp/blob/master/lib/snmp/pdu.rb#L328
I got the following error in Logstash SNMP output plugin:
{:error=>#<Encoding::CompatibilityError: incompatible encodings: ASCII-8BIT and UTF-8>, :backtrace=>["org/jruby/RubyString.java:2630:in
concat'", "/usr/share/logstash/vendor/bundle/jruby/1.9/gems/snmp-1.2.0/lib/snmp/ber.rb:305:in
encode_tlv'",
"/usr/share/logstash/vendor/bundle/jruby/1.9/gems/snmp-1.2.0/lib/snmp/ber.rb:313:inencode_octet_string'", "/usr/share/logstash/vendor/bundle/jruby/1.9/gems/snmp-1.2.0/lib/snmp/varbind.rb:140:in
encode'", "/usr/share/logstash/vendor/bundle/jruby/1.9/gems/snmp-1.2.0/lib/snmp/varbind.rb:612:inencode'", "/usr/share/logstash/vendor/bundle/jruby/1.9/gems/snmp-1.2.0/lib/snmp/varbind.rb:67:in
encode'", "org/jruby/RubyArray.java:1613:ineach'", "/usr/share/logstash/vendor/bundle/jruby/1.9/gems/snmp-1.2.0/lib/snmp/varbind.rb:66:in
encode'", "/usr/share/logstash/vendor/bundle/jruby/1.9/gems/snmp-1.2.0/lib/snmp/pdu.rb:194:inencode_pdu'", "/usr/share/logstash/vendor/bundle/jruby/1.9/gems/snmp-1.2.0/lib/snmp/pdu.rb:260:in
encode'", "/usr/share/logstash/vendor/bundle/jruby/1.9/gems/snmp-1.2.0/lib/snmp/pdu.rb:123:inencode'", "/usr/share/logstash/vendor/bundle/jruby/1.9/gems/snmp-1.2.0/lib/snmp/manager.rb:519:in
send_request'", "/usr/share/logstash/vendor/bundle/jruby/1.9/gems/snmp-1.2.0/lib/snmp/manager.rb:366:intrap_v2'", "/usr/share/logstash/vendor/local_gems/7292f880/logstash-output-snmptrap-0.9.3/lib/logstash/outputs/snmptrap.rb:64:in
register'", "/usr/share/logstash/vendor/bundle/jruby/1.9/gems/snmp-1.2.0/lib/snmp/manager.rb:218:in `open'"
I'm not sure whether this should be something handled by this library. I'm also not very familiar with ASN.1, so forgive any inaccuracies here.
An object can have a syntax of DateAndTime
, which is defined as a macro in SNMPv2-TC. If you receive a trap with one of these objects and do something like varbind.value.to_s, you receive an exception such as Encoding::UndefinedConversionError: ""\xDE"" from ASCII-8BIT to UTF-8
. The macro defines a DISPLAY-HINT 2d-1d-1d,1d:1d:1d.1d,1a1d:1d
for displaying the string. I expect to_s
to convert the raw octet string to this format.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.