solaris-kstat 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +12 -1
- data/MANIFEST +2 -2
- data/Rakefile +59 -0
- data/examples/example_kstat.rb +34 -0
- data/ext/solaris/rkstat.c +10 -1
- data/ext/solaris/rkstat.h +1 -1
- data/solaris-kstat.gemspec +35 -0
- data/test/test_solaris_kstat.rb +165 -0
- metadata +15 -12
- data/examples/test.rb +0 -43
- data/test/tc_kstat.rb +0 -147
data/CHANGES
CHANGED
@@ -1,4 +1,15 @@
|
|
1
|
-
== 1.0.
|
1
|
+
== 1.0.1 - 27-Aug-2009
|
2
|
+
* Changed the license to Artistic 2.0.
|
3
|
+
* Fixed warnings that could occur if the @module, @name, or @instance
|
4
|
+
variables were not set in the constructor. They are now explicitly
|
5
|
+
set to nil if they do not have any value.
|
6
|
+
* Updates to the gemspec, including license and description.
|
7
|
+
* Renamed and performed some minor refactoring of the test and example files.
|
8
|
+
* Changed one test to use 'biostats' instead of 'flushmeter' because
|
9
|
+
the latter does not appear to be defined in a Solaris VM.
|
10
|
+
* Added the 'example' rake task.
|
11
|
+
|
12
|
+
== 1.0.0 - 4-Feb-2008
|
2
13
|
* Updated the extconf.rb file so that it sets the target prefix properly.
|
3
14
|
* Version bump to 1.0.0.
|
4
15
|
* No actual source code changes.
|
data/MANIFEST
CHANGED
data/Rakefile
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/clean'
|
3
|
+
require 'rake/testtask'
|
4
|
+
require 'rbconfig'
|
5
|
+
include Config
|
6
|
+
|
7
|
+
desc "Clean the build files for the solaris-kstat source"
|
8
|
+
task :clean do
|
9
|
+
FileUtils.rm_rf('solaris') if File.exists?('solaris')
|
10
|
+
|
11
|
+
Dir.chdir('ext') do
|
12
|
+
FileUtils.rm_rf('rkstat.c') if File.exists?('rkstat.c')
|
13
|
+
FileUtils.rm_rf('rkstat.h') if File.exists?('rkstat.h')
|
14
|
+
sh 'make distclean' if File.exists?('kstat.so')
|
15
|
+
FileUtils.rm_rf('solaris/kstat.so') if File.exists?('solaris/kstat.so')
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
desc "Build the solaris-kstat package (but don't install it)"
|
20
|
+
task :build => [:clean] do
|
21
|
+
Dir.chdir('ext') do
|
22
|
+
ruby 'extconf.rb'
|
23
|
+
sh 'make'
|
24
|
+
Dir.mkdir('solaris') unless File.exists?('solaris')
|
25
|
+
FileUtils.cp('kstat.so', 'solaris')
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
desc "Install the solaris-kstat package (non-gem)"
|
30
|
+
task :install => [:build] do
|
31
|
+
Dir.chdir('ext') do
|
32
|
+
sh 'make install'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
desc "Install the solaris-kstat package as a gem"
|
37
|
+
task :install_gem do
|
38
|
+
ruby 'solaris-kstat.gemspec'
|
39
|
+
file = Dir["*.gem"].first
|
40
|
+
sh "gem install #{file}"
|
41
|
+
end
|
42
|
+
|
43
|
+
desc "Uninstall the solaris-kstat package. Use 'gem uninstall' for gem installs"
|
44
|
+
task :uninstall => [:clean] do
|
45
|
+
file = File.join(CONFIG['sitearchdir'], 'solaris', 'kstat.so')
|
46
|
+
FileUtils.rm_rf(file) if File.exists?(file)
|
47
|
+
end
|
48
|
+
|
49
|
+
desc "Run the example program"
|
50
|
+
task :example => [:build] do
|
51
|
+
ruby "-Iext examples/example_kstat.rb"
|
52
|
+
end
|
53
|
+
|
54
|
+
Rake::TestTask.new do |t|
|
55
|
+
task :test => :build
|
56
|
+
t.libs << 'ext'
|
57
|
+
t.verbose = true
|
58
|
+
t.warning = true
|
59
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
#######################################################################
|
2
|
+
# example_kstat.rb
|
3
|
+
#
|
4
|
+
# Sample script for general futzing. You can run this script via
|
5
|
+
# the 'rake example' task.
|
6
|
+
#######################################################################
|
7
|
+
require "solaris/kstat"
|
8
|
+
require "pp"
|
9
|
+
include Solaris
|
10
|
+
|
11
|
+
puts "VERSION: " + Kstat::VERSION
|
12
|
+
puts
|
13
|
+
|
14
|
+
k1 = Kstat.new('cpu_info', 0)
|
15
|
+
pp k1.record
|
16
|
+
|
17
|
+
puts '=' * 40
|
18
|
+
|
19
|
+
k2 = Kstat.new('unix', 0, 'biostats')
|
20
|
+
pp k2
|
21
|
+
|
22
|
+
# Print all modules
|
23
|
+
k = Kstat.new
|
24
|
+
k.record.each{ |k,v|
|
25
|
+
p k
|
26
|
+
}
|
27
|
+
|
28
|
+
=begin
|
29
|
+
pp k.record["cpu_info"][0]["cpu_info0"]
|
30
|
+
puts "=" * 40
|
31
|
+
pp k.record["unix"][0]["flushmeter"]
|
32
|
+
puts "=" * 40
|
33
|
+
pp k.record["cpu_stat"][0]["cpu_stat0"]
|
34
|
+
=end
|
data/ext/solaris/rkstat.c
CHANGED
@@ -44,18 +44,27 @@ VALUE ks_init(int argc, VALUE* argv, VALUE self){
|
|
44
44
|
|
45
45
|
rb_scan_args(argc, argv, "03", &v_module, &v_instance, &v_name);
|
46
46
|
|
47
|
+
|
47
48
|
if(!NIL_P(v_module)){
|
48
49
|
SafeStringValue(v_module);
|
49
50
|
rb_iv_set(self, "@module", v_module);
|
50
51
|
}
|
52
|
+
else{
|
53
|
+
rb_iv_set(self, "@module", Qnil);
|
54
|
+
}
|
51
55
|
|
52
56
|
if(!NIL_P(v_name)){
|
53
57
|
SafeStringValue(v_name);
|
54
58
|
rb_iv_set(self, "@name", v_name);
|
55
59
|
}
|
60
|
+
else{
|
61
|
+
rb_iv_set(self, "@name", Qnil);
|
62
|
+
}
|
56
63
|
|
57
64
|
if(!NIL_P(v_instance))
|
58
65
|
rb_iv_set(self, "@instance", v_instance);
|
66
|
+
else
|
67
|
+
rb_iv_set(self, "@instance", Qnil);
|
59
68
|
|
60
69
|
return self;
|
61
70
|
}
|
@@ -199,7 +208,7 @@ void Init_kstat(){
|
|
199
208
|
/* Unique name within module */
|
200
209
|
rb_define_attr(cKstat, "name", 1, 1);
|
201
210
|
|
202
|
-
/* 1.0.
|
211
|
+
/* 1.0.1: The version of the solaris-kstat library */
|
203
212
|
rb_define_const(cKstat, "VERSION", rb_str_new2(SOLARIS_KSTAT_VERSION));
|
204
213
|
}
|
205
214
|
|
data/ext/solaris/rkstat.h
CHANGED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
|
3
|
+
spec = Gem::Specification.new do |gem|
|
4
|
+
gem.name = 'solaris-kstat'
|
5
|
+
gem.version = '1.0.1'
|
6
|
+
gem.author = 'Daniel J. Berger'
|
7
|
+
gem.license = 'Artistic 2.0'
|
8
|
+
gem.email = 'djberg96@gmail.com'
|
9
|
+
gem.homepage = 'http://www.rubyforge.org/projects/solarisutils'
|
10
|
+
gem.platform = Gem::Platform::RUBY
|
11
|
+
gem.summary = 'Interface for the Solaris kstat library'
|
12
|
+
gem.has_rdoc = true
|
13
|
+
gem.test_file = 'test/test_solaris_kstat.rb'
|
14
|
+
gem.extensions = ['ext/extconf.rb']
|
15
|
+
gem.files = Dir['**/*'].reject{ |f| f.include?('CVS') }
|
16
|
+
|
17
|
+
gem.rubyforge_project = 'solarisutils'
|
18
|
+
|
19
|
+
gem.extra_rdoc_files = [
|
20
|
+
'README',
|
21
|
+
'CHANGES',
|
22
|
+
'MANIFEST',
|
23
|
+
'ext/solaris/rkstat.c'
|
24
|
+
]
|
25
|
+
|
26
|
+
gem.required_ruby_version = '>= 1.8.0'
|
27
|
+
|
28
|
+
gem.description = <<-EOF
|
29
|
+
The solaris-kstat library provides a Ruby interface for gathering kernel
|
30
|
+
statistics from the operating system. Each matching statistic is provided
|
31
|
+
with its module, instance, and name fields, as well as its actual value.
|
32
|
+
EOF
|
33
|
+
end
|
34
|
+
|
35
|
+
Gem::Builder.new(spec).build
|
@@ -0,0 +1,165 @@
|
|
1
|
+
###############################################################################
|
2
|
+
# test_solaris_kstat.rb
|
3
|
+
#
|
4
|
+
# Test suite for the solaris-kstat Ruby library. You should run this via
|
5
|
+
# the 'rake test' task.
|
6
|
+
###############################################################################
|
7
|
+
require 'rubygems'
|
8
|
+
gem 'test-unit'
|
9
|
+
|
10
|
+
require 'solaris/kstat'
|
11
|
+
require 'test/unit'
|
12
|
+
require 'set'
|
13
|
+
include Solaris
|
14
|
+
|
15
|
+
class TC_Solaris_Kstat < Test::Unit::TestCase
|
16
|
+
def setup
|
17
|
+
@k = Kstat.new
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_version
|
21
|
+
assert_equal('1.0.1', Kstat::VERSION)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_name
|
25
|
+
assert_respond_to(@k, :name)
|
26
|
+
assert_respond_to(@k, :name=)
|
27
|
+
assert_nil(@k.name)
|
28
|
+
assert_nothing_raised{ @k.name }
|
29
|
+
assert_nothing_raised{ @k.name = 'foo' }
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_module
|
33
|
+
assert_respond_to(@k, :module)
|
34
|
+
assert_respond_to(@k, :module=)
|
35
|
+
assert_nil(@k.module)
|
36
|
+
assert_nothing_raised{ @k.module }
|
37
|
+
assert_nothing_raised{ @k.module = 'bar' }
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_instance
|
41
|
+
assert_respond_to(@k, :instance)
|
42
|
+
assert_respond_to(@k, :instance=)
|
43
|
+
assert_nil(@k.instance)
|
44
|
+
assert_nothing_raised{ @k.instance }
|
45
|
+
assert_nothing_raised{ @k.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(@k, :record)
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_record_named
|
66
|
+
assert_nothing_raised{ @k.record['cpu_info'][0]['cpu_info0'] }
|
67
|
+
assert_kind_of(Hash, @k.record['cpu_info'][0]['cpu_info0'])
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_record_io
|
71
|
+
assert_nothing_raised{ @k.record['nfs'][1]['nfs1'] }
|
72
|
+
assert_kind_of(Hash, @k.record['nfs'][1]['nfs1'])
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_record_intr
|
76
|
+
assert_nothing_raised{ @k.record['fd'][0]['fd0'] }
|
77
|
+
assert_kind_of(Hash, @k.record['fd'][0]['fd0'])
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_record_raw_vminfo
|
81
|
+
keys = %w/freemem swap_alloc swap_avail swap_free swap_resv/
|
82
|
+
|
83
|
+
assert_nothing_raised{ @k.record['unix'][0]['vminfo'] }
|
84
|
+
assert_kind_of(Hash, @k.record['unix'][0]['vminfo'])
|
85
|
+
assert_equal(keys, @k.record['unix'][0]['vminfo'].keys.sort)
|
86
|
+
end
|
87
|
+
|
88
|
+
def test_record_raw_var
|
89
|
+
keys = %w/
|
90
|
+
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{ @k.record['unix'][0]['var'] }
|
96
|
+
assert_kind_of(Hash, @k.record['unix'][0]['var'])
|
97
|
+
assert_equal(keys, @k.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
|
+
duplicate_buffers_found
|
106
|
+
new_buffer_requests
|
107
|
+
waits_for_buffer_allocs
|
108
|
+
/
|
109
|
+
|
110
|
+
assert_nothing_raised{ @k.record['unix'][0]['biostats'] }
|
111
|
+
assert_kind_of([Hash, NilClass], @k.record['unix'][0]['biostats'])
|
112
|
+
assert_equal(keys, @k.record['unix'][0]['biostats'].keys.sort)
|
113
|
+
end
|
114
|
+
|
115
|
+
def test_record_raw_cpu_stat
|
116
|
+
keys = %w/
|
117
|
+
cpu_idle cpu_user cpu_kernel cpu_wait wait_io wait_swap
|
118
|
+
wait_pio bread bwrite lread lwrite phread phwrite pswitch
|
119
|
+
trap intr syscall sysread syswrite sysfork sysvfork sysexec
|
120
|
+
readch writech rcvint xmtint mdmint rawch canch outch msg
|
121
|
+
sema namei ufsiget ufsdirblk ufsipage ufsinopage inodeovf
|
122
|
+
fileovf procovf intrthread intrblk idlethread inv_swtch
|
123
|
+
nthreads cpumigrate xcalls mutex_adenters rw_rdfails
|
124
|
+
rw_wrfails modload modunload bawrite
|
125
|
+
/
|
126
|
+
|
127
|
+
assert_nothing_raised{ @k.record['cpu_stat'][0]['cpu_stat0'] }
|
128
|
+
assert_kind_of(Hash, @k.record['cpu_stat'][0]['cpu_stat0'])
|
129
|
+
|
130
|
+
# Too big and difficult to sort manually - so use a Set
|
131
|
+
set1 = Set.new(keys)
|
132
|
+
set2 = Set.new(@k.record['cpu_stat'][0]['cpu_stat0'].keys)
|
133
|
+
diff = set1 - set2
|
134
|
+
|
135
|
+
assert_equal(set1,set2,'Diff was: #{diff.to_a}')
|
136
|
+
end
|
137
|
+
|
138
|
+
def test_record_ncstats
|
139
|
+
keys = %w/
|
140
|
+
dbl_enters
|
141
|
+
enters
|
142
|
+
hits
|
143
|
+
long_enter
|
144
|
+
long_look misses
|
145
|
+
move_to_front
|
146
|
+
purges
|
147
|
+
/
|
148
|
+
|
149
|
+
assert_nothing_raised{ @k.record['unix'][0]['ncstats'] }
|
150
|
+
assert_kind_of(Hash, @k.record['unix'][0]['ncstats'])
|
151
|
+
assert_equal(keys, @k.record['unix'][0]['ncstats'].keys.sort)
|
152
|
+
end
|
153
|
+
|
154
|
+
def test_record_sysinfo
|
155
|
+
keys = %w/runocc runque swpocc swpque updates waiting/
|
156
|
+
|
157
|
+
assert_nothing_raised{ @k.record['unix'][0]['sysinfo'] }
|
158
|
+
assert_kind_of(Hash, @k.record['unix'][0]['sysinfo'])
|
159
|
+
assert_equal(keys, @k.record['unix'][0]['sysinfo'].keys.sort)
|
160
|
+
end
|
161
|
+
|
162
|
+
def teardown
|
163
|
+
@k = nil
|
164
|
+
end
|
165
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solaris-kstat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel J. Berger
|
@@ -9,11 +9,11 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2009-08-27 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
16
|
-
description:
|
16
|
+
description: " The solaris-kstat library provides a Ruby interface for gathering kernel\n statistics from the operating system. Each matching statistic is provided\n with its module, instance, and name fields, as well as its actual value.\n"
|
17
17
|
email: djberg96@gmail.com
|
18
18
|
executables: []
|
19
19
|
|
@@ -25,17 +25,20 @@ extra_rdoc_files:
|
|
25
25
|
- MANIFEST
|
26
26
|
- ext/solaris/rkstat.c
|
27
27
|
files:
|
28
|
+
- CHANGES
|
29
|
+
- MANIFEST
|
30
|
+
- README
|
31
|
+
- Rakefile
|
32
|
+
- solaris-kstat.gemspec
|
33
|
+
- examples/example_kstat.rb
|
28
34
|
- ext/extconf.rb
|
29
|
-
- ext/solaris
|
30
35
|
- ext/solaris/rkstat.c
|
31
36
|
- ext/solaris/rkstat.h
|
32
|
-
- test/
|
33
|
-
- examples/test.rb
|
34
|
-
- README
|
35
|
-
- CHANGES
|
36
|
-
- MANIFEST
|
37
|
+
- test/test_solaris_kstat.rb
|
37
38
|
has_rdoc: true
|
38
39
|
homepage: http://www.rubyforge.org/projects/solarisutils
|
40
|
+
licenses:
|
41
|
+
- Artistic 2.0
|
39
42
|
post_install_message:
|
40
43
|
rdoc_options: []
|
41
44
|
|
@@ -56,9 +59,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
56
59
|
requirements: []
|
57
60
|
|
58
61
|
rubyforge_project: solarisutils
|
59
|
-
rubygems_version: 1.
|
62
|
+
rubygems_version: 1.3.5
|
60
63
|
signing_key:
|
61
|
-
specification_version:
|
64
|
+
specification_version: 3
|
62
65
|
summary: Interface for the Solaris kstat library
|
63
66
|
test_files:
|
64
|
-
- test/
|
67
|
+
- test/test_solaris_kstat.rb
|
data/examples/test.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
########################################################
|
2
|
-
# test_kstat.rb
|
3
|
-
#
|
4
|
-
# Sample script for general futzing.
|
5
|
-
########################################################
|
6
|
-
base = File.basename(Dir.pwd)
|
7
|
-
|
8
|
-
if base == "examples" || base =~ /solaris-kstat.*/
|
9
|
-
require "ftools"
|
10
|
-
Dir.chdir ".." if base == "examples"
|
11
|
-
Dir.mkdir("solaris") unless File.exists?("solaris")
|
12
|
-
File.copy("kstat.so","solaris")
|
13
|
-
$LOAD_PATH.unshift Dir.pwd
|
14
|
-
end
|
15
|
-
|
16
|
-
require "solaris/kstat"
|
17
|
-
require "pp"
|
18
|
-
include Solaris
|
19
|
-
|
20
|
-
puts "VERSION: " + Kstat::VERSION
|
21
|
-
puts
|
22
|
-
|
23
|
-
k1 = Kstat.new("cpu_info",0)
|
24
|
-
pp k1.record
|
25
|
-
|
26
|
-
puts "=" * 40
|
27
|
-
|
28
|
-
k2 = Kstat.new("unix",0,"flushmeter")
|
29
|
-
pp k2
|
30
|
-
|
31
|
-
# Print all modules
|
32
|
-
k = Kstat.new
|
33
|
-
k.record.each{ |k,v|
|
34
|
-
p k
|
35
|
-
}
|
36
|
-
|
37
|
-
=begin
|
38
|
-
pp k.record["cpu_info"][0]["cpu_info0"]
|
39
|
-
puts "=" * 40
|
40
|
-
pp k.record["unix"][0]["flushmeter"]
|
41
|
-
puts "=" * 40
|
42
|
-
pp k.record["cpu_stat"][0]["cpu_stat0"]
|
43
|
-
=end
|
data/test/tc_kstat.rb
DELETED
@@ -1,147 +0,0 @@
|
|
1
|
-
###############################################################################
|
2
|
-
# tc_kstat.rb
|
3
|
-
#
|
4
|
-
# Test suite for the solaris-kstat Ruby package. You should run this via
|
5
|
-
# the 'rake test' task.
|
6
|
-
###############################################################################
|
7
|
-
require "solaris/kstat"
|
8
|
-
require "test/unit"
|
9
|
-
require "set"
|
10
|
-
include Solaris
|
11
|
-
|
12
|
-
class TC_Kstat < Test::Unit::TestCase
|
13
|
-
def setup
|
14
|
-
@k = Kstat.new
|
15
|
-
end
|
16
|
-
|
17
|
-
def test_version
|
18
|
-
assert_equal('1.0.0', Kstat::VERSION)
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_name
|
22
|
-
assert_respond_to(@k, :name)
|
23
|
-
assert_respond_to(@k, :name=)
|
24
|
-
assert_nil(@k.name)
|
25
|
-
assert_nothing_raised{ @k.name }
|
26
|
-
assert_nothing_raised{ @k.name = "foo" }
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_module
|
30
|
-
assert_respond_to(@k, :module)
|
31
|
-
assert_respond_to(@k, :module=)
|
32
|
-
assert_nil(@k.module)
|
33
|
-
assert_nothing_raised{ @k.module }
|
34
|
-
assert_nothing_raised{ @k.module = "bar" }
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_instance
|
38
|
-
assert_respond_to(@k, :instance)
|
39
|
-
assert_respond_to(@k, :instance=)
|
40
|
-
assert_nil(@k.instance)
|
41
|
-
assert_nothing_raised{ @k.instance }
|
42
|
-
assert_nothing_raised{ @k.instance = 0 }
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_constructor_valid_values
|
46
|
-
assert_nothing_raised{ Kstat.new("cpu_info",0,"cpu_info0").record }
|
47
|
-
assert_nothing_raised{ Kstat.new(nil,0,"cpu_info0").record }
|
48
|
-
assert_nothing_raised{ Kstat.new("cpu_info",0,nil).record }
|
49
|
-
end
|
50
|
-
|
51
|
-
def test_constructor_invalid_values
|
52
|
-
assert_raises(Kstat::Error){ Kstat.new("bogus").record }
|
53
|
-
assert_raises(Kstat::Error){ Kstat.new("cpu_info",99).record }
|
54
|
-
assert_raises(Kstat::Error){ Kstat.new("cpu_info",0,"bogus").record }
|
55
|
-
assert_raises(TypeError){ Kstat.new("cpu_info","x").record }
|
56
|
-
end
|
57
|
-
|
58
|
-
def test_record_basic
|
59
|
-
assert_respond_to(@k, :record)
|
60
|
-
end
|
61
|
-
|
62
|
-
def test_record_named
|
63
|
-
assert_nothing_raised{ @k.record["cpu_info"][0]["cpu_info0"] }
|
64
|
-
assert_kind_of(Hash, @k.record["cpu_info"][0]["cpu_info0"])
|
65
|
-
end
|
66
|
-
|
67
|
-
def test_record_io
|
68
|
-
assert_nothing_raised{ @k.record["nfs"][1]["nfs1"] }
|
69
|
-
assert_kind_of(Hash, @k.record["nfs"][1]["nfs1"])
|
70
|
-
end
|
71
|
-
|
72
|
-
def test_record_intr
|
73
|
-
assert_nothing_raised{ @k.record["fd"][0]["fd0"] }
|
74
|
-
assert_kind_of(Hash, @k.record["fd"][0]["fd0"])
|
75
|
-
end
|
76
|
-
|
77
|
-
def test_record_raw_vminfo
|
78
|
-
keys = %w/freemem swap_alloc swap_avail swap_free swap_resv/
|
79
|
-
|
80
|
-
assert_nothing_raised{ @k.record["unix"][0]["vminfo"] }
|
81
|
-
assert_kind_of(Hash, @k.record["unix"][0]["vminfo"])
|
82
|
-
assert_equal(keys, @k.record["unix"][0]["vminfo"].keys.sort)
|
83
|
-
end
|
84
|
-
|
85
|
-
def test_record_raw_var
|
86
|
-
keys = %w/v_autoup v_buf v_bufhwm v_call v_clist v_hbuf v_hmask/
|
87
|
-
keys.push %w/v_maxpmem v_maxsyspri v_maxup v_maxupttl v_nglobpris v_pbuf/
|
88
|
-
keys.push %w/v_proc v_sptmap/
|
89
|
-
keys.flatten!
|
90
|
-
|
91
|
-
assert_nothing_raised{ @k.record["unix"][0]["var"] }
|
92
|
-
assert_kind_of(Hash, @k.record["unix"][0]["var"])
|
93
|
-
assert_equal(keys, @k.record["unix"][0]["var"].keys.sort)
|
94
|
-
end
|
95
|
-
|
96
|
-
def test_record_raw_flushmeter
|
97
|
-
keys = %w/f_ctx f_page f_partial f_region f_segment f_usr/
|
98
|
-
|
99
|
-
assert_nothing_raised{ @k.record["unix"][0]["flushmeter"] }
|
100
|
-
assert_kind_of(Hash, @k.record["unix"][0]["flushmeter"])
|
101
|
-
assert_equal(keys, @k.record["unix"][0]["flushmeter"].keys.sort)
|
102
|
-
end
|
103
|
-
|
104
|
-
def test_record_raw_cpu_stat
|
105
|
-
keys = %w/cpu_idle cpu_user cpu_kernel cpu_wait wait_io wait_swap/
|
106
|
-
keys << %w/wait_pio bread bwrite lread lwrite phread phwrite pswitch/
|
107
|
-
keys << %w/trap intr syscall sysread syswrite sysfork sysvfork sysexec/
|
108
|
-
keys << %w/readch writech rcvint xmtint mdmint rawch canch outch msg/
|
109
|
-
keys << %w/sema namei ufsiget ufsdirblk ufsipage ufsinopage inodeovf/
|
110
|
-
keys << %w/fileovf procovf intrthread intrblk idlethread inv_swtch/
|
111
|
-
keys << %w/nthreads cpumigrate xcalls mutex_adenters rw_rdfails/
|
112
|
-
keys << %w/rw_wrfails modload modunload bawrite/
|
113
|
-
keys.flatten!
|
114
|
-
|
115
|
-
assert_nothing_raised{ @k.record["cpu_stat"][0]["cpu_stat0"] }
|
116
|
-
assert_kind_of(Hash, @k.record["cpu_stat"][0]["cpu_stat0"])
|
117
|
-
|
118
|
-
# Too big and difficult to sort manually - so use a Set
|
119
|
-
set1 = Set.new(keys)
|
120
|
-
set2 = Set.new(@k.record["cpu_stat"][0]["cpu_stat0"].keys)
|
121
|
-
diff = set1 - set2
|
122
|
-
|
123
|
-
assert_equal(set1,set2,"Diff was: #{diff.to_a}")
|
124
|
-
end
|
125
|
-
|
126
|
-
def test_record_ncstats
|
127
|
-
keys = %w/dbl_enters enters hits long_enter long_look misses/
|
128
|
-
keys.push %w/move_to_front purges/
|
129
|
-
keys.flatten!
|
130
|
-
|
131
|
-
assert_nothing_raised{ @k.record["unix"][0]["ncstats"] }
|
132
|
-
assert_kind_of(Hash, @k.record["unix"][0]["ncstats"])
|
133
|
-
assert_equal(keys, @k.record["unix"][0]["ncstats"].keys.sort)
|
134
|
-
end
|
135
|
-
|
136
|
-
def test_record_sysinfo
|
137
|
-
keys = %w/runocc runque swpocc swpque updates waiting/
|
138
|
-
|
139
|
-
assert_nothing_raised{ @k.record["unix"][0]["sysinfo"] }
|
140
|
-
assert_kind_of(Hash, @k.record["unix"][0]["sysinfo"])
|
141
|
-
assert_equal(keys, @k.record["unix"][0]["sysinfo"].keys.sort)
|
142
|
-
end
|
143
|
-
|
144
|
-
def teardown
|
145
|
-
@k = nil
|
146
|
-
end
|
147
|
-
end
|