struct Hardware::Net
- Hardware::Net
- Struct
- Value
- Object
Overview
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
net = Hardware::Net.new # Update network stats
sleep 1
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
Defined in:
hardware/net.crConstructors
-
.new(pid : Int32 = Process.pid)
Creates a new
Hardware::Netfor a PID.
Instance Method Summary
-
#in_bcast_octets : Int64
Returns the "InBcastOctets" field of
net/netstat. -
#in_bcast_pkts : Int64
Returns the "InBcastPkts" field of
net/netstat. -
#in_ce_pkts : Int64
Returns the "InCePkts" field of
net/netstat. -
#in_csum_esrrors : Int64
Returns the "InCsumEsrrors" field of
net/netstat. -
#in_ect0_pkts : Int64
Returns the "InEct0Pkts" field of
net/netstat. -
#in_ect1_pkts : Int64
Returns the "InEct1Pkts" field of
net/netstat. -
#in_mcast_octets : Int64
Returns the "InMcastOctets" field of
net/netstat. -
#in_mcast_pkts : Int64
Returns the "InMcastPkts" field of
net/netstat. -
#in_no_ect_pkts : Int64
Returns the "InNoEctPkts" field of
net/netstat. -
#in_no_routes : Int64
Returns the "InNoRoutes" field of
net/netstat. -
#in_octets : Int64
Returns the "InOctets" field of
net/netstat. -
#in_truncated_pkts : Int64
Returns the "InTruncatedPkts" field of
net/netstat. -
#out_bcast_octets : Int64
Returns the "OutBcastOctets" field of
net/netstat. -
#out_bcast_pkts : Int64
Returns the "OutBcastPkts" field of
net/netstat. -
#out_mcast_octets : Int64
Returns the "OutMcastOctets" field of
net/netstat. -
#out_mcast_pkts : Int64
Returns the "OutMcastPkts" field of
net/netstat. -
#out_octets : Int64
Returns the "OutOctets" field of
net/netstat.
Constructor Detail
Instance Method Detail
Returns the "InCePkts" field of net/netstat. Only in recent versions of Linux
Returns the "InCsumEsrrors" field of net/netstat. Only in recent versions of Linux
Returns the "InEct0Pkts" field of net/netstat. Only in recent versions of Linux
Returns the "InEct1Pkts" field of net/netstat. Only in recent versions of Linux
Returns the "InNoEctPkts" field of net/netstat. Only in recent versions of Linux