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!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...