Getting Data In

Ruby SNMP CIM

ephemeric
Contributor

Greetz,

I know almost nothing about Ruby, could someone maybe assist by advising how to print the below
fields but for each value in each column concatenate the value with the CIM field (loosely named for now), like interface="ifDescr" in="ifInOctets" out="ifOutOctets"?

Thank you.

!/usr/bin/ruby

require 'rubygems'
require 'snmp'

ifTable_columns = ["ifDescr", "ifInOctets", "ifOutOctets"]
SNMP::Manager.open(:host => '10.0.0.10', :community => 'public') do |manager|
manager.walk(ifTable_columns) do |row|
row.each { |vb| print "\s#{vb.value}" }
puts
end
end

0 Karma
1 Solution

psanford_splunk
Splunk Employee
Splunk Employee

Hi - If you are new to ruby, our upcoming Ruby SDK release might be able to help you interface with Splunk. We can give you pre-release access now. Just send your GitHub ID to: devinfo@splunk.com

View solution in original post

fross_splunk
Splunk Employee
Splunk Employee

I see you figured it out, but the Ruby SDK for Splunk wouldn't be much help here. It's a core Ruby question, and not really something involving Splunk. There are a lot more Rubyists actively answering questions on Stackoverflow, so you'll probably get faster responses there.

0 Karma

ephemeric
Contributor

!/usr/bin/ruby

require 'rubygems'
require 'snmp'

SNMP::Manager.open(:host => '10.0.0.10', :community => 'public') do |manager|
manager.walk(["ifDescr", "ifInOctets", "ifOutOctets"]) do |descr, inoctets, outoctets|
puts "src_int=#{descr.value} bytes_in=#{inoctets.value} bytes_out=#{outoctets.value}"
end
end

0 Karma

psanford_splunk
Splunk Employee
Splunk Employee

Hi - If you are new to ruby, our upcoming Ruby SDK release might be able to help you interface with Splunk. We can give you pre-release access now. Just send your GitHub ID to: devinfo@splunk.com

ephemeric
Contributor

Wow! Thank you.

0 Karma
Get Updates on the Splunk Community!

Explore the Latest Educational Offerings from Splunk

At Splunk Education, we are committed to providing a robust learning experience for all users, regardless of ...

Meet Duke Cyberwalker | A hero’s journey with Splunk

We like to say, the lightsaber is to Luke as Splunk is to Duke. Curious yet? Then read Eric Fusilero’s latest ...

The Future of Splunk Search is Here - See What’s New!

We’re excited to introduce two powerful new search features, now generally available for Splunk Cloud Platform ...