Class: Tochka::Agent
- Inherits:
-
Object
- Object
- Tochka::Agent
- Defined in:
- lib/tochka/agent.rb
Constant Summary collapse
- SOCKPATH =
"/var/run/captured.sock"- CMD_GET_STATUS =
"get_status"- CMD_START_CAPTURE =
"start_capture"- CMD_STOP_CAPTURE =
"stop_capture"- STATE_INIT =
"init"- STATE_RUNNING =
"running"- STATE_STOP =
"stop"- STATE_UNKNOWN =
"unknown"
Instance Attribute Summary collapse
-
#channel_walk ⇒ Object
readonly
Returns the value of attribute channel_walk.
-
#current_channel ⇒ Object
readonly
Returns the value of attribute current_channel.
-
#duration ⇒ Object
readonly
Returns the value of attribute duration.
-
#file_name ⇒ Object
readonly
Returns the value of attribute file_name.
-
#file_size ⇒ Object
readonly
Returns the value of attribute file_size.
-
#frame_count ⇒ Object
readonly
Returns the value of attribute frame_count.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
-
#utilization ⇒ Object
readonly
Returns the value of attribute utilization.
-
#utilization_channel ⇒ Object
readonly
Returns the value of attribute utilization_channel.
Instance Method Summary collapse
- #get_status ⇒ Object
-
#initialize ⇒ Agent
constructor
A new instance of Agent.
- #start_capture ⇒ Object
- #stop_capture ⇒ Object
Constructor Details
#initialize ⇒ Agent
Returns a new instance of Agent.
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/tochka/agent.rb', line 19 def initialize @state = STATE_INIT @file_name = "<None>" @file_size = 0 @duration = 0 @current_channel = 0 @channel_walk = 0 @frame_count = 0 @utilization = 0 @utilization_channel = 0 end |
Instance Attribute Details
#channel_walk ⇒ Object (readonly)
Returns the value of attribute channel_walk.
7 8 9 |
# File 'lib/tochka/agent.rb', line 7 def channel_walk @channel_walk end |
#current_channel ⇒ Object (readonly)
Returns the value of attribute current_channel.
7 8 9 |
# File 'lib/tochka/agent.rb', line 7 def current_channel @current_channel end |
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
7 8 9 |
# File 'lib/tochka/agent.rb', line 7 def duration @duration end |
#file_name ⇒ Object (readonly)
Returns the value of attribute file_name.
7 8 9 |
# File 'lib/tochka/agent.rb', line 7 def file_name @file_name end |
#file_size ⇒ Object (readonly)
Returns the value of attribute file_size.
7 8 9 |
# File 'lib/tochka/agent.rb', line 7 def file_size @file_size end |
#frame_count ⇒ Object (readonly)
Returns the value of attribute frame_count.
7 8 9 |
# File 'lib/tochka/agent.rb', line 7 def frame_count @frame_count end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
7 8 9 |
# File 'lib/tochka/agent.rb', line 7 def state @state end |
#utilization ⇒ Object (readonly)
Returns the value of attribute utilization.
7 8 9 |
# File 'lib/tochka/agent.rb', line 7 def utilization @utilization end |
#utilization_channel ⇒ Object (readonly)
Returns the value of attribute utilization_channel.
7 8 9 |
# File 'lib/tochka/agent.rb', line 7 def utilization_channel @utilization_channel end |
Instance Method Details
#get_status ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/tochka/agent.rb', line 31 def get_status resp = do_rpc(get_msg(CMD_GET_STATUS)) if resp["state"] != nil update_state(resp) return resp end # not responded? @state = STATE_UNKNOWN return {} rescue => e $log.err("agent detected unknown error in get_status (#{e})") return {} end |
#start_capture ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/tochka/agent.rb', line 46 def start_capture $log.info("requesting start_capture") resp = do_rpc(get_msg(CMD_START_CAPTURE)) resp = get_status() if resp["state"] == STATE_RUNNING update_state(resp) return true end # not responded or failed @state = STATE_UNKNOWN return false rescue => e $log.err("agent detected unknown error in start_capture (#{e})") return false end |
#stop_capture ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/tochka/agent.rb', line 63 def stop_capture $log.info("requesting stop_capture") resp = do_rpc(get_msg(CMD_STOP_CAPTURE)) resp = get_status() if resp["state"] == STATE_STOP update_state(resp) return true end return false rescue => e $log.err("agent detected unknown error in stop_capture (#{e})") return false end |