Class: SNMPPass::Script::PassPersist

Inherits:
Object
  • Object
show all
Includes:
SNMPPass::Script
Defined in:
lib/snmp_pass/script/pass_persist.rb

Overview

Handles a script which is invoked using the pass_persist directive in snmpd.conf.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(variable_store: SNMPPass::VariableStore.new) ⇒ PassPersist

Create a new pass_Persist.

Parameters:

  • variable_store (VariableStore) (defaults to: SNMPPass::VariableStore.new)

    the variable_store to use for storing the variables


19
20
21
# File 'lib/snmp_pass/script/pass_persist.rb', line 19

def initialize(variable_store: SNMPPass::VariableStore.new)
  @variable_store = variable_store
end

Instance Attribute Details

#runningObject (readonly)

Returns the value of attribute running


9
10
11
# File 'lib/snmp_pass/script/pass_persist.rb', line 9

def running
  @running
end

#variable_storeObject (readonly)

Returns the value of attribute variable_store


13
14
15
# File 'lib/snmp_pass/script/pass_persist.rb', line 13

def variable_store
  @variable_store
end

Instance Method Details

#runObject

Start watching and responding to commands on STDIN. If an exception occurs then absorb it and stop watching


25
26
27
28
29
30
31
32
33
# File 'lib/snmp_pass/script/pass_persist.rb', line 25

def run
  @running = true
  # Do not buffer stdout
  STDOUT.sync = true

  while @running
    one_once
  end
end

#running?Boolean

Check if the instance is watching for and responding to commands on STDIN.

Returns:

  • (Boolean)

42
43
44
# File 'lib/snmp_pass/script/pass_persist.rb', line 42

def running?
  @running || false
end

#stopObject

Stop watching and responding to commands on STDIN.


36
37
38
# File 'lib/snmp_pass/script/pass_persist.rb', line 36

def stop
  @running = false
end