class

SNMP::Client

Inherits Reference / Object

Constructors

new(host : String, session : SNMP::Session | SNMP::V3::Session, timeout : Int32 = 3, port : Int32 = 161)
Source
new(host : String, community = "public", timeout : Int32 = 3, port : Int32 = 161)
Source

Class methods

oid_within?(oid : String, base : String) : Bool

True when oid is the base subtree or a descendant of it. Compares OID arcs, not the raw string, so a sibling column (e.g. .10) that merely shares a string prefix with .1 is not treated as a child.

Source

Instance methods

bulk_walk(oid : String, max_repetitions = 10, &)

Walk oid's subtree using GetBulk (fewer round-trips than GetNext), yielding each in-subtree VarBind. Stops at endOfMibView or the first varbind that leaves the subtree. max_repetitions bounds the varbinds fetched per request.

Source
bulk_walk(oid : String, max_repetitions = 10) : Array(SNMP::VarBind)

Non-block form: collect the whole subtree into an array of VarBind.

Source
close

Close the underlying UDP socket. The next request reconnects transparently. A Client is not safe for concurrent use — use one per fiber.

Source

Multi-varbind Get: one round-trip binding every OID; the Response carries a varbind per requested OID.

Source
get_bulk(oids : Enumerable(String), non_repeaters = 0, max_repetitions = 10) : SNMP::Message

GetBulk: one round-trip returning up to max_repetitions successors per repeating OID. Returns the raw Response message (its PDU holds every varbind).

Source
get_next(oid : String) : SNMP::Message
Source
get_next(oids : Enumerable(String)) : SNMP::Message

Multi-varbind GetNext: advances every supplied OID in one round-trip.

Source
host
Source
port
Source
send_inform(oid : String, uptime = 0, varbinds : Array(SNMP::VarBind) = [] of SNMP::VarBind) : SNMP::Message

Send an Inform and return the receiver's acknowledging Response.

Source
send_trap_v1(enterprise : String, agent_address : String, generic_trap : SNMP::GenericTrap, specific_trap = 0, uptime = 0, varbinds : Array(SNMP::VarBind) = [] of SNMP::VarBind) : Nil

Send an SNMPv1 Trap (RFC 1157). Fire-and-forget.

Source
send_trap_v2(oid : String, uptime = 0, varbinds : Array(SNMP::VarBind) = [] of SNMP::VarBind) : Nil

Send an SNMPv2-Trap to the configured host/port (typically a trap sink on 162). Fire-and-forget: a trap is unacknowledged, so nothing is read back.

Source
session
Source
set(oid : String, value) : SNMP::Message

Set a single OID to value (a typed SNMP value, a Crystal primitive, or a raw ASN1::BER) and return the agent's Response.

Source
set(values : Hash(String, _)) : SNMP::Message

Multi-varbind Set: assign every OID => value pair in one round-trip.

Source
socket
Source
timeout
Source
walk(oid : String) : Array(SNMP::Message)

Collect a subtree into an array. NOTE: this buffers every message in memory; for large subtrees prefer the block form below or #bulk_walk, which stream.

Source
walk(oid : String, &)
Source

Nested types