Module: SNMP
- Included in:
- Inari::Commands
- Defined in:
- lib/inari/commands/snmp.rb
Instance Method Summary collapse
- #get_snmp_in(interface) ⇒ Object
-
#get_snmp_out(interface) ⇒ Object
SNMP commands.
- #snmp_walk ⇒ Object
Instance Method Details
#get_snmp_in(interface) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/inari/commands/snmp.rb', line 12 def get_snmp_in(interface) snmp_walk().each do |snmp_data| return snmp_data[3].to_i if (snmp_data[1] == interface.to_s) end return 0 end |
#get_snmp_out(interface) ⇒ Object
SNMP commands
5 6 7 8 9 10 |
# File 'lib/inari/commands/snmp.rb', line 5 def get_snmp_out(interface) snmp_walk().each do |snmp_data| return snmp_data[2].to_i if (snmp_data[1] == interface.to_s) end return 0 end |
#snmp_walk ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/inari/commands/snmp.rb', line 19 def snmp_walk() columns, values, snmp_data = ['ifIndex', 'ifDescr', 'ifInOctets', 'ifOutOctets'], [], [] SNMP::Manager.open(:Host => 'mon') do |manager| manager.walk(columns) do |row| row.each { |vb| values << vb.value } end values.each_slice(4) { |slice| snmp_data << slice } end snmp_data end |