#!/usr/bin/env ruby require 'pry' class StraceParser SYS_CALL_MATCHER = /\A[a-zA-Z_]*\(/ attr_accessor :file_lines def initialize(filepath) @file_lines = File.readlines(filepath).map(&:chomp) end def sys_calls @file_lines.map do |line| matches = line.match(SYS_CALL_MATCHER) # catch any non-sys-call-matches. maybe we can fix the regex but this is fine for now. sys_call = matches.to_s.chomp("(") unless matches.to_s == "" end.compact end def sys_call_counts sys_calls.group_by(&:itself).map {|k,v| [k, v.count] }.sort_by {|k,v|v}.reverse end def open_sys_calls end def read_sys_calls end def write_sys_calls end end