Top Level Namespace
Defined Under Namespace
Modules: Network
Classes: Float, Interface
Constant Summary
collapse
- Counter32Max =
4294967295
- OPTIONS =
{
:PostLog => true,
:Duration => 10,
:DatabaseFile => "ports.db",
:HostsFile => "hosts.conf"
}
- Counters =
["ifInOctets", "ifInErrors", :ifInUtilization, "ifOutOctets", "ifOutErrors", :ifOutUtilization]
Instance Method Summary
collapse
Instance Method Details
#bits_to_string(size) ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/network/monitor/network_statistics.rb', line 23
def bits_to_string(size)
human_size = size
levels = 0
while human_size >= 1000
human_size /= 1000.0
levels += 1
end
sprintf("%0.1f%s", human_size, ['', 'K', 'M', 'G', 'T', 'X'].fetch(levels)) + 'b'
end
|
#fetch_names(hosts) ⇒ Object
72
73
74
75
76
77
78
79
80
81
82
83
84
|
# File 'lib/network/monitor/network_statistics.rb', line 72
def fetch_names(hosts)
puts "Fetching names..."
hosts.each do |h|
SNMP::Manager.open(:Host => h, :Version => :SNMPv1) do |manager|
response = manager.get(["sysDescr.0", "sysName.0"])
name = response.varbind_list[1].value.to_s + ' (' + response.varbind_list[0].value.to_s + ')'
$names[h] = name
end
end
puts "Done."
end
|