Class: Kanrisuru::Core::System::Parser::Ps
- Inherits:
-
Object
- Object
- Kanrisuru::Core::System::Parser::Ps
- Defined in:
- lib/kanrisuru/core/system/parsers/ps.rb
Class Method Summary collapse
Class Method Details
.build_process_list(rows) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/kanrisuru/core/system/parsers/ps.rb', line 19 def build_process_list(rows) rows.map do |row| values = *row.split(/\s+/, 15) values.shift if values[0] == '' Kanrisuru::Core::System::ProcessInfo.new( values[0].to_i, values[1], values[2].to_i, values[3], values[4].to_i, values[5].to_i, values[6].to_f, values[7].to_f, values[8], values[9].to_i, values[10].to_i, values[11], parse_policy_abbr(values[11]), values[12], values[13] ) end end |
.parse(command) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/kanrisuru/core/system/parsers/ps.rb', line 9 def parse(command) ## Have found issues with regular newline parsing from command ## most likely a buffer overflow from SSH buffer. ## Join string then split by newline. result_string = command.raw_result.join rows = result_string.split("\n") build_process_list(rows) end |
.parse_policy_abbr(value) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/kanrisuru/core/system/parsers/ps.rb', line 44 def parse_policy_abbr(value) case value when '-' 'not reported' when 'TS' 'SCHED_OTHER' when 'FF' 'SCHED_FIFO' when 'RR' 'SCHED_RR' when 'B' 'SCHED_BATCH' when 'ISO' 'SCHED_ISO' when 'IDL' 'SCHED_IDLE' when 'DLN' 'SCHED_DEADLINE' else 'unknown value' end end |