Sha256: 0a8170a0100ce68f1ba8e091578e8401d2d1f8b5cf1af90b4ca5e083f94d847e
Contents?: true
Size: 592 Bytes
Versions: 9
Compression:
Stored size: 592 Bytes
Contents
#!/usr/bin/env ruby require 'json' require 'panoptimon/util' Panoptimon::Util.os(linux: true) head = [ 'rx bytes', 'rx packets', 'rx errs', 'rx drop', 'rx fifo', 'rx frame', 'rx compressed', 'rx multicast', 'tx bytes', 'tx packets', 'tx drops', 'tx fifo', 'tx colls', 'tx carrier', 'tx compressed' ] class Array; def to_h ; Hash[*self.flatten]; end; end state = File.read('/proc/net/dev'). split("\n").drop(2).map {|l| (iface, row) = *l.sub(/^\s+/, '').split(/:\s+/, 2) [iface, head.zip(row.split(/\s+/)).to_h] }.to_h puts JSON::generate(state)
Version data entries
9 entries across 9 versions & 1 rubygems