Skip to content

Instantly share code, notes, and snippets.

@hirolovesbeer
Created September 3, 2015 03:59
Show Gist options
  • Save hirolovesbeer/d0aaa5c864c793cbd485 to your computer and use it in GitHub Desktop.
Save hirolovesbeer/d0aaa5c864c793cbd485 to your computer and use it in GitHub Desktop.
require 'snmp'
require 'fluent-logger'
require 'pp'
log = Fluent::Logger::FluentLogger.new(nil, :host=>'192.168.0.20', :port=>4000)
hosts = ['192.168.0.10',
'192.168.0.11',
'192.168.0.12',
'192.168.0.13',
'192.168.0.14',
'192.168.0.15',
'192.168.0.16',
'192.168.0.17',
'192.168.0.18',
'192.168.0.19']
hosts.each {|host|
SNMP::Manager.open(:host => host, :community => "hogehoge") do |manager|
begin
response = manager.get(["1.3.6.1.4.1.9.9.273.1.1.2.1.1.1"])
response.each_varbind do |vb|
puts host + ":2.4g=".to_s.to_s + vb.value.to_s
unless log.post("ap.24g", {"ap"=>host, "value"=>vb.value.to_i})
pp log.last_error
end
end
rescue => e
pp e
end
begin
response = manager.get(["1.3.6.1.4.1.9.9.273.1.1.2.1.1.2"])
response.each_varbind do |vb|
puts host + ":5g=" + vb.value.to_s
unless log.post("ap.5g", {"ap"=>host, "value"=>vb.value.to_i})
pp log.last_error
end
end
rescue => e
pp e
end
end
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment