Module: SystemInformation
- Defined in:
- lib/systeminformation.rb,
lib/systeminformation/os.rb,
lib/systeminformation/linux/cpu.rb,
lib/systeminformation/linux/net.rb,
lib/systeminformation/linux/load.rb,
lib/systeminformation/unix/users.rb,
lib/systeminformation/linux/memory.rb
Defined Under Namespace
Class Method Summary collapse
-
.cpu ⇒ Object
Returns a hash of { "cpuid" => { :idle => 1.0, :user => 0.0, ... }, ... }.
-
.load ⇒ Object
Returns a hash of { :load_1 =>0.0, :load_5 =>0.0, :load_15 =>0.0, :procs_running =>0.0, :procs_total =>0.0 }.
-
.memory ⇒ Object
Returns a hash of items = { :free=>23340, :cached=>106052, :buffers=>10864, :total=>505492, :swaptotal=>916472, :swapfree=>782652, :used=>365236, :swapused=>133820 }.
-
.net ⇒ Object
Returns a hash of { "eth0" => { :rbytes => 0.0, :rpackets=>0.0, :sbytes=>0.0, :spackets=>0.0 }, ... }.
-
.os ⇒ Object
Returns what operating system is running.
-
.users ⇒ Object
Returns the number of currently logged in users as an integer.
Class Method Details
.cpu ⇒ Object
Returns a hash of { "cpuid" => { :idle => 1.0, :user => 0.0, ... }, ... }
The numerical values for each cpu sum up to 1.
Note: Since cpu utilisation is only defined for a time interval, the first call to this methods does not return meaningful data. It should be discarded and after a short time reexecuted. Subsequent calls will use the previous call as reference.
26 27 28 29 30 31 |
# File 'lib/systeminformation.rb', line 26 def self.cpu if OS::linux? @@cpu ||= Linux::CPU.new @@cpu.utilization end end |
.load ⇒ Object
Returns a hash of { :load_1 =>0.0, :load_5 =>0.0, :load_15 =>0.0, :procs_running =>0.0, :procs_total =>0.0 }
43 44 45 46 47 |
# File 'lib/systeminformation.rb', line 43 def self.load if OS::linux? Linux::Load.load end end |
.memory ⇒ Object
Returns a hash of items = { :free=>23340, :cached=>106052, :buffers=>10864, :total=>505492, :swaptotal=>916472, :swapfree=>782652, :used=>365236, :swapused=>133820 }
The unit is kilobyte blocks.
85 86 87 88 89 |
# File 'lib/systeminformation.rb', line 85 def self.memory if OS::linux? Linux::Memory.usage end end |
.net ⇒ Object
Returns a hash of { "eth0" => { :rbytes => 0.0, :rpackets=>0.0, :sbytes=>0.0, :spackets=>0.0 }, ... }
values are bytes/second or packets/second respectively
Note: Since network throughput is only defined for a time interval, the first call to this methods does not return meaningful data. It should be discarded and after a short time reexecuted. Subsequent calls will use the previous call as reference.
66 67 68 69 70 71 |
# File 'lib/systeminformation.rb', line 66 def self.net if OS::linux? @@net ||= Linux::Net.new @@net.throughput end end |