Hardware::Net
Inherits Struct / Value / Object
Network informations about the system or a process like the brandwidth use.
Example of network brandwidth calculation:
net = Hardware::Net.new # System network stats
old_in, old_out = net.in_octets, net.out_octets
loop do
sleep 1
net = Hardware::Net.new # Update network stats
now_in, now_out = net.in_octets, net.out_octets
puts "down: #{(now_in - old_in) / 1000}kB/s | up: #{(now_out - old_out) / 1000}kB/s" # => down: 427kB/s | up: 24kB/s
old_in, old_out = now_in, now_out
end
Constructors
Instance methods
in_ce_pkts
Returns the ""InCePkts"" field of the IpExt field in net/netstat. Only in recent versions of Linux
in_csum_errors
Returns the ""InCsumErrors"" field of the IpExt field in net/netstat. Only in recent versions of Linux
in_ect0_pkts
Returns the ""InEct0Pkts"" field of the IpExt field in net/netstat. Only in recent versions of Linux
in_ect1_pkts
Returns the ""InEct1Pkts"" field of the IpExt field in net/netstat. Only in recent versions of Linux
in_no_ect_pkts
Returns the ""InNoEctPkts"" field of the IpExt field in net/netstat. Only in recent versions of Linux
ip_ext
Sourcepid
Sourcetcp_ext
Source