Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Sample to gather stats using SNMP (process list is valid only for Sun Solaris operating System)
require 'snmp'
require 'ipaddress'
include SNMP
# ARGV[0] is an IP address or a network in CIDR notation
raise "Missing IP address or network" if ARGV[0].nil?
@list = IPAddress.parse(ARGV[0])
@list.each do |ip|
puts "Asking #{ip.to_s} for info using 'public' SNMP community" => ip.to_s, :Community => 'public') do |manager|
response = manager.get([""),"")])
response.each_varbind do |vb|
puts "#{} #{vb.value.to_s} #{vb.value.asn1_type}"
# Sun Process Table -
processTable ="")
manager.walk(processTable) { |varbind| puts "#{varbind.value.to_s}" if"SNMPv2-SMI::enterprises.")}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.