Skip to content

Commit 8ab1e3b

Browse files
author
Vincent Landgraf
committed
#10 implements boottime and load avg. helpers
1 parent b8d95a1 commit 8ab1e3b

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ This is a focused and fast library to get system information like:
1717
* Linux (>= 2.6)
1818
* OpenBSD
1919
* NetBSD
20-
* Solaris/SmartOS (partially)
20+
* Solaris/SmartOS
2121

2222
*It might support (but not tested):*
2323

lib/vmstat/solaris.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
require "time"
2+
13
module Vmstat
24
def self.cpu
35
mpstat = `mpstat 1 1`.lines
@@ -8,6 +10,15 @@ def self.cpu
810
end
911
end
1012

13+
def self.boot_time
14+
Time.parse(`who -b`.gsub(/^.*boot\s+/, "").gsub(/\s+/, " ").strip)
15+
end
16+
17+
def self.load_average
18+
uptime = `uptime`.gsub(",", ".")
19+
LoadAverage.new(*uptime.gsub(/\d+(\.\d+)?/).to_a[-3..-1].map(&:to_f))
20+
end
21+
1122
def self.memory
1223
memstat = `echo ::memstat | mdb -k`
1324
vmstat = `vmstat -s`

0 commit comments

Comments
 (0)