vmstat 2.1.1 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +6 -2
- data/README.md +6 -7
- data/ext/vmstat/extconf.rb +13 -4
- data/ext/vmstat/hw/posix.h +8 -2
- data/ext/vmstat/hw/statfs.h +27 -1
- data/ext/vmstat/hw/sysctl.h +26 -32
- data/lib/vmstat.rb +7 -0
- data/lib/vmstat/netopenbsd.rb +61 -0
- data/lib/vmstat/solaris.rb +75 -0
- data/lib/vmstat/version.rb +1 -1
- data/spec/vmstat/solaris_spec.rb +275 -0
- data/spec/vmstat_spec.rb +2 -2
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69a842d6f8a88a49ab2bce5670713cc8608a2f70
|
4
|
+
data.tar.gz: c68c3e51480bbf34f321b09ddfdfb2f90d80394c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1f86c40a0baaec18bb129a59bb156147e6f3d35875d251b380014ac1d3d7ee785e65fbacead385094c9ba823eafbc8f6405d111d8131426c26d1c838228bec7
|
7
|
+
data.tar.gz: 3e828475c895b8bdd29435d12e28b37c5a8e1741bc32a76e70bb695946cdf40d728caf3ca53464175d1e151328a2d409c67ed18f8634ff537c156414aba113eb
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -15,16 +15,14 @@ This is a focused and fast library to get system information like:
|
|
15
15
|
* FreeBSD
|
16
16
|
* MacOS X
|
17
17
|
* Linux (>= 2.6)
|
18
|
+
* OpenBSD
|
19
|
+
* NetBSD
|
20
|
+
* Solaris/SmartOS
|
18
21
|
|
19
22
|
*It might support (but not tested):*
|
20
23
|
|
21
24
|
* Older versions of linux
|
22
25
|
|
23
|
-
*It doesn't support:*
|
24
|
-
|
25
|
-
* OpenBSD
|
26
|
-
* NetBSD
|
27
|
-
|
28
26
|
## Installation
|
29
27
|
|
30
28
|
Add this line to your application's Gemfile:
|
@@ -137,9 +135,10 @@ Just require the library and make a snapshot or use the distinct methods to just
|
|
137
135
|
## Todo
|
138
136
|
|
139
137
|
* Swap information
|
140
|
-
* Support more platforms (hp ux, aix,
|
138
|
+
* Support more platforms (hp ux, aix, ...)
|
139
|
+
* Optimize performance for OpenBSD, NetBSD using `uvmexp` etc. directly
|
140
|
+
* Optimize performance for solaris, smartos using `kstat` etc. directly
|
141
141
|
* Server performance/system information (open file handles, cache sizes, number of inodes ...)
|
142
|
-
* Add support for (Open|Net)BSD using UVM (http://cvsweb.netbsd.org/bsdweb.cgi/src/external/bsd/top/dist/machine/) and remove sysctlbyname references where possible to make it compatible
|
143
142
|
|
144
143
|
## Contributing
|
145
144
|
|
data/ext/vmstat/extconf.rb
CHANGED
@@ -2,9 +2,13 @@ require 'mkmf'
|
|
2
2
|
|
3
3
|
# posix.h
|
4
4
|
have_header 'unistd.h'
|
5
|
-
have_func 'getpagesize'
|
5
|
+
have_func 'getpagesize', 'unistd.h'
|
6
6
|
have_header 'stdlib.h'
|
7
|
-
|
7
|
+
if have_header 'sys/loadavg.h'
|
8
|
+
have_func 'getloadavg', 'sys/loadavg.h'
|
9
|
+
else
|
10
|
+
have_func 'getloadavg'
|
11
|
+
end
|
8
12
|
|
9
13
|
# mach.h
|
10
14
|
have_header 'mach/mach.h'
|
@@ -31,6 +35,10 @@ have_header 'sys/param.h'
|
|
31
35
|
have_header 'sys/mount.h'
|
32
36
|
have_header 'sys/statfs.h'
|
33
37
|
have_func 'statfs'
|
38
|
+
have_struct_member('struct statfs', 'f_type', ['sys/param.h', 'sys/mount.h', 'sys/statfs.h'])
|
39
|
+
have_struct_member('struct statfs', 'f_fstypename', ['sys/param.h', 'sys/mount.h'])
|
40
|
+
have_func 'statvfs', ['sys/types.h', 'sys/statvfs.h']
|
41
|
+
have_struct_member('struct statvfs', 'f_basetype', ['sys/types.h', 'sys/statvfs.h'])
|
34
42
|
|
35
43
|
# sysctl.h
|
36
44
|
sys_headers = ['unistd.h', 'sys/sysctl.h', 'sys/types.h', 'sys/socket.h',
|
@@ -44,8 +52,9 @@ have_const 'PF_LINK', sys_headers
|
|
44
52
|
have_const 'NETLINK_GENERIC', sys_headers
|
45
53
|
have_const 'IFMIB_IFDATA', sys_headers
|
46
54
|
have_const 'IFDATA_GENERAL', sys_headers
|
47
|
-
|
48
|
-
have_const '
|
55
|
+
|
56
|
+
have_const 'CTL_KERN', ['sys/sysctl.h', 'sys/types.h']
|
57
|
+
have_const 'KERN_BOOTTIME', ['sys/sysctl.h', 'sys/types.h']
|
49
58
|
|
50
59
|
# bsd.h
|
51
60
|
# only if we have *bsd like stats check for sysctlbyname
|
data/ext/vmstat/hw/posix.h
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
-
#if defined(HAVE_UNISTD_H)
|
1
|
+
#if defined(HAVE_UNISTD_H)
|
2
2
|
#include <unistd.h>
|
3
|
+
#endif
|
3
4
|
|
5
|
+
#if defined(HAVE_GETPAGESIZE)
|
4
6
|
#ifndef VMSTAT_PAGESIZE
|
5
7
|
#define VMSTAT_PAGESIZE
|
6
8
|
VALUE vmstat_pagesize(VALUE self) {
|
@@ -9,7 +11,11 @@ VALUE vmstat_pagesize(VALUE self) {
|
|
9
11
|
#endif
|
10
12
|
#endif
|
11
13
|
|
12
|
-
#if defined(
|
14
|
+
#if defined(HAVE_SYS_LOADAVG_H)
|
15
|
+
#include <sys/loadavg.h>
|
16
|
+
#endif
|
17
|
+
|
18
|
+
#if defined(HAVE_GETLOADAVG)
|
13
19
|
#ifndef VMSTAT_LOAD_AVERAGE
|
14
20
|
#define VMSTAT_LOAD_AVERAGE
|
15
21
|
VALUE vmstat_load_average(VALUE self) {
|
data/ext/vmstat/hw/statfs.h
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#if defined(
|
1
|
+
#if defined(HAVE_STATFS) && (defined(HAVE_STRUCT_STATFS_F_TYPE) || defined(HAVE_STRUCT_STATFS_F_FSTYPENAME))
|
2
2
|
#include <vmstat.h>
|
3
3
|
#include <sys/param.h>
|
4
4
|
#include <sys/mount.h>
|
@@ -39,3 +39,29 @@ VALUE vmstat_disk(VALUE self, VALUE path) {
|
|
39
39
|
}
|
40
40
|
#endif
|
41
41
|
#endif
|
42
|
+
|
43
|
+
#if defined(HAVE_STATVFS) && defined(HAVE_STRUCT_STATVFS_F_BASETYPE)
|
44
|
+
#include <vmstat.h>
|
45
|
+
#include <sys/types.h>
|
46
|
+
#include <sys/statvfs.h>
|
47
|
+
|
48
|
+
#ifndef VMSTAT_DISK
|
49
|
+
#define VMSTAT_DISK
|
50
|
+
VALUE vmstat_disk(VALUE self, VALUE path) {
|
51
|
+
VALUE disk = Qnil;
|
52
|
+
struct statvfs stat;
|
53
|
+
|
54
|
+
if (statvfs(StringValueCStr(path), &stat) == 0) {
|
55
|
+
disk = rb_funcall(rb_path2class("Vmstat::LinuxDisk"),
|
56
|
+
rb_intern("new"), 6, ID2SYM(rb_intern(stat.f_basetype)),
|
57
|
+
path,
|
58
|
+
ULL2NUM(stat.f_bsize),
|
59
|
+
ULL2NUM(stat.f_bfree),
|
60
|
+
ULL2NUM(stat.f_bavail),
|
61
|
+
ULL2NUM(stat.f_blocks));
|
62
|
+
}
|
63
|
+
|
64
|
+
return disk;
|
65
|
+
}
|
66
|
+
#endif
|
67
|
+
#endif
|
data/ext/vmstat/hw/sysctl.h
CHANGED
@@ -1,22 +1,31 @@
|
|
1
|
-
#if defined(HAVE_SYS_SYSCTL_H) && \
|
2
|
-
defined(
|
3
|
-
defined(HAVE_SYS_SOCKET_H) && \
|
4
|
-
defined(HAVE_NET_IF_H) && \
|
5
|
-
defined(HAVE_NET_IF_MIB_H) && \
|
6
|
-
defined(HAVE_NET_IF_TYPES_H) && \
|
7
|
-
defined(HAVE_GETLOADAVG) && \
|
8
|
-
defined(HAVE_SYSCTL) && \
|
9
|
-
defined(HAVE_TYPE_STRUCT_IFMIBDATA) && \
|
10
|
-
defined(HAVE_CONST_CTL_NET) && \
|
11
|
-
defined(HAVE_CONST_PF_LINK) && \
|
12
|
-
defined(HAVE_CONST_NETLINK_GENERIC) && \
|
13
|
-
defined(HAVE_CONST_IFMIB_IFDATA) && \
|
14
|
-
defined(HAVE_CONST_IFDATA_GENERAL) && \
|
15
|
-
defined(HAVE_CONST_CTL_KERN) && \
|
16
|
-
defined(HAVE_CONST_KERN_BOOTTIME)
|
1
|
+
#if defined(HAVE_SYS_SYSCTL_H) && defined(HAVE_SYS_TYPES_H) && \
|
2
|
+
defined(HAVE_CONST_CTL_KERN) && defined(HAVE_CONST_KERN_BOOTTIME)
|
17
3
|
#include <vmstat.h>
|
18
4
|
#include <sys/sysctl.h>
|
19
5
|
#include <sys/types.h>
|
6
|
+
|
7
|
+
#ifndef VMSTAT_BOOT_TIME
|
8
|
+
#define VMSTAT_BOOT_TIME
|
9
|
+
static int BOOT_TIME_MIB[] = { CTL_KERN, KERN_BOOTTIME };
|
10
|
+
|
11
|
+
VALUE vmstat_boot_time(VALUE self) {
|
12
|
+
struct timeval tv;
|
13
|
+
size_t size = sizeof(tv);
|
14
|
+
|
15
|
+
if (sysctl(BOOT_TIME_MIB, 2, &tv, &size, NULL, 0) == 0) {
|
16
|
+
return rb_time_new(tv.tv_sec, tv.tv_usec);
|
17
|
+
} else {
|
18
|
+
return Qnil;
|
19
|
+
}
|
20
|
+
}
|
21
|
+
#endif // VMSTAT_BOOT_TIME
|
22
|
+
|
23
|
+
#if defined(HAVE_SYS_SOCKET_H) && defined(HAVE_NET_IF_H) && \
|
24
|
+
defined(HAVE_NET_IF_MIB_H) && defined(HAVE_NET_IF_TYPES_H) && \
|
25
|
+
defined(HAVE_GETLOADAVG) && defined(HAVE_SYSCTL) && \
|
26
|
+
defined(HAVE_TYPE_STRUCT_IFMIBDATA) && defined(HAVE_CONST_CTL_NET) && \
|
27
|
+
defined(HAVE_CONST_PF_LINK) && defined(HAVE_CONST_NETLINK_GENERIC) && \
|
28
|
+
defined(HAVE_CONST_IFMIB_IFDATA) && defined(HAVE_CONST_IFDATA_GENERAL)
|
20
29
|
#include <sys/socket.h>
|
21
30
|
#include <net/if.h>
|
22
31
|
#include <net/if_mib.h>
|
@@ -52,21 +61,6 @@ VALUE vmstat_network_interfaces(VALUE self) {
|
|
52
61
|
|
53
62
|
return devices;
|
54
63
|
}
|
55
|
-
#endif
|
56
|
-
|
57
|
-
#ifndef VMSTAT_BOOT_TIME
|
58
|
-
#define VMSTAT_BOOT_TIME
|
59
|
-
static int BOOT_TIME_MIB[] = { CTL_KERN, KERN_BOOTTIME };
|
60
|
-
|
61
|
-
VALUE vmstat_boot_time(VALUE self) {
|
62
|
-
struct timeval tv;
|
63
|
-
size_t size = sizeof(tv);
|
64
|
-
|
65
|
-
if (sysctl(BOOT_TIME_MIB, 2, &tv, &size, NULL, 0) == 0) {
|
66
|
-
return rb_time_new(tv.tv_sec, tv.tv_usec);
|
67
|
-
} else {
|
68
|
-
return Qnil;
|
69
|
-
}
|
70
|
-
}
|
64
|
+
#endif // VMSTAT_NETWORK_INTERFACES
|
71
65
|
#endif
|
72
66
|
#endif
|
data/lib/vmstat.rb
CHANGED
@@ -20,6 +20,7 @@ module Vmstat
|
|
20
20
|
autoload :ProcFS, "vmstat/procfs"
|
21
21
|
autoload :Stub, "vmstat/stub"
|
22
22
|
autoload :Snapshot, "vmstat/snapshot"
|
23
|
+
autoload :Solaris, "vmstat/solaris"
|
23
24
|
extend Stub # the default empty implementation
|
24
25
|
|
25
26
|
# @!method self.boot_time
|
@@ -98,4 +99,10 @@ require "vmstat/vmstat" # native lib
|
|
98
99
|
|
99
100
|
if RUBY_PLATFORM =~ /linux/
|
100
101
|
Vmstat.send(:extend, Vmstat::ProcFS)
|
102
|
+
elsif RUBY_PLATFORM =~ /(net|open)bsd/
|
103
|
+
# command based implementation of mem, net, cpu
|
104
|
+
require "vmstat/netopenbsd"
|
105
|
+
elsif RUBY_PLATFORM =~ /solaris|smartos/
|
106
|
+
# command based implementation of mem, net, cpu
|
107
|
+
Vmstat.send(:include, Vmstat::Solaris)
|
101
108
|
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module Vmstat
|
2
|
+
def self.cpu
|
3
|
+
cptime = `sysctl kern.cp_time`.split(/=/).last
|
4
|
+
user, nice, sys, irq, idle = cptime.split(/,/).map(&:to_i)
|
5
|
+
[Cpu.new(0, user, sys + irq, nice, idle)]
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.memory
|
9
|
+
uvmexp = `vmstat -s`
|
10
|
+
|
11
|
+
Memory.new(
|
12
|
+
# pagesize call is not used to avoid double shell out
|
13
|
+
pagesize, # pagesize
|
14
|
+
extract_uvm_val(uvmexp, 'pages managed'), # wired
|
15
|
+
extract_uvm_val(uvmexp, 'pages active'), # active
|
16
|
+
extract_uvm_val(uvmexp, 'pages inactive'), # inactive
|
17
|
+
extract_uvm_val(uvmexp, 'pages free'), # free
|
18
|
+
extract_uvm_val(uvmexp, 'pagein operations'), # pageins
|
19
|
+
extract_uvm_val(uvmexp, 'pages being paged out') # pageouts
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.network_interfaces
|
24
|
+
bytes = `netstat -ibq`.lines.grep(/<Link>/) # bytes
|
25
|
+
pkgs = `netstat -iqd`.lines.grep(/<Link>/) # packages
|
26
|
+
|
27
|
+
itf = Hash.new { |h, k| h[k] = NetworkInterface.new(k) }
|
28
|
+
|
29
|
+
bytes.each do |line|
|
30
|
+
# Name Mtu Network Address Ibytes Obytes
|
31
|
+
name, _, _, _, ibytes, obytes = line.split(/\s+/)
|
32
|
+
itf[name].in_bytes = ibytes.to_i
|
33
|
+
itf[name].out_bytes = obytes.to_i
|
34
|
+
end
|
35
|
+
|
36
|
+
pkgs.each do |line|
|
37
|
+
# Name Mtu Network Address Ipkts Ierrs Opkts Oerrs Colls Drop
|
38
|
+
name, _, _, _, _, ierrs, _, oerrs, _, drop = line.split(/\s+/)
|
39
|
+
itf[name].in_errors = ierrs.to_i
|
40
|
+
itf[name].in_drops = drop.to_i
|
41
|
+
itf[name].out_errors = oerrs.to_i
|
42
|
+
end
|
43
|
+
|
44
|
+
itf.each do |name, nic|
|
45
|
+
if name =~ /lo\d+/
|
46
|
+
nic.type = NetworkInterface::LOOPBACK_TYPE
|
47
|
+
else
|
48
|
+
nic.type = NetworkInterface::ETHERNET_TYPE
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
itf.values
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.extract_uvm_val(uvmexp, name)
|
56
|
+
regexp = Regexp.new('(\d+)\s' + name)
|
57
|
+
uvmexp.lines.grep(regexp) do |line|
|
58
|
+
return $1.to_i
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
module Vmstat
|
2
|
+
module Solaris
|
3
|
+
module ClassMethods
|
4
|
+
def cpu
|
5
|
+
kstat = `kstat -p "cpu_stat:::/idle|kernel|user/"`
|
6
|
+
cpus = Hash.new { |h, k| h[k] = Hash.new }
|
7
|
+
|
8
|
+
kstat.lines.each do |line|
|
9
|
+
_, cpu, _, key, value = line.strip.split(/:|\s+/)
|
10
|
+
cpus[cpu.to_i][key] = value
|
11
|
+
end
|
12
|
+
|
13
|
+
cpus.map do |num, v|
|
14
|
+
Cpu.new(num, v["user"].to_i, v["kernel"].to_i, 0, v["idle"].to_i)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def boot_time
|
19
|
+
Time.at(`kstat -p unix:::boot_time`.strip.split(/\s+/).last.to_i)
|
20
|
+
end
|
21
|
+
|
22
|
+
def memory
|
23
|
+
kstat = `kstat -p -n system_pages`
|
24
|
+
values = Hash.new
|
25
|
+
|
26
|
+
kstat.lines.each do |line|
|
27
|
+
_, _, _, key, value = line.strip.split(/:|\s+/)
|
28
|
+
values[key] = value
|
29
|
+
end
|
30
|
+
|
31
|
+
total = values['pagestotal'].to_i
|
32
|
+
free = values['pagesfree'].to_i
|
33
|
+
locked = values['pageslocked'].to_i
|
34
|
+
|
35
|
+
Memory.new(Vmstat.pagesize,
|
36
|
+
locked, # wired
|
37
|
+
total - free - locked, # active
|
38
|
+
0, # inactive
|
39
|
+
free, # free
|
40
|
+
0, #pageins
|
41
|
+
0) #pageouts
|
42
|
+
end
|
43
|
+
|
44
|
+
def network_interfaces
|
45
|
+
kstat = `kstat -p link:::`
|
46
|
+
itfs = Hash.new { |h, k| h[k] = Hash.new }
|
47
|
+
|
48
|
+
kstat.lines.each do |line|
|
49
|
+
_, _, name, key, value = line.strip.split(/:|\s+/)
|
50
|
+
itfs[name.to_sym][key] = value
|
51
|
+
end
|
52
|
+
|
53
|
+
itfs.map do |k, v|
|
54
|
+
NetworkInterface.new(k, v['rbytes64'].to_i,
|
55
|
+
v['ierrors'].to_i,
|
56
|
+
0,
|
57
|
+
v['obytes64'].to_i,
|
58
|
+
v['oerrors'].to_i,
|
59
|
+
NetworkInterface::ETHERNET_TYPE)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
extend ClassMethods
|
65
|
+
|
66
|
+
def self.included base
|
67
|
+
base.instance_eval do
|
68
|
+
def cpu; Vmstat::Solaris.cpu end
|
69
|
+
def boot_time; Vmstat::Solaris.boot_time end
|
70
|
+
def memory; Vmstat::Solaris.memory end
|
71
|
+
def network_interfaces; Vmstat::Solaris.network_interfaces end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
data/lib/vmstat/version.rb
CHANGED
@@ -0,0 +1,275 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Vmstat::Solaris do
|
4
|
+
let(:solaris) do
|
5
|
+
c = Vmstat::Solaris
|
6
|
+
|
7
|
+
def c.`(cmd)
|
8
|
+
if cmd == 'kstat -p "cpu_stat:::/idle|kernel|user/"'
|
9
|
+
"cpu_stat:0:cpu_stat0:idle 2325343762
|
10
|
+
cpu_stat:0:cpu_stat0:idlethread 776439232
|
11
|
+
cpu_stat:0:cpu_stat0:kernel 89137335
|
12
|
+
cpu_stat:0:cpu_stat0:kernel_asflt 1
|
13
|
+
cpu_stat:0:cpu_stat0:user 64919001
|
14
|
+
cpu_stat:1:cpu_stat1:idle 2322767706
|
15
|
+
cpu_stat:1:cpu_stat1:idlethread 125993797
|
16
|
+
cpu_stat:1:cpu_stat1:kernel 78457429
|
17
|
+
cpu_stat:1:cpu_stat1:kernel_asflt 34
|
18
|
+
cpu_stat:1:cpu_stat1:user 78174710
|
19
|
+
cpu_stat:2:cpu_stat2:idle 2390178542
|
20
|
+
cpu_stat:2:cpu_stat2:idlethread 3368087417
|
21
|
+
cpu_stat:2:cpu_stat2:kernel 50617796
|
22
|
+
cpu_stat:2:cpu_stat2:kernel_asflt 0
|
23
|
+
cpu_stat:2:cpu_stat2:user 38603497
|
24
|
+
cpu_stat:3:cpu_stat3:idle 2390802861
|
25
|
+
cpu_stat:3:cpu_stat3:idlethread 1772145290
|
26
|
+
cpu_stat:3:cpu_stat3:kernel 46044221
|
27
|
+
cpu_stat:3:cpu_stat3:kernel_asflt 0
|
28
|
+
cpu_stat:3:cpu_stat3:user 42552751
|
29
|
+
cpu_stat:4:cpu_stat4:idle 2436590263
|
30
|
+
cpu_stat:4:cpu_stat4:idlethread 2145015281
|
31
|
+
cpu_stat:4:cpu_stat4:kernel 23983506
|
32
|
+
cpu_stat:4:cpu_stat4:kernel_asflt 0
|
33
|
+
cpu_stat:4:cpu_stat4:user 18826062
|
34
|
+
cpu_stat:5:cpu_stat5:idle 2435969240
|
35
|
+
cpu_stat:5:cpu_stat5:idlethread 3720145695
|
36
|
+
cpu_stat:5:cpu_stat5:kernel 25630307
|
37
|
+
cpu_stat:5:cpu_stat5:kernel_asflt 0
|
38
|
+
cpu_stat:5:cpu_stat5:user 17800281
|
39
|
+
cpu_stat:6:cpu_stat6:idle 2432659504
|
40
|
+
cpu_stat:6:cpu_stat6:idlethread 3012624014
|
41
|
+
cpu_stat:6:cpu_stat6:kernel 24414413
|
42
|
+
cpu_stat:6:cpu_stat6:kernel_asflt 0
|
43
|
+
cpu_stat:6:cpu_stat6:user 22325909
|
44
|
+
cpu_stat:7:cpu_stat7:idle 2430409364
|
45
|
+
cpu_stat:7:cpu_stat7:idlethread 1931519381
|
46
|
+
cpu_stat:7:cpu_stat7:kernel 28094309
|
47
|
+
cpu_stat:7:cpu_stat7:kernel_asflt 0
|
48
|
+
cpu_stat:7:cpu_stat7:user 20896150
|
49
|
+
cpu_stat:8:cpu_stat8:idle 2443187236
|
50
|
+
cpu_stat:8:cpu_stat8:idlethread 1900014542
|
51
|
+
cpu_stat:8:cpu_stat8:kernel 20799721
|
52
|
+
cpu_stat:8:cpu_stat8:kernel_asflt 0
|
53
|
+
cpu_stat:8:cpu_stat8:user 15412864
|
54
|
+
cpu_stat:9:cpu_stat9:idle 2440596009
|
55
|
+
cpu_stat:9:cpu_stat9:idlethread 3703869451
|
56
|
+
cpu_stat:9:cpu_stat9:kernel 23787482
|
57
|
+
cpu_stat:9:cpu_stat9:kernel_asflt 0
|
58
|
+
cpu_stat:9:cpu_stat9:user 15016328
|
59
|
+
cpu_stat:10:cpu_stat10:idle 2427567910
|
60
|
+
cpu_stat:10:cpu_stat10:idlethread 3191481058
|
61
|
+
cpu_stat:10:cpu_stat10:kernel 30059932
|
62
|
+
cpu_stat:10:cpu_stat10:kernel_asflt 5
|
63
|
+
cpu_stat:10:cpu_stat10:user 21771975
|
64
|
+
cpu_stat:11:cpu_stat11:idle 2431827979
|
65
|
+
cpu_stat:11:cpu_stat11:idlethread 1824361353
|
66
|
+
cpu_stat:11:cpu_stat11:kernel 27388335
|
67
|
+
cpu_stat:11:cpu_stat11:kernel_asflt 0
|
68
|
+
cpu_stat:11:cpu_stat11:user 20183500
|
69
|
+
cpu_stat:12:cpu_stat12:idle 2442824569
|
70
|
+
cpu_stat:12:cpu_stat12:idlethread 2037054756
|
71
|
+
cpu_stat:12:cpu_stat12:kernel 21276397
|
72
|
+
cpu_stat:12:cpu_stat12:kernel_asflt 0
|
73
|
+
cpu_stat:12:cpu_stat12:user 15298846
|
74
|
+
cpu_stat:13:cpu_stat13:idle 2443388458
|
75
|
+
cpu_stat:13:cpu_stat13:idlethread 3442886390
|
76
|
+
cpu_stat:13:cpu_stat13:kernel 22081759
|
77
|
+
cpu_stat:13:cpu_stat13:kernel_asflt 0
|
78
|
+
cpu_stat:13:cpu_stat13:user 13929592
|
79
|
+
cpu_stat:14:cpu_stat14:idle 2434768696
|
80
|
+
cpu_stat:14:cpu_stat14:idlethread 2856867656
|
81
|
+
cpu_stat:14:cpu_stat14:kernel 23352419
|
82
|
+
cpu_stat:14:cpu_stat14:kernel_asflt 0
|
83
|
+
cpu_stat:14:cpu_stat14:user 21278693
|
84
|
+
cpu_stat:15:cpu_stat15:idle 2432514522
|
85
|
+
cpu_stat:15:cpu_stat15:idlethread 1703823954
|
86
|
+
cpu_stat:15:cpu_stat15:kernel 27050642
|
87
|
+
cpu_stat:15:cpu_stat15:kernel_asflt 16
|
88
|
+
cpu_stat:15:cpu_stat15:user 19834642
|
89
|
+
cpu_stat:16:cpu_stat16:idle 2436582325
|
90
|
+
cpu_stat:16:cpu_stat16:idlethread 1983802071
|
91
|
+
cpu_stat:16:cpu_stat16:kernel 21833225
|
92
|
+
cpu_stat:16:cpu_stat16:kernel_asflt 0
|
93
|
+
cpu_stat:16:cpu_stat16:user 20984253
|
94
|
+
cpu_stat:17:cpu_stat17:idle 2432250902
|
95
|
+
cpu_stat:17:cpu_stat17:idlethread 307297399
|
96
|
+
cpu_stat:17:cpu_stat17:kernel 29580663
|
97
|
+
cpu_stat:17:cpu_stat17:kernel_asflt 0
|
98
|
+
cpu_stat:17:cpu_stat17:user 17568236
|
99
|
+
cpu_stat:18:cpu_stat18:idle 2447310538
|
100
|
+
cpu_stat:18:cpu_stat18:idlethread 1473510287
|
101
|
+
cpu_stat:18:cpu_stat18:kernel 18480841
|
102
|
+
cpu_stat:18:cpu_stat18:kernel_asflt 5
|
103
|
+
cpu_stat:18:cpu_stat18:user 13608419
|
104
|
+
cpu_stat:19:cpu_stat19:idle 2446462748
|
105
|
+
cpu_stat:19:cpu_stat19:idlethread 2882237650
|
106
|
+
cpu_stat:19:cpu_stat19:kernel 20384068
|
107
|
+
cpu_stat:19:cpu_stat19:kernel_asflt 0
|
108
|
+
cpu_stat:19:cpu_stat19:user 12552980
|
109
|
+
cpu_stat:20:cpu_stat20:idle 2439710143
|
110
|
+
cpu_stat:20:cpu_stat20:idlethread 2513415319
|
111
|
+
cpu_stat:20:cpu_stat20:kernel 20976077
|
112
|
+
cpu_stat:20:cpu_stat20:kernel_asflt 0
|
113
|
+
cpu_stat:20:cpu_stat20:user 18713575
|
114
|
+
cpu_stat:21:cpu_stat21:idle 2434565830
|
115
|
+
cpu_stat:21:cpu_stat21:idlethread 1574993351
|
116
|
+
cpu_stat:21:cpu_stat21:kernel 26063716
|
117
|
+
cpu_stat:21:cpu_stat21:kernel_asflt 0
|
118
|
+
cpu_stat:21:cpu_stat21:user 18770245
|
119
|
+
cpu_stat:22:cpu_stat22:idle 2447896586
|
120
|
+
cpu_stat:22:cpu_stat22:idlethread 1566290884
|
121
|
+
cpu_stat:22:cpu_stat22:kernel 18718466
|
122
|
+
cpu_stat:22:cpu_stat22:kernel_asflt 0
|
123
|
+
cpu_stat:22:cpu_stat22:user 12784738
|
124
|
+
cpu_stat:23:cpu_stat23:idle 2444823222
|
125
|
+
cpu_stat:23:cpu_stat23:idlethread 3286395080
|
126
|
+
cpu_stat:23:cpu_stat23:kernel 21510594
|
127
|
+
cpu_stat:23:cpu_stat23:kernel_asflt 0
|
128
|
+
cpu_stat:23:cpu_stat23:user 13065972
|
129
|
+
cpu_stat:24:cpu_stat24:idle 2437316848
|
130
|
+
cpu_stat:24:cpu_stat24:idlethread 2628739060
|
131
|
+
cpu_stat:24:cpu_stat24:kernel 22266295
|
132
|
+
cpu_stat:24:cpu_stat24:kernel_asflt 0
|
133
|
+
cpu_stat:24:cpu_stat24:user 19816643
|
134
|
+
cpu_stat:25:cpu_stat25:idle 2433451000
|
135
|
+
cpu_stat:25:cpu_stat25:idlethread 1604646150
|
136
|
+
cpu_stat:25:cpu_stat25:kernel 26748441
|
137
|
+
cpu_stat:25:cpu_stat25:kernel_asflt 0
|
138
|
+
cpu_stat:25:cpu_stat25:user 19200341
|
139
|
+
cpu_stat:26:cpu_stat26:idle 2446405472
|
140
|
+
cpu_stat:26:cpu_stat26:idlethread 1573139378
|
141
|
+
cpu_stat:26:cpu_stat26:kernel 19619834
|
142
|
+
cpu_stat:26:cpu_stat26:kernel_asflt 0
|
143
|
+
cpu_stat:26:cpu_stat26:user 13374474
|
144
|
+
cpu_stat:27:cpu_stat27:idle 2444019515
|
145
|
+
cpu_stat:27:cpu_stat27:idlethread 3275705315
|
146
|
+
cpu_stat:27:cpu_stat27:kernel 21816225
|
147
|
+
cpu_stat:27:cpu_stat27:kernel_asflt 0
|
148
|
+
cpu_stat:27:cpu_stat27:user 13564039
|
149
|
+
cpu_stat:28:cpu_stat28:idle 2435784523
|
150
|
+
cpu_stat:28:cpu_stat28:idlethread 2628201319
|
151
|
+
cpu_stat:28:cpu_stat28:kernel 23125551
|
152
|
+
cpu_stat:28:cpu_stat28:kernel_asflt 0
|
153
|
+
cpu_stat:28:cpu_stat28:user 20489701
|
154
|
+
cpu_stat:29:cpu_stat29:idle 2432230501
|
155
|
+
cpu_stat:29:cpu_stat29:idlethread 1635408506
|
156
|
+
cpu_stat:29:cpu_stat29:kernel 27198273
|
157
|
+
cpu_stat:29:cpu_stat29:kernel_asflt 0
|
158
|
+
cpu_stat:29:cpu_stat29:user 19970999
|
159
|
+
cpu_stat:30:cpu_stat30:idle 2444413183
|
160
|
+
cpu_stat:30:cpu_stat30:idlethread 1644573224
|
161
|
+
cpu_stat:30:cpu_stat30:kernel 20310412
|
162
|
+
cpu_stat:30:cpu_stat30:kernel_asflt 0
|
163
|
+
cpu_stat:30:cpu_stat30:user 14676176
|
164
|
+
cpu_stat:31:cpu_stat31:idle 2442483106
|
165
|
+
cpu_stat:31:cpu_stat31:idlethread 3345414215
|
166
|
+
cpu_stat:31:cpu_stat31:kernel 22515695
|
167
|
+
cpu_stat:31:cpu_stat31:kernel_asflt 0
|
168
|
+
cpu_stat:31:cpu_stat31:user 14400967\n"
|
169
|
+
elsif cmd == "kstat -p unix:::boot_time"
|
170
|
+
"unix:0:system_misc:boot_time 1470765992\n"
|
171
|
+
elsif cmd == "kstat -p -n system_pages"
|
172
|
+
"unix:0:system_pages:availrmem 70121
|
173
|
+
unix:0:system_pages:crtime 116.1198523
|
174
|
+
unix:0:system_pages:desfree 3744
|
175
|
+
unix:0:system_pages:desscan 25
|
176
|
+
unix:0:system_pages:econtig 176160768
|
177
|
+
unix:0:system_pages:fastscan 137738
|
178
|
+
unix:0:system_pages:freemem 61103
|
179
|
+
unix:0:system_pages:kernelbase 16777216
|
180
|
+
unix:0:system_pages:lotsfree 7488
|
181
|
+
unix:0:system_pages:minfree 1872
|
182
|
+
unix:0:system_pages:nalloc 26859076
|
183
|
+
unix:0:system_pages:nalloc_calls 11831
|
184
|
+
unix:0:system_pages:nfree 25250198
|
185
|
+
unix:0:system_pages:nfree_calls 7888
|
186
|
+
unix:0:system_pages:nscan 0
|
187
|
+
unix:0:system_pages:pagesfree 61103
|
188
|
+
unix:0:system_pages:pageslocked 409145
|
189
|
+
unix:0:system_pages:pagestotal 479266
|
190
|
+
unix:0:system_pages:physmem 489586
|
191
|
+
unix:0:system_pages:pp_kernel 438675
|
192
|
+
unix:0:system_pages:slowscan 100
|
193
|
+
unix:0:system_pages:snaptime 314313.3248461\n"
|
194
|
+
elsif cmd == "kstat -p link:::"
|
195
|
+
"link:0:e1000g0:ierrors 0
|
196
|
+
link:0:e1000g0:oerrors 1
|
197
|
+
link:0:e1000g0:rbytes64 1000
|
198
|
+
link:0:e1000g0:obytes64 2000\n"
|
199
|
+
else
|
200
|
+
raise "Unknown cmd: '#{cmd}'"
|
201
|
+
end
|
202
|
+
end
|
203
|
+
c
|
204
|
+
end
|
205
|
+
|
206
|
+
context "#cpu" do
|
207
|
+
subject { solaris.cpu }
|
208
|
+
|
209
|
+
it { should be_a(Array)}
|
210
|
+
it do
|
211
|
+
should == [
|
212
|
+
Vmstat::Cpu.new(0, 64919001, 89137335, 0, 2325343762),
|
213
|
+
Vmstat::Cpu.new(1, 78174710, 78457429, 0, 2322767706),
|
214
|
+
Vmstat::Cpu.new(2, 38603497, 50617796, 0, 2390178542),
|
215
|
+
Vmstat::Cpu.new(3, 42552751, 46044221, 0, 2390802861),
|
216
|
+
Vmstat::Cpu.new(4, 18826062, 23983506, 0, 2436590263),
|
217
|
+
Vmstat::Cpu.new(5, 17800281, 25630307, 0, 2435969240),
|
218
|
+
Vmstat::Cpu.new(6, 22325909, 24414413, 0, 2432659504),
|
219
|
+
Vmstat::Cpu.new(7, 20896150, 28094309, 0, 2430409364),
|
220
|
+
Vmstat::Cpu.new(8, 15412864, 20799721, 0, 2443187236),
|
221
|
+
Vmstat::Cpu.new(9, 15016328, 23787482, 0, 2440596009),
|
222
|
+
Vmstat::Cpu.new(10, 21771975, 30059932, 0, 2427567910),
|
223
|
+
Vmstat::Cpu.new(11, 20183500, 27388335, 0, 2431827979),
|
224
|
+
Vmstat::Cpu.new(12, 15298846, 21276397, 0, 2442824569),
|
225
|
+
Vmstat::Cpu.new(13, 13929592, 22081759, 0, 2443388458),
|
226
|
+
Vmstat::Cpu.new(14, 21278693, 23352419, 0, 2434768696),
|
227
|
+
Vmstat::Cpu.new(15, 19834642, 27050642, 0, 2432514522),
|
228
|
+
Vmstat::Cpu.new(16, 20984253, 21833225, 0, 2436582325),
|
229
|
+
Vmstat::Cpu.new(17, 17568236, 29580663, 0, 2432250902),
|
230
|
+
Vmstat::Cpu.new(18, 13608419, 18480841, 0, 2447310538),
|
231
|
+
Vmstat::Cpu.new(19, 12552980, 20384068, 0, 2446462748),
|
232
|
+
Vmstat::Cpu.new(20, 18713575, 20976077, 0, 2439710143),
|
233
|
+
Vmstat::Cpu.new(21, 18770245, 26063716, 0, 2434565830),
|
234
|
+
Vmstat::Cpu.new(22, 12784738, 18718466, 0, 2447896586),
|
235
|
+
Vmstat::Cpu.new(23, 13065972, 21510594, 0, 2444823222),
|
236
|
+
Vmstat::Cpu.new(24, 19816643, 22266295, 0, 2437316848),
|
237
|
+
Vmstat::Cpu.new(25, 19200341, 26748441, 0, 2433451000),
|
238
|
+
Vmstat::Cpu.new(26, 13374474, 19619834, 0, 2446405472),
|
239
|
+
Vmstat::Cpu.new(27, 13564039, 21816225, 0, 2444019515),
|
240
|
+
Vmstat::Cpu.new(28, 20489701, 23125551, 0, 2435784523),
|
241
|
+
Vmstat::Cpu.new(29, 19970999, 27198273, 0, 2432230501),
|
242
|
+
Vmstat::Cpu.new(30, 14676176, 20310412, 0, 2444413183),
|
243
|
+
Vmstat::Cpu.new(31, 14400967, 22515695, 0, 2442483106)
|
244
|
+
]
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
248
|
+
context "#memory" do
|
249
|
+
subject { solaris.memory }
|
250
|
+
|
251
|
+
it { should be_a(Vmstat::Memory) }
|
252
|
+
it do
|
253
|
+
should == Vmstat::Memory.new(4096, 409145, 9018, 0, 61103, 0, 0)
|
254
|
+
end
|
255
|
+
end
|
256
|
+
|
257
|
+
context "#boot_time" do
|
258
|
+
subject { solaris.boot_time }
|
259
|
+
|
260
|
+
it { should be_a(Time) }
|
261
|
+
it { should == Time.at(1470765992) }
|
262
|
+
end
|
263
|
+
|
264
|
+
context "#network_interfaces" do
|
265
|
+
subject { solaris.network_interfaces }
|
266
|
+
|
267
|
+
it { should be_a(Array) }
|
268
|
+
it do
|
269
|
+
should == [
|
270
|
+
Vmstat::NetworkInterface.new(:e1000g0, 1000, 0, 0, 2000, 1,
|
271
|
+
Vmstat::NetworkInterface::ETHERNET_TYPE)
|
272
|
+
]
|
273
|
+
end
|
274
|
+
end
|
275
|
+
end
|
data/spec/vmstat_spec.rb
CHANGED
@@ -24,7 +24,7 @@ describe Vmstat do
|
|
24
24
|
Vmstat.loopback_devices.size.should == 1
|
25
25
|
end
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
context "performance" do
|
29
29
|
percent = RUBY_VERSION.to_i == 2 ? 26 : 10
|
30
30
|
|
@@ -44,5 +44,5 @@ describe Vmstat do
|
|
44
44
|
it_should_behave_like "a not memory leaking method", :disk, "/"
|
45
45
|
it_should_behave_like "a not memory leaking method", :boot_time
|
46
46
|
it_should_behave_like "a not memory leaking method", :load_average
|
47
|
-
end
|
47
|
+
end if ENV['PERF'] == "1"
|
48
48
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vmstat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vincent Landgraf
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -114,9 +114,11 @@ files:
|
|
114
114
|
- lib/vmstat/linux_disk.rb
|
115
115
|
- lib/vmstat/load_average.rb
|
116
116
|
- lib/vmstat/memory.rb
|
117
|
+
- lib/vmstat/netopenbsd.rb
|
117
118
|
- lib/vmstat/network_interface.rb
|
118
119
|
- lib/vmstat/procfs.rb
|
119
120
|
- lib/vmstat/snapshot.rb
|
121
|
+
- lib/vmstat/solaris.rb
|
120
122
|
- lib/vmstat/stub.rb
|
121
123
|
- lib/vmstat/task.rb
|
122
124
|
- lib/vmstat/version.rb
|
@@ -135,6 +137,7 @@ files:
|
|
135
137
|
- spec/vmstat/network_spec.rb
|
136
138
|
- spec/vmstat/procfs_spec.rb
|
137
139
|
- spec/vmstat/snapshot_spec.rb
|
140
|
+
- spec/vmstat/solaris_spec.rb
|
138
141
|
- spec/vmstat/task_spec.rb
|
139
142
|
- spec/vmstat_spec.rb
|
140
143
|
- vmstat.gemspec
|
@@ -157,7 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
157
160
|
version: '0'
|
158
161
|
requirements: []
|
159
162
|
rubyforge_project:
|
160
|
-
rubygems_version: 2.4.
|
163
|
+
rubygems_version: 2.4.8
|
161
164
|
signing_key:
|
162
165
|
specification_version: 4
|
163
166
|
summary: A focused and fast library to gather system information
|
@@ -177,5 +180,6 @@ test_files:
|
|
177
180
|
- spec/vmstat/network_spec.rb
|
178
181
|
- spec/vmstat/procfs_spec.rb
|
179
182
|
- spec/vmstat/snapshot_spec.rb
|
183
|
+
- spec/vmstat/solaris_spec.rb
|
180
184
|
- spec/vmstat/task_spec.rb
|
181
185
|
- spec/vmstat_spec.rb
|