ohai 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (139) hide show
  1. data/LICENSE +201 -0
  2. data/README.rdoc +98 -0
  3. data/Rakefile +61 -0
  4. data/bin/ohai +24 -0
  5. data/lib/ohai.rb +27 -0
  6. data/lib/ohai/application.rb +113 -0
  7. data/lib/ohai/config.rb +29 -0
  8. data/lib/ohai/exception.rb +23 -0
  9. data/lib/ohai/log.rb +26 -0
  10. data/lib/ohai/mixin/command.rb +208 -0
  11. data/lib/ohai/mixin/from_file.rb +36 -0
  12. data/lib/ohai/mixin/string.rb +29 -0
  13. data/lib/ohai/plugins/command.rb +21 -0
  14. data/lib/ohai/plugins/darwin/filesystem.rb +57 -0
  15. data/lib/ohai/plugins/darwin/hostname.rb +22 -0
  16. data/lib/ohai/plugins/darwin/kernel.rb +37 -0
  17. data/lib/ohai/plugins/darwin/network.rb +187 -0
  18. data/lib/ohai/plugins/darwin/platform.rb +36 -0
  19. data/lib/ohai/plugins/darwin/ps.rb +23 -0
  20. data/lib/ohai/plugins/darwin/ssh_host_key.rb +25 -0
  21. data/lib/ohai/plugins/darwin/system_profiler.rb +33 -0
  22. data/lib/ohai/plugins/darwin/uptime.rb +32 -0
  23. data/lib/ohai/plugins/dmi.rb +59 -0
  24. data/lib/ohai/plugins/ec2.rb +100 -0
  25. data/lib/ohai/plugins/erlang.rb +40 -0
  26. data/lib/ohai/plugins/freebsd/cpu.rb +52 -0
  27. data/lib/ohai/plugins/freebsd/filesystem.rb +57 -0
  28. data/lib/ohai/plugins/freebsd/hostname.rb +22 -0
  29. data/lib/ohai/plugins/freebsd/kernel.rb +37 -0
  30. data/lib/ohai/plugins/freebsd/memory.rb +50 -0
  31. data/lib/ohai/plugins/freebsd/network.rb +112 -0
  32. data/lib/ohai/plugins/freebsd/platform.rb +23 -0
  33. data/lib/ohai/plugins/freebsd/ps.rb +24 -0
  34. data/lib/ohai/plugins/freebsd/ssh_host_key.rb +26 -0
  35. data/lib/ohai/plugins/freebsd/uptime.rb +32 -0
  36. data/lib/ohai/plugins/freebsd/virtualization.rb +66 -0
  37. data/lib/ohai/plugins/hostname.rb +27 -0
  38. data/lib/ohai/plugins/java.rb +36 -0
  39. data/lib/ohai/plugins/kernel.rb +33 -0
  40. data/lib/ohai/plugins/keys.rb +22 -0
  41. data/lib/ohai/plugins/languages.rb +21 -0
  42. data/lib/ohai/plugins/linux/block_device.rb +38 -0
  43. data/lib/ohai/plugins/linux/cpu.rb +60 -0
  44. data/lib/ohai/plugins/linux/filesystem.rb +57 -0
  45. data/lib/ohai/plugins/linux/hostname.rb +26 -0
  46. data/lib/ohai/plugins/linux/kernel.rb +33 -0
  47. data/lib/ohai/plugins/linux/lsb.rb +38 -0
  48. data/lib/ohai/plugins/linux/memory.rb +83 -0
  49. data/lib/ohai/plugins/linux/network.rb +112 -0
  50. data/lib/ohai/plugins/linux/platform.rb +43 -0
  51. data/lib/ohai/plugins/linux/ps.rb +23 -0
  52. data/lib/ohai/plugins/linux/ssh_host_key.rb +26 -0
  53. data/lib/ohai/plugins/linux/uptime.rb +28 -0
  54. data/lib/ohai/plugins/linux/virtualization.rb +77 -0
  55. data/lib/ohai/plugins/netbsd/cpu.rb +48 -0
  56. data/lib/ohai/plugins/netbsd/filesystem.rb +57 -0
  57. data/lib/ohai/plugins/netbsd/hostname.rb +22 -0
  58. data/lib/ohai/plugins/netbsd/kernel.rb +35 -0
  59. data/lib/ohai/plugins/netbsd/memory.rb +98 -0
  60. data/lib/ohai/plugins/netbsd/network.rb +111 -0
  61. data/lib/ohai/plugins/netbsd/platform.rb +22 -0
  62. data/lib/ohai/plugins/netbsd/ps.rb +24 -0
  63. data/lib/ohai/plugins/netbsd/ssh_host_key.rb +26 -0
  64. data/lib/ohai/plugins/netbsd/uptime.rb +31 -0
  65. data/lib/ohai/plugins/netbsd/virtualization.rb +65 -0
  66. data/lib/ohai/plugins/network.rb +52 -0
  67. data/lib/ohai/plugins/ohai_time.rb +21 -0
  68. data/lib/ohai/plugins/openbsd/cpu.rb +38 -0
  69. data/lib/ohai/plugins/openbsd/filesystem.rb +57 -0
  70. data/lib/ohai/plugins/openbsd/hostname.rb +22 -0
  71. data/lib/ohai/plugins/openbsd/kernel.rb +35 -0
  72. data/lib/ohai/plugins/openbsd/memory.rb +98 -0
  73. data/lib/ohai/plugins/openbsd/network.rb +111 -0
  74. data/lib/ohai/plugins/openbsd/platform.rb +23 -0
  75. data/lib/ohai/plugins/openbsd/ps.rb +24 -0
  76. data/lib/ohai/plugins/openbsd/ssh_host_key.rb +26 -0
  77. data/lib/ohai/plugins/openbsd/uptime.rb +32 -0
  78. data/lib/ohai/plugins/openbsd/virtualization.rb +66 -0
  79. data/lib/ohai/plugins/os.rb +48 -0
  80. data/lib/ohai/plugins/perl.rb +37 -0
  81. data/lib/ohai/plugins/platform.rb +25 -0
  82. data/lib/ohai/plugins/python.rb +37 -0
  83. data/lib/ohai/plugins/ruby.rb +39 -0
  84. data/lib/ohai/plugins/solaris2/cpu.rb +33 -0
  85. data/lib/ohai/plugins/solaris2/hostname.rb +25 -0
  86. data/lib/ohai/plugins/solaris2/kernel.rb +40 -0
  87. data/lib/ohai/plugins/solaris2/network.rb +141 -0
  88. data/lib/ohai/plugins/solaris2/platform.rb +33 -0
  89. data/lib/ohai/plugins/solaris2/ps.rb +23 -0
  90. data/lib/ohai/plugins/solaris2/ssh_host_key.rb +26 -0
  91. data/lib/ohai/plugins/uptime.rb +42 -0
  92. data/lib/ohai/plugins/virtualization.rb +86 -0
  93. data/lib/ohai/plugins/windows/filesystem.rb +44 -0
  94. data/lib/ohai/plugins/windows/hostname.rb +25 -0
  95. data/lib/ohai/plugins/windows/kernel.rb +75 -0
  96. data/lib/ohai/plugins/windows/network.rb +114 -0
  97. data/lib/ohai/plugins/windows/platform.rb +26 -0
  98. data/lib/ohai/system.rb +241 -0
  99. data/spec/ohai/mixin/command_spec.rb +37 -0
  100. data/spec/ohai/mixin/from_file_spec.rb +53 -0
  101. data/spec/ohai/plugins/darwin/hostname_spec.rb +34 -0
  102. data/spec/ohai/plugins/darwin/kernel_spec.rb +46 -0
  103. data/spec/ohai/plugins/darwin/platform_spec.rb +67 -0
  104. data/spec/ohai/plugins/dmi_spec.rb +73 -0
  105. data/spec/ohai/plugins/ec2_spec.rb +81 -0
  106. data/spec/ohai/plugins/erlang_spec.rb +63 -0
  107. data/spec/ohai/plugins/freebsd/hostname_spec.rb +34 -0
  108. data/spec/ohai/plugins/freebsd/kernel_spec.rb +37 -0
  109. data/spec/ohai/plugins/freebsd/platform_spec.rb +40 -0
  110. data/spec/ohai/plugins/hostname_spec.rb +39 -0
  111. data/spec/ohai/plugins/java_spec.rb +70 -0
  112. data/spec/ohai/plugins/kernel_spec.rb +43 -0
  113. data/spec/ohai/plugins/linux/cpu_spec.rb +128 -0
  114. data/spec/ohai/plugins/linux/hostname_spec.rb +52 -0
  115. data/spec/ohai/plugins/linux/kernel_spec.rb +31 -0
  116. data/spec/ohai/plugins/linux/lsb_spec.rb +60 -0
  117. data/spec/ohai/plugins/linux/platform_spec.rb +81 -0
  118. data/spec/ohai/plugins/linux/uptime_spec.rb +61 -0
  119. data/spec/ohai/plugins/linux/virtualization_spec.rb +131 -0
  120. data/spec/ohai/plugins/netbsd/hostname_spec.rb +34 -0
  121. data/spec/ohai/plugins/netbsd/kernel_spec.rb +36 -0
  122. data/spec/ohai/plugins/netbsd/platform_spec.rb +40 -0
  123. data/spec/ohai/plugins/ohai_time_spec.rb +46 -0
  124. data/spec/ohai/plugins/openbsd/hostname_spec.rb +34 -0
  125. data/spec/ohai/plugins/openbsd/kernel_spec.rb +37 -0
  126. data/spec/ohai/plugins/openbsd/platform_spec.rb +40 -0
  127. data/spec/ohai/plugins/os_spec.rb +69 -0
  128. data/spec/ohai/plugins/perl_spec.rb +89 -0
  129. data/spec/ohai/plugins/platform_spec.rb +56 -0
  130. data/spec/ohai/plugins/python_spec.rb +53 -0
  131. data/spec/ohai/plugins/ruby_spec.rb +51 -0
  132. data/spec/ohai/plugins/solaris2/hostname_spec.rb +43 -0
  133. data/spec/ohai/plugins/solaris2/kernel_spec.rb +164 -0
  134. data/spec/ohai/system_spec.rb +130 -0
  135. data/spec/ohai_spec.rb +27 -0
  136. data/spec/rcov.opts +2 -0
  137. data/spec/spec.opts +2 -0
  138. data/spec/spec_helper.rb +68 -0
  139. metadata +240 -0
@@ -0,0 +1,57 @@
1
+ #
2
+ # Author:: Adam Jacob (<adam@opscode.com>)
3
+ # Copyright:: Copyright (c) 2008 Opscode, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ provides "filesystem"
20
+
21
+ fs = Mash.new
22
+
23
+ # Grab filesystem data from df
24
+ popen4("df") do |pid, stdin, stdout, stderr|
25
+ stdin.close
26
+ stdout.each do |line|
27
+ case line
28
+ when /^Filesystem/
29
+ next
30
+ when /^(.+?)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+\%)\s+(.+)$/
31
+ filesystem = $1
32
+ fs[filesystem] = Mash.new
33
+ fs[filesystem]['kb_size'] = $2
34
+ fs[filesystem]['kb_used'] = $3
35
+ fs[filesystem]['kb_available'] = $4
36
+ fs[filesystem]['percent_used'] = $5
37
+ fs[filesystem]['mount'] = $6
38
+ end
39
+ end
40
+ end
41
+
42
+ # Grab mount information from mount
43
+ popen4("mount -l") do |pid, stdin, stdout, stderr|
44
+ stdin.close
45
+ stdout.each do |line|
46
+ if line =~ /^(.+?) on (.+?) \((.+?), (.+?)\)$/
47
+ filesystem = $1
48
+ fs[filesystem] = Mash.new unless fs.has_key?(filesystem)
49
+ fs[filesystem]['mount'] = $2
50
+ fs[filesystem]['fs_type'] = $3
51
+ fs[filesystem]['mount-options'] = $4.split(/,\s*/)
52
+ end
53
+ end
54
+ end
55
+
56
+ # Set the filesystem data
57
+ filesystem fs
@@ -0,0 +1,22 @@
1
+ #
2
+ # Author:: Bryan McLellan (btm@loftninjas.org)
3
+ # Copyright:: Copyright (c) 2009 Bryan McLellan
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ provides "hostname", "fqdn"
20
+
21
+ hostname from("hostname -s")
22
+ fqdn from("hostname")
@@ -0,0 +1,35 @@
1
+ #
2
+ # Author:: Bryan McLellan (btm@loftninjas.org)
3
+ # Copyright:: Copyright (c) 2009 Bryan McLellan
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ provides "kernel"
20
+
21
+ kernel[:os] = kernel[:name]
22
+ kernel[:securelevel] = from_with_regex("sysctl kern.securelevel", /kern.securelevel=(.+)$/)
23
+
24
+ mod = Mash.new
25
+ popen4("/usr/bin/modstat") do |pid, stdin, stdout, stderr|
26
+ stdin.close
27
+ stdout.each do |line|
28
+ # 1 7 0xc0400000 97f830 kernel
29
+ if line =~ /(\d+)\s+(\d+)\s+([0-9a-fx]+)\s+([0-9a-fx]+)\s+([a-zA-Z0-9\_]+)/
30
+ kld[$5] = { :size => $4, :refcount => $2 }
31
+ end
32
+ end
33
+ end
34
+
35
+ kernel[:modules] = mod unless mod.empty?
@@ -0,0 +1,98 @@
1
+ #
2
+ # Author:: Mathieu Sauve-Frankel <msf@kisoku.net>
3
+ # Copyright:: Copyright (c) 2009 Bryan McLellan
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ provides "memory"
20
+
21
+ memory Mash.new
22
+ memory[:swap] = Mash.new
23
+
24
+ # $ vmstat -s
25
+ # 4096 bytes per page
26
+ # 514011 pages managed
27
+ # 224519 pages free
28
+ # 209339 pages active
29
+ # 4647 pages inactive
30
+ # 0 pages being paged out
31
+ # 5 pages wired
32
+ # 0 pages zeroed
33
+ # 4 pages reserved for pagedaemon
34
+ # 6 pages reserved for kernel
35
+ # 262205 swap pages
36
+ # 0 swap pages in use
37
+ # 0 total anon's in system
38
+ # 0 free anon's
39
+ # 1192991609 page faults
40
+ # 1369579301 traps
41
+ # 814549706 interrupts
42
+ # 771702498 cpu context switches
43
+ # 208810590 fpu context switches
44
+ # 492361360 software interrupts
45
+ # 1161998825 syscalls
46
+ # 0 pagein operations
47
+ # 0 swap ins
48
+ # 0 swap outs
49
+ # 768352 forks
50
+ # 16 forks where vmspace is shared
51
+ # 1763 kernel map entries
52
+ # 0 number of times the pagedaemon woke up
53
+ # 0 revolutions of the clock hand
54
+ # 0 pages freed by pagedaemon
55
+ # 0 pages scanned by pagedaemon
56
+ # 0 pages reactivated by pagedaemon
57
+ # 0 busy pages found by pagedaemon
58
+ # 1096393776 total name lookups
59
+ # cache hits (37% pos + 2% neg) system 1% per-directory
60
+ # deletions 0%, falsehits 6%, toolong 26%
61
+ # 0 select collisions
62
+
63
+ popen4("vmstat -s") do |pid, stdin, stdout, stderr|
64
+ stdin.close
65
+ stdout.each do |line|
66
+ case line
67
+ when /(\d+) bytes per page/
68
+ memory[:page_size] = $1
69
+ when /(\d+) pages managed/
70
+ memory[:page_count] = $1
71
+ memory[:total] = memory[:page_size].to_i * memory[:page_count].to_i
72
+ when /(\d+) pages free/
73
+ memory[:free] = memory[:page_size].to_i * $1.to_i
74
+ when /(\d+) pages active/
75
+ memory[:active] = memory[:page_size].to_i * $1.to_i
76
+ when /(\d+) pages inactive/
77
+ memory[:inactive] = memory[:page_size].to_i * $1.to_i
78
+ when /(\d+) pages wired/
79
+ memory[:wired] = memory[:page_size].to_i * $1.to_i
80
+ end
81
+ end
82
+ end
83
+
84
+ popen4("swapctl -l") do |pid, stdin, stdout, stderr|
85
+ stdin.close
86
+ stdout.each do |line|
87
+ # Device 1024-blocks Used Avail Capacity Priority
88
+ # swap_device 1048824 0 1048824 0% 0
89
+ if line =~ /^([\d\w\/]+)\s+(\d+)\s+(\d+)\s+(\d+)\s+([\d\%]+)/
90
+ mdev = $1
91
+ memory[:swap][mdev] = Mash.new
92
+ memory[:swap][mdev][:total] = $2
93
+ memory[:swap][mdev][:used] = $3
94
+ memory[:swap][mdev][:free] = $4
95
+ memory[:swap][mdev][:percent_free] = $5
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,111 @@
1
+ #
2
+ # Author:: Bryan McLellan (btm@loftninjas.org)
3
+ # Copyright:: Copyright (c) 2009 Bryan McLellan
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ provides "network", "counters/network"
20
+
21
+ network[:default_interface] = from("route -n get default \| grep interface: \| awk \'/: / \{print \$2\}\'")
22
+
23
+ iface = Mash.new
24
+ popen4("/sbin/ifconfig -a") do |pid, stdin, stdout, stderr|
25
+ stdin.close
26
+ cint = nil
27
+ stdout.each do |line|
28
+ if line =~ /^([0-9a-zA-Z\.]+):\s+/
29
+ cint = $1
30
+ iface[cint] = Mash.new
31
+ if cint =~ /^(\w+)(\d+.*)/
32
+ iface[cint][:type] = $1
33
+ iface[cint][:number] = $2
34
+ end
35
+ end
36
+ # call the family lladdr to match linux for consistency
37
+ if line =~ /\s+address: (.+?)\s/
38
+ iface[cint][:addresses] = Mash.new unless iface[cint][:addresses]
39
+ iface[cint][:addresses][$1] = { "family" => "lladdr" }
40
+ end
41
+ if line =~ /\s+inet ([\d.]+) netmask ([\da-fx]+)\s*\w*\s*([\d.]*)/
42
+ iface[cint][:addresses] = Mash.new unless iface[cint][:addresses]
43
+ # convert the netmask to decimal for consistency
44
+ netmask = "#{$2[2,2].hex}.#{$2[4,2].hex}.#{$2[6,2].hex}.#{$2[8,2].hex}"
45
+ if $3.empty?
46
+ iface[cint][:addresses][$1] = { "family" => "inet", "netmask" => netmask }
47
+ else
48
+ # found a broadcast address
49
+ iface[cint][:addresses][$1] = { "family" => "inet", "netmask" => netmask, "broadcast" => $3 }
50
+ end
51
+ end
52
+ if line =~ /\s+inet6 ([a-f0-9\:]+)%?(\w*)\s+prefixlen\s+(\d+)\s*\w*\s*([\da-fx]*)/
53
+ iface[cint][:addresses] = Mash.new unless iface[cint][:addresses]
54
+ if $4.empty?
55
+ iface[cint][:addresses][$1] = { "family" => "inet6", "prefixlen" => $3 }
56
+ else
57
+ #found a zone_id / scope
58
+ iface[cint][:addresses][$1] = { "family" => "inet6", "zoneid" => $2, "prefixlen" => $3, "scopeid" => $4 }
59
+ end
60
+ end
61
+ if line =~ /flags=\d+<(.+)>/
62
+ flags = $1.split(',')
63
+ iface[cint][:flags] = flags if flags.length > 0
64
+ end
65
+ if line =~ /metric: (\d+) mtu: (\d+)/
66
+ iface[cint][:metric] = $1
67
+ iface[cint][:mtu] = $2
68
+ end
69
+ end
70
+ end
71
+
72
+ popen4("arp -an") do |pid, stdin, stdout, stderr|
73
+ stdin.close
74
+ stdout.each do |line|
75
+ if line =~ /\((\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\) at ([a-fA-F0-9\:]+) on ([0-9a-zA-Z\.\:\-]+)/
76
+ next unless iface[$3] # this should never happen
77
+ iface[$3][:arp] = Mash.new unless iface[$3][:arp]
78
+ iface[$3][:arp][$1] = $2.downcase
79
+ end
80
+ end
81
+ end
82
+
83
+ network["interfaces"] = iface
84
+
85
+ net_counters = Mash.new
86
+ # From netstat(1), not sure of the implications:
87
+ # Show the state of all network interfaces or a single interface
88
+ # which have been auto-configured (interfaces statically configured
89
+ # into a system, but not located at boot time are not shown).
90
+ popen4("netstat -idn") do |pid, stdin, stdout, stderr|
91
+ stdin.close
92
+ stdout.each do |line|
93
+ # Name Mtu Network Address Ipkts Ierrs Opkts Oerrs Coll Drop
94
+ # em0 1500 <Link> 00:11:25:2d:90:be 3719557 0 3369969 0 0 0
95
+ # $1 $2 $3 $4 $5 $6 $7 $8
96
+ if line =~ /^([\w\.\*]+)\s+\d+\s+<Link>\s+([\w:]*)\s*(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/
97
+ cint = $1
98
+ net_counters[cint] = Mash.new unless net_counters[cint]
99
+ net_counters[cint] = Mash.new unless net_counters[cint]["rx"]
100
+ net_counters[cint] = Mash.new unless net_counters[cint]["tx"]
101
+ net_counters[cint] = $3
102
+ net_counters[cint] = $4
103
+ net_counters[cint] = $5
104
+ net_counters[cint] = $6
105
+ net_counters[cint] = $7
106
+ net_counters[cint] = $8
107
+ end
108
+ end
109
+ end
110
+
111
+ counters[:network][:interfaces] = net_counters
@@ -0,0 +1,22 @@
1
+ #
2
+ # Author:: Bryan McLellan (btm@loftninjas.org)
3
+ # Copyright:: Copyright (c) 2009 Bryan McLellan
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ provides "platform", "platform_version"
20
+
21
+ platform from("uname -s").downcase
22
+ platform_version from("uname -r")
@@ -0,0 +1,24 @@
1
+ #
2
+ # Author:: Bryan McLellan (btm@loftninjas.org)
3
+ # Copyright:: Copyright (c) 2009 Bryan McLellan
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ provides "command/ps"
20
+
21
+ require_plugin 'command'
22
+
23
+ # ps -e requires procfs
24
+ command[:ps] = 'ps -ax'
@@ -0,0 +1,26 @@
1
+ #
2
+ # Author:: Adam Jacob (<adam@opscode.com>)
3
+ # Copyright:: Copyright (c) 2008 Opscode, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ provides "keys/ssh"
20
+
21
+ require_plugin "keys"
22
+
23
+ keys[:ssh] = Mash.new
24
+
25
+ keys[:ssh][:host_dsa_public] = IO.read("/etc/ssh/ssh_host_dsa_key.pub").split[1]
26
+ keys[:ssh][:host_rsa_public] = IO.read("/etc/ssh/ssh_host_rsa_key.pub").split[1]
@@ -0,0 +1,31 @@
1
+ #
2
+ # Author:: Bryan McLellan (btm@loftninjas.org)
3
+ # Copyright:: Copyright (c) 2009 Bryan McLellan
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ provides "uptime", "uptime_seconds"
20
+
21
+ # kern.boottime: { sec = 1232765114, usec = 823118 } Fri Jan 23 18:45:14 2009
22
+
23
+ popen4("/sbin/sysctl kern.boottime") do |pid, stdin, stdout, stderr|
24
+ stdin.close
25
+ stdout.each do |line|
26
+ if line =~ /kern.boottime:\D+(\d+)/
27
+ uptime_seconds Time.new.to_i - $1.to_i
28
+ uptime self._seconds_to_human(uptime_seconds)
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,65 @@
1
+ #
2
+ # Author:: Bryan McLellan (btm@loftninjas.org)
3
+ # Copyright:: Copyright (c) 2009 Bryan McLellan
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ provides "virtualization"
20
+
21
+ virtualization Mash.new
22
+
23
+ # KVM Host support for FreeBSD is in development
24
+ # http://feanor.sssup.it/~fabio/freebsd/lkvm/
25
+
26
+ # Detect KVM/QEMU from cpu, report as KVM
27
+ # hw.model: QEMU Virtual CPU version 0.9.1
28
+ if from("sysctl -n hw.model") =~ /QEMU Virtual CPU/
29
+ virtualization[:system] = "kvm"
30
+ virtualization[:role] = "guest"
31
+ end
32
+
33
+ # http://www.dmo.ca/blog/detecting-virtualization-on-linux
34
+ if File.exists?("/usr/pkg/sbin/dmidecode")
35
+ popen4("dmidecode") do |pid, stdin, stdout, stderr|
36
+ stdin.close
37
+ found_virt_manufacturer = nil
38
+ found_virt_product = nil
39
+ stdout.each do |line|
40
+ case line
41
+ when /Manufacturer: Microsoft/
42
+ found_virt_manufacturer = "microsoft"
43
+ when /Product Name: Virtual Machine/
44
+ found_virt_product = "microsoft"
45
+ when /Version: 5.0/
46
+ if found_virt_manufacturer == "microsoft" && found_virt_product == "microsoft"
47
+ virtualization[:system] = "virtualpc"
48
+ virtualization[:role] = "guest"
49
+ end
50
+ when /Version: VS2005R2/
51
+ if found_virt_manufacturer == "microsoft" && found_virt_product == "microsoft"
52
+ virtualization[:system] = "virtualserver"
53
+ virtualization[:role] = "guest"
54
+ end
55
+ when /Manufacturer: VMware/
56
+ found_virt_manufacturer = "vmware"
57
+ when /Product Name: VMware Virtual Platform/
58
+ if found_virt_manufacturer == "vmware"
59
+ virtualization[:system] = "vmware"
60
+ virtualization[:role] = "guest"
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end