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!

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer at Splunk .conf24 ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...

Combine Multiline Logs into a Single Event with SOCK: a Step-by-Step Guide for ...

Combine multiline logs into a single event with SOCK - a step-by-step guide for newbies Olga Malita The ...