Method: IsMacIdle.net_traffic

Defined in:
lib/is_mac_idle.rb

.net_traffic(sec = 1) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/is_mac_idle.rb', line 14

def net_traffic(sec = 1)
  Open3.popen3("netstat -i -w #{sec}") do |i, o, e, th|
    o.gets
    o.gets
    a = o.gets.split.map(&:to_i)
    th.kill
    {in: a[2], out: a[5]}
  end
end