sigar 0.7.2 → 0.7.3

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.
@@ -1,35 +0,0 @@
1
- #
2
- # Copyright (c) 2007, 2009 Hyperic, Inc.
3
- # Copyright (c) 2010 VMware, Inc.
4
- #
5
- # Licensed under the Apache License, Version 2.0 (the "License");
6
- # you may not use this file except in compliance with the License.
7
- # You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing, software
12
- # distributed under the License is distributed on an "AS IS" BASIS,
13
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- # See the License for the specific language governing permissions and
15
- # limitations under the License.
16
- #
17
-
18
- require 'sigar'
19
-
20
- def output(sigar, pid)
21
- args = sigar.proc_args(pid)
22
- exe = sigar.proc_exe(pid);
23
- puts "exe=" + exe.name
24
- puts "cwd=" + exe.cwd
25
-
26
- args.each do |arg|
27
- puts " " + "=>" + arg + "<="
28
- end
29
- end
30
-
31
- sigar = Sigar.new
32
-
33
- ARGV.each do |pid|
34
- output(sigar, pid)
35
- end
@@ -1,31 +0,0 @@
1
- #
2
- # Copyright (c) 2007, 2009 Hyperic, Inc.
3
- # Copyright (c) 2010 VMware, Inc.
4
- #
5
- # Licensed under the Apache License, Version 2.0 (the "License");
6
- # you may not use this file except in compliance with the License.
7
- # You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing, software
12
- # distributed under the License is distributed on an "AS IS" BASIS,
13
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- # See the License for the specific language governing permissions and
15
- # limitations under the License.
16
- #
17
-
18
- require 'sigar'
19
-
20
- def output(sigar, pid)
21
- env = sigar.proc_env(pid)
22
- env.each do |key, val|
23
- puts key + "=" + val
24
- end
25
- end
26
-
27
- sigar = Sigar.new
28
-
29
- ARGV.each do |pid|
30
- output(sigar, pid)
31
- end
@@ -1,48 +0,0 @@
1
- #
2
- # Copyright (c) 2009 SpringSource, Inc.
3
- # Copyright (c) 2010 VMware, Inc.
4
- #
5
- # Licensed under the Apache License, Version 2.0 (the "License");
6
- # you may not use this file except in compliance with the License.
7
- # You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing, software
12
- # distributed under the License is distributed on an "AS IS" BASIS,
13
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- # See the License for the specific language governing permissions and
15
- # limitations under the License.
16
- #
17
-
18
- require 'sigar'
19
-
20
- def flags(flags)
21
- f = ""
22
- if (flags & Sigar::RTF_UP) != 0
23
- f += "U"
24
- end
25
- if (flags & Sigar::RTF_GATEWAY) != 0
26
- f += "G"
27
- end
28
- if (flags & Sigar::RTF_HOST) != 0
29
- f += "H"
30
- end
31
- f
32
- end
33
-
34
- def gw(addr)
35
- addr == "0.0.0.0" ? "*" : addr
36
- end
37
- def dest(addr)
38
- addr == "0.0.0.0" ? "default" : addr
39
- end
40
-
41
- puts "Kernel IP routing table"
42
- fmt = "%-15s %-15s %-15s %-5s %-6s %-3s %-s\n"
43
- printf fmt, "Destination", "Gateway", "Genmask", "Flags", "Metric", "Ref", "Iface"
44
-
45
- Sigar.new.net_route_list.each do |route|
46
- printf fmt, dest(route.destination), gw(route.gateway), route.mask,
47
- flags(route.flags), route.metric.to_s, route.refcnt.to_s, route.ifname
48
- end
@@ -1,40 +0,0 @@
1
- #
2
- # Copyright (c) 2009 SpringSource, Inc.
3
- # Copyright (c) 2010 VMware, Inc.
4
- #
5
- # Licensed under the Apache License, Version 2.0 (the "License");
6
- # you may not use this file except in compliance with the License.
7
- # You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing, software
12
- # distributed under the License is distributed on an "AS IS" BASIS,
13
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- # See the License for the specific language governing permissions and
15
- # limitations under the License.
16
- #
17
-
18
- require 'sigar'
19
- require 'rbconfig'
20
-
21
- puts "Sigar version......." + Sigar::VERSION
22
- puts "Build date.........." + Sigar::BUILD_DATE
23
- puts "SCM rev............." + Sigar::SCM_REVISION
24
-
25
- sys = Sigar.new.sys_info
26
- puts "OS description......" + sys.description
27
- puts "OS name............." + sys.name
28
- puts "OS arch............." + sys.arch
29
- puts "OS machine.........." + sys.machine
30
- puts "OS version.........." + sys.version
31
- puts "OS patch level......" + sys.patch_level
32
- puts "OS vendor..........." + sys.vendor
33
- puts "OS vendor version..." + sys.vendor_version
34
- if (sys.vendor_code_name != nil)
35
- puts "OS code name........" + sys.vendor_code_name
36
- end
37
-
38
- puts "Ruby version........" + RUBY_VERSION
39
- puts "Ruby build vendor..." + ::Config::CONFIG['build_vendor']
40
- puts "Ruby archdir........" + ::Config::CONFIG['archdir']
@@ -1,30 +0,0 @@
1
- #
2
- # Copyright (c) 2007 Hyperic, Inc.
3
- # Copyright (c) 2010 VMware, Inc.
4
- #
5
- # Licensed under the Apache License, Version 2.0 (the "License");
6
- # you may not use this file except in compliance with the License.
7
- # You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing, software
12
- # distributed under the License is distributed on an "AS IS" BASIS,
13
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- # See the License for the specific language governing permissions and
15
- # limitations under the License.
16
- #
17
-
18
- require 'sigar'
19
-
20
- def format_time(who)
21
- return Time.at(who.time).strftime("%b %e %H:%M")
22
- end
23
-
24
- sigar = Sigar.new
25
-
26
- whos = sigar.who_list
27
-
28
- whos.each do |who|
29
- puts who.user + "\t" + who.device + "\t" + format_time(who) + who.host
30
- end
@@ -1,40 +0,0 @@
1
- #
2
- # Copyright (c) 2009 VMware, Inc.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- #
16
-
17
- $LOAD_PATH.unshift File.dirname(__FILE__)
18
- require 'helper'
19
-
20
- class CpuTest < Test::Unit::TestCase
21
- def check_cpu(cpu)
22
- assert_gt_eq_zero cpu.user, "user"
23
- assert_gt_eq_zero cpu.sys, "sys"
24
- assert_gt_eq_zero cpu.idle, "idle"
25
- assert_gt_eq_zero cpu.wait, "wait"
26
- assert_gt_eq_zero cpu.irq, "irq"
27
- assert_gt_eq_zero cpu.soft_irq, "soft_irq"
28
- assert_gt_eq_zero cpu.stolen, "stolen"
29
- assert_gt_zero cpu.total, "total"
30
- end
31
-
32
- def test_cpu
33
- sigar = Sigar.new
34
- check_cpu sigar.cpu
35
-
36
- sigar.cpu_list.each do |cpu|
37
- check_cpu cpu
38
- end
39
- end
40
- end
@@ -1,43 +0,0 @@
1
- #
2
- # Copyright (c) 2009 VMware, Inc.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- #
16
-
17
- $LOAD_PATH.unshift File.dirname(__FILE__)
18
- require 'helper'
19
-
20
- class FileSystemTest < Test::Unit::TestCase
21
-
22
- def test_file_system
23
- sigar = Sigar.new
24
- sigar.file_system_list.each do |fs|
25
- assert_length fs.dev_name, "dev_name"
26
- assert_length fs.dir_name, "dir_name"
27
- assert_length fs.type_name, "type_name"
28
- assert_length fs.sys_type_name, "sys_type_name"
29
- assert fs.options.length >= 0, "options"
30
-
31
- begin
32
- usage = sigar.file_system_usage fs.dir_name
33
- rescue => err
34
- if fs.type == Sigar::FSTYPE_LOCAL_DISK
35
- raise err
36
- end
37
- # else ok, e.g. floppy drive on windows
38
- next
39
- end
40
- end
41
- end
42
-
43
- end
@@ -1,57 +0,0 @@
1
- #
2
- # Copyright (c) 2009-2010 VMware, Inc.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- #
16
-
17
- require 'test/unit'
18
- require 'sigar'
19
-
20
- module Test::Unit::Assertions
21
- def assert_gt_eq_zero(value, message)
22
- message = build_message message, '<?> is not >= 0.', value
23
- assert_block message do
24
- value >= 0
25
- end
26
- end
27
-
28
- def assert_gt_zero(value, message)
29
- message = build_message message, '<?> is not > 0.', value
30
- assert_block message do
31
- value > 0
32
- end
33
- end
34
-
35
- def assert_eq(expected, actual, message)
36
- message = build_message message, '<?> != <?>.', expected, actual
37
- assert_block message do
38
- expected == actual
39
- end
40
- end
41
-
42
- def assert_length(value, message)
43
- message = build_message message, '<?>.length > 0.', value
44
- assert_block message do
45
- value.length > 0
46
- end
47
- end
48
-
49
- def assert_any(value, message)
50
- message = build_message message, '<?> is anything.', value
51
- assert_block message do
52
- true
53
- end
54
- end
55
-
56
- end
57
-
@@ -1,30 +0,0 @@
1
- #
2
- # Copyright (c) 2009 VMware, Inc.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- #
16
-
17
- $LOAD_PATH.unshift File.dirname(__FILE__)
18
- require 'helper'
19
-
20
- class LoadAvgTest < Test::Unit::TestCase
21
-
22
- def test_loadavg
23
- begin
24
- loadavg = Sigar.new.loadavg
25
- rescue #XXX SigarNotImplemented (win32)
26
- return
27
- end
28
- assert loadavg.length == 3
29
- end
30
- end
@@ -1,45 +0,0 @@
1
- #
2
- # Copyright (c) 2009 VMware, Inc.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- #
16
-
17
- $LOAD_PATH.unshift File.dirname(__FILE__)
18
- require 'helper'
19
-
20
- class MemTest < Test::Unit::TestCase
21
-
22
- def test_mem
23
- sigar = Sigar.new
24
- mem = sigar.mem
25
- assert_gt_zero mem.total, "total"
26
- assert_gt_zero mem.used, "used"
27
-
28
- assert_gt_zero mem.used_percent, "used_percent"
29
- assert mem.used_percent <= 100, "used_percent <= 100"
30
-
31
- assert_gt_eq_zero mem.free_percent, "free_percent"
32
- assert mem.free_percent < 100, "free_percent < 100"
33
-
34
- assert_gt_zero mem.free, "free"
35
-
36
- assert_gt_zero mem.actual_used, "actual_used"
37
-
38
- assert_gt_zero mem.actual_free, "actual_free"
39
-
40
- assert_gt_zero mem.ram, "ram"
41
-
42
- assert (mem.ram % 8) == 0
43
- end
44
-
45
- end
@@ -1,36 +0,0 @@
1
- #
2
- # Copyright (c) 2009-2010 VMware, Inc.
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
- #
16
-
17
- $LOAD_PATH.unshift File.dirname(__FILE__)
18
- require 'helper'
19
-
20
- class SwapTest < Test::Unit::TestCase
21
-
22
- def test_swap
23
- sigar = Sigar.new
24
- swap = sigar.swap
25
-
26
- assert_gt_eq_zero swap.total, "total"
27
- assert_gt_eq_zero swap.used, "used"
28
- assert_gt_eq_zero swap.free, "free"
29
-
30
- assert_eq swap.total - swap.used, swap.free, "total-used==free"
31
-
32
- assert_any swap.page_in, "page_in"
33
- assert_any swap.page_out, "page_out"
34
- end
35
-
36
- end