solaris-kstat 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGES +13 -0
- data/README +8 -17
- data/Rakefile +37 -43
- data/ext/solaris/rkstat.c +170 -148
- data/ext/solaris/rkstat.h +276 -288
- data/solaris-kstat.gemspec +24 -29
- data/test/test_solaris_kstat.rb +155 -149
- metadata +20 -10
data/solaris-kstat.gemspec
CHANGED
@@ -1,35 +1,30 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
gem.extensions = ['ext/extconf.rb']
|
15
|
-
gem.files = Dir['**/*'].reject{ |f| f.include?('CVS') }
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = 'solaris-kstat'
|
5
|
+
spec.version = '1.0.2'
|
6
|
+
spec.author = 'Daniel J. Berger'
|
7
|
+
spec.license = 'Artistic 2.0'
|
8
|
+
spec.email = 'djberg96@gmail.com'
|
9
|
+
spec.homepage = 'http://www.rubyforge.org/projects/solarisutils'
|
10
|
+
spec.summary = 'Interface for the Solaris kstat library'
|
11
|
+
spec.test_file = 'test/test_solaris_kstat.rb'
|
12
|
+
spec.extensions = ['ext/extconf.rb']
|
13
|
+
spec.files = Dir['**/*'].reject{ |f| f.include?('git') }
|
16
14
|
|
17
|
-
|
15
|
+
spec.rubyforge_project = 'solarisutils'
|
18
16
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
17
|
+
spec.extra_rdoc_files = [
|
18
|
+
'README',
|
19
|
+
'CHANGES',
|
20
|
+
'MANIFEST',
|
21
|
+
'ext/solaris/rkstat.c'
|
22
|
+
]
|
25
23
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
EOF
|
24
|
+
spec.description = <<-EOF
|
25
|
+
The solaris-kstat library provides a Ruby interface for gathering kernel
|
26
|
+
statistics from the Solaris operating system. Each matching statistic is
|
27
|
+
provided with its module, instance, and name fields, as well as its actual
|
28
|
+
value.
|
29
|
+
EOF
|
33
30
|
end
|
34
|
-
|
35
|
-
Gem::Builder.new(spec).build
|
data/test/test_solaris_kstat.rb
CHANGED
@@ -13,153 +13,159 @@ require 'set'
|
|
13
13
|
include Solaris
|
14
14
|
|
15
15
|
class TC_Solaris_Kstat < Test::Unit::TestCase
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
16
|
+
def setup
|
17
|
+
@kstat = Kstat.new
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_version
|
21
|
+
assert_equal('1.0.2', Kstat::VERSION)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_name
|
25
|
+
assert_respond_to(@kstat, :name)
|
26
|
+
assert_respond_to(@kstat, :name=)
|
27
|
+
assert_nil(@kstat.name)
|
28
|
+
assert_nothing_raised{ @kstat.name }
|
29
|
+
assert_nothing_raised{ @kstat.name = 'foo' }
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_module
|
33
|
+
assert_respond_to(@kstat, :module)
|
34
|
+
assert_respond_to(@kstat, :module=)
|
35
|
+
assert_nil(@kstat.module)
|
36
|
+
assert_nothing_raised{ @kstat.module }
|
37
|
+
assert_nothing_raised{ @kstat.module = 'bar' }
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_instance
|
41
|
+
assert_respond_to(@kstat, :instance)
|
42
|
+
assert_respond_to(@kstat, :instance=)
|
43
|
+
assert_nil(@kstat.instance)
|
44
|
+
assert_nothing_raised{ @kstat.instance }
|
45
|
+
assert_nothing_raised{ @kstat.instance = 0 }
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_constructor_valid_values
|
49
|
+
assert_nothing_raised{ Kstat.new('cpu_info',0,'cpu_info0').record }
|
50
|
+
assert_nothing_raised{ Kstat.new(nil,0,'cpu_info0').record }
|
51
|
+
assert_nothing_raised{ Kstat.new('cpu_info',0,nil).record }
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_constructor_invalid_values
|
55
|
+
assert_raises(Kstat::Error){ Kstat.new('bogus').record }
|
56
|
+
assert_raises(Kstat::Error){ Kstat.new('cpu_info',99).record }
|
57
|
+
assert_raises(Kstat::Error){ Kstat.new('cpu_info',0,'bogus').record }
|
58
|
+
assert_raises(TypeError){ Kstat.new('cpu_info','x').record }
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_record_basic
|
62
|
+
assert_respond_to(@kstat, :record)
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_record_named
|
66
|
+
assert_nothing_raised{ @kstat.record['cpu_info'][0]['cpu_info0'] }
|
67
|
+
assert_kind_of(Hash, @kstat.record['cpu_info'][0]['cpu_info0'])
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_record_io
|
71
|
+
assert_nothing_raised{ @kstat.record['nfs'][1]['nfs1'] }
|
72
|
+
assert_kind_of(Hash, @kstat.record['nfs'][1]['nfs1'])
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_record_intr
|
76
|
+
assert_nothing_raised{ @kstat.record['fd'][0]['fd0'] }
|
77
|
+
assert_kind_of(Hash, @kstat.record['fd'][0]['fd0'])
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_record_raw_vminfo
|
81
|
+
keys = %w/class freemem swap_alloc swap_avail swap_free swap_resv/
|
82
|
+
|
83
|
+
assert_nothing_raised{ @kstat.record['unix'][0]['vminfo'] }
|
84
|
+
assert_kind_of(Hash, @kstat.record['unix'][0]['vminfo'])
|
85
|
+
assert_equal(keys, @kstat.record['unix'][0]['vminfo'].keys.sort)
|
86
|
+
end
|
87
|
+
|
88
|
+
def test_record_raw_var
|
89
|
+
keys = %w/
|
90
|
+
class v_autoup v_buf v_bufhwm v_call v_clist v_hbuf v_hmask
|
91
|
+
v_maxpmem v_maxsyspri v_maxup v_maxupttl v_nglobpris v_pbuf
|
92
|
+
v_proc v_sptmap
|
93
|
+
/
|
94
|
+
|
95
|
+
assert_nothing_raised{ @kstat.record['unix'][0]['var'] }
|
96
|
+
assert_kind_of(Hash, @kstat.record['unix'][0]['var'])
|
97
|
+
assert_equal(keys, @kstat.record['unix'][0]['var'].keys.sort)
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_record_raw_biostats
|
101
|
+
keys = %w/
|
102
|
+
buffer_cache_hits
|
103
|
+
buffer_cache_lookups
|
104
|
+
buffers_locked_by_someone
|
105
|
+
class
|
106
|
+
duplicate_buffers_found
|
107
|
+
new_buffer_requests
|
108
|
+
waits_for_buffer_allocs
|
109
|
+
/
|
110
|
+
|
111
|
+
assert_nothing_raised{ @kstat.record['unix'][0]['biostats'] }
|
112
|
+
assert_kind_of([Hash, NilClass], @kstat.record['unix'][0]['biostats'])
|
113
|
+
assert_equal(keys, @kstat.record['unix'][0]['biostats'].keys.sort)
|
114
|
+
end
|
115
|
+
|
116
|
+
def test_record_raw_cpu_stat
|
117
|
+
keys = %w/
|
118
|
+
class cpu_idle cpu_user cpu_kernel cpu_wait wait_io wait_swap
|
119
|
+
wait_pio bread bwrite lread lwrite phread phwrite pswitch
|
120
|
+
trap intr syscall sysread syswrite sysfork sysvfork sysexec
|
121
|
+
readch writech rcvint xmtint mdmint rawch canch outch msg
|
122
|
+
sema namei ufsiget ufsdirblk ufsipage ufsinopage inodeovf
|
123
|
+
fileovf procovf intrthread intrblk idlethread inv_swtch
|
124
|
+
nthreads cpumigrate xcalls mutex_adenters rw_rdfails
|
125
|
+
rw_wrfails modload modunload bawrite
|
126
|
+
/
|
127
|
+
|
128
|
+
assert_nothing_raised{ @kstat.record['cpu_stat'][0]['cpu_stat0'] }
|
129
|
+
assert_kind_of(Hash, @kstat.record['cpu_stat'][0]['cpu_stat0'])
|
130
|
+
|
131
|
+
# Too big and difficult to sort manually - so use a Set
|
132
|
+
set1 = Set.new(keys)
|
133
|
+
set2 = Set.new(@kstat.record['cpu_stat'][0]['cpu_stat0'].keys)
|
134
|
+
diff = set1 - set2
|
135
|
+
|
136
|
+
assert_equal(set1,set2,'Diff was: #{diff.to_a}')
|
137
|
+
end
|
138
|
+
|
139
|
+
def test_record_ncstats
|
140
|
+
keys = %w/
|
141
|
+
class
|
142
|
+
dbl_enters
|
143
|
+
enters
|
144
|
+
hits
|
145
|
+
long_enter
|
146
|
+
long_look misses
|
147
|
+
move_to_front
|
148
|
+
purges
|
149
|
+
/
|
150
|
+
|
151
|
+
assert_nothing_raised{ @kstat.record['unix'][0]['ncstats'] }
|
152
|
+
assert_kind_of(Hash, @kstat.record['unix'][0]['ncstats'])
|
153
|
+
assert_equal(keys, @kstat.record['unix'][0]['ncstats'].keys.sort)
|
154
|
+
end
|
155
|
+
|
156
|
+
def test_record_sysinfo
|
157
|
+
keys = %w/class runocc runque swpocc swpque updates waiting/
|
158
|
+
|
159
|
+
assert_nothing_raised{ @kstat.record['unix'][0]['sysinfo'] }
|
160
|
+
assert_kind_of(Hash, @kstat.record['unix'][0]['sysinfo'])
|
161
|
+
assert_equal(keys, @kstat.record['unix'][0]['sysinfo'].keys.sort)
|
162
|
+
end
|
163
|
+
|
164
|
+
def test_class_set
|
165
|
+
assert_equal("misc", @kstat.record['unix'][0]['sysinfo']['class'])
|
166
|
+
end
|
167
|
+
|
168
|
+
def teardown
|
169
|
+
@kstat = nil
|
170
|
+
end
|
165
171
|
end
|
metadata
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solaris-kstat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 19
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
- 2
|
10
|
+
version: 1.0.2
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
13
|
- Daniel J. Berger
|
@@ -9,11 +15,10 @@ autorequire:
|
|
9
15
|
bindir: bin
|
10
16
|
cert_chain: []
|
11
17
|
|
12
|
-
date:
|
13
|
-
default_executable:
|
18
|
+
date: 2011-07-29 00:00:00 Z
|
14
19
|
dependencies: []
|
15
20
|
|
16
|
-
description: "
|
21
|
+
description: " The solaris-kstat library provides a Ruby interface for gathering kernel\n statistics from the Solaris operating system. Each matching statistic is\n provided with its module, instance, and name fields, as well as its actual\n value.\n"
|
17
22
|
email: djberg96@gmail.com
|
18
23
|
executables: []
|
19
24
|
|
@@ -29,13 +34,12 @@ files:
|
|
29
34
|
- MANIFEST
|
30
35
|
- README
|
31
36
|
- Rakefile
|
32
|
-
- solaris-kstat.gemspec
|
33
37
|
- examples/example_kstat.rb
|
34
38
|
- ext/extconf.rb
|
35
39
|
- ext/solaris/rkstat.c
|
36
40
|
- ext/solaris/rkstat.h
|
41
|
+
- solaris-kstat.gemspec
|
37
42
|
- test/test_solaris_kstat.rb
|
38
|
-
has_rdoc: true
|
39
43
|
homepage: http://www.rubyforge.org/projects/solarisutils
|
40
44
|
licenses:
|
41
45
|
- Artistic 2.0
|
@@ -45,21 +49,27 @@ rdoc_options: []
|
|
45
49
|
require_paths:
|
46
50
|
- lib
|
47
51
|
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
48
53
|
requirements:
|
49
54
|
- - ">="
|
50
55
|
- !ruby/object:Gem::Version
|
51
|
-
|
52
|
-
|
56
|
+
hash: 3
|
57
|
+
segments:
|
58
|
+
- 0
|
59
|
+
version: "0"
|
53
60
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
54
62
|
requirements:
|
55
63
|
- - ">="
|
56
64
|
- !ruby/object:Gem::Version
|
65
|
+
hash: 3
|
66
|
+
segments:
|
67
|
+
- 0
|
57
68
|
version: "0"
|
58
|
-
version:
|
59
69
|
requirements: []
|
60
70
|
|
61
71
|
rubyforge_project: solarisutils
|
62
|
-
rubygems_version: 1.
|
72
|
+
rubygems_version: 1.8.5
|
63
73
|
signing_key:
|
64
74
|
specification_version: 3
|
65
75
|
summary: Interface for the Solaris kstat library
|