Class: NETSNMP::Session
- Inherits:
-
Object
- Object
- NETSNMP::Session
- Defined in:
- lib/netsnmp/session.rb
Overview
Let’s just remind that there is no session in snmp, this is just an abstraction.
Direct Known Subclasses
Defined Under Namespace
Classes: Transport
Constant Summary collapse
- TIMEOUT =
2
Instance Method Summary collapse
-
#build_pdu(type, *vars) ⇒ NETSNMP::PDU
A pdu.
-
#close ⇒ Object
Closes the session.
-
#initialize(version: 1, community: "public", **options) ⇒ Session
constructor
A new instance of Session.
-
#send(pdu) ⇒ NETSNMP::PDU
send a pdu, receives a pdu.
Constructor Details
#initialize(version: 1, community: "public", **options) ⇒ Session
Returns a new instance of Session.
9 10 11 12 13 |
# File 'lib/netsnmp/session.rb', line 9 def initialize(version: 1, community: "public", **) @version = 1 @community = community validate() end |
Instance Method Details
#build_pdu(type, *vars) ⇒ NETSNMP::PDU
Returns a pdu.
27 28 29 |
# File 'lib/netsnmp/session.rb', line 27 def build_pdu(type, *vars) PDU.build(type, headers: [ @version, @community ], varbinds: vars) end |
#close ⇒ Object
Closes the session
16 17 18 19 20 |
# File 'lib/netsnmp/session.rb', line 16 def close # if the transport came as an argument, # then let the outer realm care for its lifecycle @transport.close unless @proxy end |
#send(pdu) ⇒ NETSNMP::PDU
send a pdu, receives a pdu
37 38 39 40 41 |
# File 'lib/netsnmp/session.rb', line 37 def send(pdu) encoded_request = encode(pdu) encoded_response = @transport.send(encoded_request) decode(encoded_response) end |