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.
10 11 12 13 14 |
# File 'lib/netsnmp/session.rb', line 10 def initialize(version: 1, community: "public", **) @version = version @community = community validate() end |
Instance Method Details
#build_pdu(type, *vars) ⇒ NETSNMP::PDU
Returns a pdu.
28 29 30 |
# File 'lib/netsnmp/session.rb', line 28 def build_pdu(type, *vars) PDU.build(type, headers: [@version, @community], varbinds: vars) end |
#close ⇒ Object
Closes the session
17 18 19 20 21 |
# File 'lib/netsnmp/session.rb', line 17 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
38 39 40 41 42 |
# File 'lib/netsnmp/session.rb', line 38 def send(pdu) encoded_request = encode(pdu) encoded_response = @transport.send(encoded_request) decode(encoded_response) end |