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
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
Defined in:
net.crConstructors
-
.new(pid : Int32? = nil)
Creates a new
Hardware::Net
for the system, or a given PID.
Instance Method Summary
-
#in_bcast_octets : Int64
Returns the ""InBcastOctets"" field of the
IpExt
field innet/netstat
. -
#in_bcast_pkts : Int64
Returns the ""InBcastPkts"" field of the
IpExt
field innet/netstat
. -
#in_ce_pkts : Int64
Returns the ""InCePkts"" field of the
IpExt
field innet/netstat
. -
#in_csum_errors : Int64
Returns the ""InCsumErrors"" field of the
IpExt
field innet/netstat
. -
#in_ect0_pkts : Int64
Returns the ""InEct0Pkts"" field of the
IpExt
field innet/netstat
. -
#in_ect1_pkts : Int64
Returns the ""InEct1Pkts"" field of the
IpExt
field innet/netstat
. -
#in_mcast_octets : Int64
Returns the ""InMcastOctets"" field of the
IpExt
field innet/netstat
. -
#in_mcast_pkts : Int64
Returns the ""InMcastPkts"" field of the
IpExt
field innet/netstat
. -
#in_no_ect_pkts : Int64
Returns the ""InNoEctPkts"" field of the
IpExt
field innet/netstat
. -
#in_no_routes : Int64
Returns the ""InNoRoutes"" field of the
IpExt
field innet/netstat
. -
#in_octets : Int64
Returns the ""InOctets"" field of the
IpExt
field innet/netstat
. -
#in_truncated_pkts : Int64
Returns the ""InTruncatedPkts"" field of the
IpExt
field innet/netstat
. - #ip_ext : Hash(String, Int64)
-
#out_bcast_octets : Int64
Returns the ""OutBcastOctets"" field of the
IpExt
field innet/netstat
. -
#out_bcast_pkts : Int64
Returns the ""OutBcastPkts"" field of the
IpExt
field innet/netstat
. -
#out_mcast_octets : Int64
Returns the ""OutMcastOctets"" field of the
IpExt
field innet/netstat
. -
#out_mcast_pkts : Int64
Returns the ""OutMcastPkts"" field of the
IpExt
field innet/netstat
. -
#out_octets : Int64
Returns the ""OutOctets"" field of the
IpExt
field innet/netstat
. - #pid : Int32?
- #tcp_ext : Hash(String, Int64)
Constructor Detail
Instance Method Detail
Returns the ""InBcastOctets"" field of the IpExt
field in net/netstat
.
Returns the ""InCePkts"" field of the IpExt
field in net/netstat
. Only in recent versions of Linux
Returns the ""InCsumErrors"" field of the IpExt
field in net/netstat
. Only in recent versions of Linux
Returns the ""InEct0Pkts"" field of the IpExt
field in net/netstat
. Only in recent versions of Linux
Returns the ""InEct1Pkts"" field of the IpExt
field in net/netstat
. Only in recent versions of Linux
Returns the ""InMcastOctets"" field of the IpExt
field in net/netstat
.
Returns the ""InNoEctPkts"" field of the IpExt
field in net/netstat
. Only in recent versions of Linux
Returns the ""InTruncatedPkts"" field of the IpExt
field in net/netstat
.
Returns the ""OutBcastOctets"" field of the IpExt
field in net/netstat
.
Returns the ""OutMcastOctets"" field of the IpExt
field in net/netstat
.