ohai 6.24.2 → 7.0.0.rc.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ohai.rb +1 -1
- data/lib/ohai/application.rb +5 -12
- data/lib/ohai/common/dmi.rb +126 -0
- data/lib/ohai/config.rb +9 -9
- data/lib/ohai/{plugins/darwin/hostname.rb → dsl.rb} +7 -7
- data/lib/ohai/dsl/plugin.rb +186 -0
- data/lib/ohai/dsl/plugin/versionvi.rb +62 -0
- data/lib/ohai/dsl/plugin/versionvii.rb +106 -0
- data/lib/ohai/exception.rb +11 -2
- data/lib/ohai/hints.rb +48 -0
- data/lib/ohai/loader.rb +205 -0
- data/lib/ohai/mixin/command.rb +14 -18
- data/lib/ohai/mixin/constant_helper.rb +53 -0
- data/lib/ohai/mixin/gce_metadata.rb +0 -2
- data/lib/ohai/{plugins/freebsd/uptime.rb → mixin/network_constants.rb} +15 -13
- data/lib/ohai/mixin/os.rb +59 -0
- data/lib/ohai/mixin/seconds_to_human.rb +48 -0
- data/lib/ohai/plugins/aix/cpu.rb +26 -22
- data/lib/ohai/plugins/aix/filesystem.rb +47 -48
- data/lib/ohai/plugins/aix/kernel.rb +11 -7
- data/lib/ohai/plugins/aix/memory.rb +8 -4
- data/lib/ohai/plugins/aix/network.rb +73 -82
- data/lib/ohai/plugins/aix/platform.rb +9 -6
- data/lib/ohai/plugins/aix/uptime.rb +14 -12
- data/lib/ohai/plugins/azure.rb +33 -11
- data/lib/ohai/plugins/c.rb +103 -78
- data/lib/ohai/plugins/chef.rb +20 -8
- data/lib/ohai/plugins/cloud.rb +234 -230
- data/lib/ohai/plugins/command.rb +6 -2
- data/lib/ohai/plugins/darwin/cpu.rb +10 -4
- data/lib/ohai/plugins/darwin/filesystem.rb +32 -32
- data/lib/ohai/plugins/darwin/network.rb +157 -154
- data/lib/ohai/plugins/darwin/platform.rb +18 -16
- data/lib/ohai/plugins/darwin/system_profiler.rb +49 -46
- data/lib/ohai/plugins/dmi.rb +102 -102
- data/lib/ohai/plugins/ec2.rb +30 -28
- data/lib/ohai/plugins/erlang.rb +19 -16
- data/lib/ohai/plugins/eucalyptus.rb +37 -36
- data/lib/ohai/plugins/freebsd/cpu.rb +34 -29
- data/lib/ohai/plugins/freebsd/filesystem.rb +32 -32
- data/lib/ohai/plugins/freebsd/memory.rb +35 -25
- data/lib/ohai/plugins/freebsd/network.rb +94 -89
- data/lib/ohai/plugins/freebsd/platform.rb +10 -4
- data/lib/ohai/plugins/freebsd/virtualization.rb +62 -61
- data/lib/ohai/plugins/gce.rb +30 -36
- data/lib/ohai/plugins/groovy.rb +14 -11
- data/lib/ohai/plugins/hostname.rb +132 -10
- data/lib/ohai/plugins/ip_scopes.rb +31 -16
- data/lib/ohai/plugins/java.rb +45 -21
- data/lib/ohai/plugins/kernel.rb +186 -19
- data/lib/ohai/plugins/keys.rb +6 -2
- data/lib/ohai/plugins/languages.rb +6 -2
- data/lib/ohai/plugins/linode.rb +38 -30
- data/lib/ohai/plugins/linux/block_device.rb +19 -15
- data/lib/ohai/plugins/linux/cpu.rb +42 -38
- data/lib/ohai/plugins/linux/filesystem.rb +70 -130
- data/lib/ohai/plugins/linux/lsb.rb +35 -35
- data/lib/ohai/plugins/linux/memory.rb +65 -61
- data/lib/ohai/plugins/linux/network.rb +343 -362
- data/lib/ohai/plugins/linux/platform.rb +90 -88
- data/lib/ohai/plugins/linux/virtualization.rb +95 -90
- data/lib/ohai/plugins/lua.rb +14 -10
- data/lib/ohai/plugins/mono.rb +17 -13
- data/lib/ohai/plugins/netbsd/cpu.rb +25 -23
- data/lib/ohai/plugins/netbsd/filesystem.rb +32 -32
- data/lib/ohai/plugins/netbsd/memory.rb +59 -59
- data/lib/ohai/plugins/netbsd/network.rb +92 -88
- data/lib/ohai/plugins/netbsd/platform.rb +10 -3
- data/lib/ohai/plugins/netbsd/virtualization.rb +41 -38
- data/lib/ohai/plugins/network.rb +131 -130
- data/lib/ohai/plugins/network_listeners.rb +26 -22
- data/lib/ohai/plugins/nodejs.rb +14 -10
- data/lib/ohai/plugins/ohai.rb +11 -6
- data/lib/ohai/plugins/ohai_time.rb +6 -2
- data/lib/ohai/plugins/openbsd/cpu.rb +20 -15
- data/lib/ohai/plugins/openbsd/filesystem.rb +32 -32
- data/lib/ohai/plugins/openbsd/memory.rb +59 -59
- data/lib/ohai/plugins/openbsd/network.rb +92 -88
- data/lib/ohai/plugins/openbsd/platform.rb +10 -4
- data/lib/ohai/plugins/openbsd/virtualization.rb +41 -39
- data/lib/ohai/plugins/openstack.rb +23 -21
- data/lib/ohai/plugins/os.rb +8 -32
- data/lib/ohai/plugins/passwd.rb +27 -22
- data/lib/ohai/plugins/perl.rb +21 -16
- data/lib/ohai/plugins/php.rb +15 -12
- data/lib/ohai/plugins/platform.rb +9 -9
- data/lib/ohai/plugins/{linux/kernel.rb → ps.rb} +13 -12
- data/lib/ohai/plugins/python.rb +16 -12
- data/lib/ohai/plugins/rackspace.rb +82 -77
- data/lib/ohai/plugins/root_group.rb +13 -9
- data/lib/ohai/plugins/ruby.rb +50 -48
- data/lib/ohai/plugins/sigar/cpu.rb +21 -17
- data/lib/ohai/plugins/sigar/filesystem.rb +26 -23
- data/lib/ohai/plugins/sigar/memory.rb +17 -14
- data/lib/ohai/plugins/sigar/network.rb +133 -67
- data/lib/ohai/plugins/sigar/network_route.rb +33 -28
- data/lib/ohai/plugins/sigar/platform.rb +10 -6
- data/lib/ohai/plugins/solaris2/cpu.rb +41 -33
- data/lib/ohai/plugins/solaris2/dmi.rb +146 -146
- data/lib/ohai/plugins/solaris2/filesystem.rb +74 -77
- data/lib/ohai/plugins/{aix/hostname.rb → solaris2/memory.rb} +7 -4
- data/lib/ohai/plugins/solaris2/network.rb +91 -86
- data/lib/ohai/plugins/solaris2/platform.rb +40 -36
- data/lib/ohai/plugins/solaris2/virtualization.rb +54 -59
- data/lib/ohai/plugins/solaris2/zpools.rb +38 -38
- data/lib/ohai/plugins/ssh_host_key.rb +49 -45
- data/lib/ohai/plugins/uptime.rb +87 -25
- data/lib/ohai/plugins/virtualization.rb +59 -55
- data/lib/ohai/plugins/windows/cpu.rb +44 -40
- data/lib/ohai/plugins/windows/filesystem.rb +28 -22
- data/lib/ohai/plugins/windows/network.rb +88 -79
- data/lib/ohai/plugins/windows/platform.rb +10 -3
- data/lib/ohai/provides_map.rb +184 -0
- data/lib/ohai/runner.rb +109 -0
- data/lib/ohai/system.rb +103 -184
- data/lib/ohai/version.rb +4 -3
- data/spec/data/plugins/___lib64___libc.so.6.output +135 -0
- data/spec/data/plugins/___lib___libc.so.6.output +135 -0
- data/spec/data/plugins/cc.output +135 -0
- data/spec/data/plugins/cl.output +135 -0
- data/spec/data/plugins/devenv.com.output +135 -0
- data/spec/data/plugins/env.output +71 -0
- data/spec/data/plugins/erl.output +144 -0
- data/spec/data/plugins/gcc.output +135 -0
- data/spec/data/plugins/groovy.output +159 -0
- data/spec/data/plugins/java.output +143 -0
- data/spec/data/plugins/lua.output +143 -0
- data/spec/data/plugins/messages.rb +8 -0
- data/spec/data/plugins/node.output +143 -0
- data/spec/data/plugins/perl.output +143 -0
- data/spec/data/plugins/php.output +143 -0
- data/spec/data/plugins/python.output +143 -0
- data/spec/data/plugins/uname.output +71 -0
- data/spec/data/plugins/v6message.rb +2 -0
- data/spec/data/plugins/v7message.rb +7 -0
- data/spec/data/plugins/what.output +135 -0
- data/spec/data/plugins/xlc.output +135 -0
- data/spec/spec_helper.rb +52 -18
- data/spec/support/integration_helper.rb +44 -0
- data/spec/unit/dsl/plugin_spec.rb +298 -0
- data/spec/unit/hints_spec.rb +65 -0
- data/spec/unit/loader_spec.rb +226 -0
- data/spec/unit/mixin/ec2_metadata_spec.rb +9 -9
- data/spec/unit/plugins/aix/cpu_spec.rb +17 -18
- data/spec/unit/plugins/aix/filesystem_spec.rb +20 -18
- data/spec/unit/plugins/aix/hostname_spec.rb +8 -4
- data/spec/unit/plugins/aix/kernel_spec.rb +13 -12
- data/spec/unit/plugins/aix/network_spec.rb +66 -45
- data/spec/unit/plugins/aix/platform_spec.rb +11 -10
- data/spec/unit/plugins/aix/uptime_spec.rb +7 -8
- data/spec/unit/plugins/azure_spec.rb +20 -21
- data/spec/unit/plugins/c_spec.rb +88 -87
- data/spec/unit/plugins/chef_spec.rb +5 -6
- data/spec/unit/plugins/cloud_spec.rb +81 -82
- data/spec/unit/plugins/darwin/cpu_spec.rb +8 -9
- data/spec/unit/plugins/darwin/hostname_spec.rb +23 -11
- data/spec/unit/plugins/darwin/kernel_spec.rb +39 -16
- data/spec/unit/plugins/darwin/network_spec.rb +375 -378
- data/spec/unit/plugins/darwin/platform_spec.rb +23 -50
- data/spec/unit/plugins/darwin/system_profiler_spec.rb +7 -8
- data/spec/unit/plugins/dmi_spec.rb +7 -12
- data/spec/unit/plugins/ec2_spec.rb +70 -59
- data/spec/unit/plugins/erlang_spec.rb +18 -20
- data/spec/unit/plugins/eucalyptus_spec.rb +37 -33
- data/spec/unit/plugins/fail_spec.rb +276 -23
- data/spec/unit/plugins/freebsd/hostname_spec.rb +11 -9
- data/spec/unit/plugins/freebsd/kernel_spec.rb +8 -8
- data/spec/unit/plugins/freebsd/platform_spec.rb +9 -10
- data/spec/unit/plugins/freebsd/virtualization_spec.rb +32 -32
- data/spec/unit/plugins/gce_spec.rb +19 -25
- data/spec/unit/plugins/groovy_spec.rb +10 -16
- data/spec/unit/plugins/hostname_spec.rb +45 -20
- data/spec/unit/plugins/ip_scopes_spec.rb +97 -0
- data/spec/unit/plugins/java_spec.rb +145 -99
- data/spec/unit/plugins/kernel_spec.rb +51 -15
- data/spec/unit/plugins/linode_spec.rb +31 -29
- data/spec/unit/plugins/linux/cpu_spec.rb +42 -43
- data/spec/unit/plugins/linux/filesystem_spec.rb +143 -324
- data/spec/unit/plugins/linux/hostname_spec.rb +16 -23
- data/spec/unit/plugins/linux/kernel_spec.rb +22 -8
- data/spec/unit/plugins/linux/lsb_spec.rb +54 -56
- data/spec/unit/plugins/linux/network_spec.rb +196 -238
- data/spec/unit/plugins/linux/platform_spec.rb +186 -205
- data/spec/unit/plugins/linux/uptime_spec.rb +13 -25
- data/spec/unit/plugins/linux/virtualization_spec.rb +149 -129
- data/spec/unit/plugins/lua_spec.rb +12 -15
- data/spec/unit/plugins/mono_spec.rb +10 -15
- data/spec/unit/plugins/netbsd/hostname_spec.rb +17 -7
- data/spec/unit/plugins/netbsd/kernel_spec.rb +8 -8
- data/spec/unit/plugins/netbsd/platform_spec.rb +8 -10
- data/spec/unit/plugins/network_spec.rb +358 -235
- data/spec/unit/plugins/nodejs_spec.rb +13 -15
- data/spec/unit/plugins/ohai_spec.rb +3 -4
- data/spec/unit/plugins/ohai_time_spec.rb +8 -9
- data/spec/unit/plugins/openbsd/hostname_spec.rb +21 -11
- data/spec/unit/plugins/openbsd/kernel_spec.rb +8 -8
- data/spec/unit/plugins/openbsd/platform_spec.rb +6 -12
- data/spec/unit/plugins/openstack_spec.rb +214 -0
- data/spec/unit/plugins/os_spec.rb +13 -16
- data/spec/unit/plugins/passwd_spec.rb +12 -13
- data/spec/unit/plugins/perl_spec.rb +20 -44
- data/spec/unit/plugins/php_spec.rb +20 -15
- data/spec/unit/plugins/platform_spec.rb +24 -29
- data/spec/unit/plugins/python_spec.rb +13 -17
- data/spec/unit/plugins/rackspace_spec.rb +90 -57
- data/spec/unit/plugins/root_group_spec.rb +17 -19
- data/spec/unit/plugins/ruby_spec.rb +15 -16
- data/spec/unit/plugins/sigar/network_route_spec.rb +12 -13
- data/spec/unit/plugins/solaris2/cpu_spec.rb +82 -0
- data/spec/unit/plugins/solaris2/hostname_spec.rb +12 -13
- data/spec/unit/plugins/solaris2/kernel_spec.rb +11 -15
- data/{lib/ohai/plugins/openbsd/uptime.rb → spec/unit/plugins/solaris2/memory_spec.rb} +10 -12
- data/spec/unit/plugins/solaris2/network_spec.rb +44 -20
- data/spec/unit/plugins/solaris2/platform_spec.rb +13 -22
- data/spec/unit/plugins/solaris2/virtualization_spec.rb +37 -45
- data/spec/unit/plugins/ssh_host_keys_spec.rb +11 -15
- data/spec/unit/provides_map_spec.rb +208 -0
- data/spec/unit/runner_spec.rb +488 -0
- data/spec/unit/system_spec.rb +639 -104
- metadata +151 -87
- checksums.yaml +0 -7
- data/lib/ohai/mixin/from_file.rb +0 -36
- data/lib/ohai/plugins/aix/ps.rb +0 -23
- data/lib/ohai/plugins/darwin/kernel.rb +0 -37
- data/lib/ohai/plugins/darwin/ps.rb +0 -23
- data/lib/ohai/plugins/darwin/uptime.rb +0 -32
- data/lib/ohai/plugins/dmi_common.rb +0 -121
- data/lib/ohai/plugins/freebsd/hostname.rb +0 -22
- data/lib/ohai/plugins/freebsd/kernel.rb +0 -37
- data/lib/ohai/plugins/freebsd/ps.rb +0 -24
- data/lib/ohai/plugins/hpux/cpu.rb +0 -19
- data/lib/ohai/plugins/hpux/filesystem.rb +0 -19
- data/lib/ohai/plugins/hpux/hostname.rb +0 -19
- data/lib/ohai/plugins/hpux/memory.rb +0 -19
- data/lib/ohai/plugins/hpux/network.rb +0 -19
- data/lib/ohai/plugins/hpux/platform.rb +0 -19
- data/lib/ohai/plugins/hpux/ps.rb +0 -23
- data/lib/ohai/plugins/hpux/uptime.rb +0 -19
- data/lib/ohai/plugins/linux/hostname.rb +0 -40
- data/lib/ohai/plugins/linux/ps.rb +0 -23
- data/lib/ohai/plugins/linux/uptime.rb +0 -28
- data/lib/ohai/plugins/netbsd/hostname.rb +0 -22
- data/lib/ohai/plugins/netbsd/kernel.rb +0 -35
- data/lib/ohai/plugins/netbsd/ps.rb +0 -24
- data/lib/ohai/plugins/netbsd/uptime.rb +0 -31
- data/lib/ohai/plugins/openbsd/hostname.rb +0 -22
- data/lib/ohai/plugins/openbsd/kernel.rb +0 -35
- data/lib/ohai/plugins/openbsd/ps.rb +0 -24
- data/lib/ohai/plugins/sigar/hostname.rb +0 -28
- data/lib/ohai/plugins/sigar/uptime.rb +0 -27
- data/lib/ohai/plugins/solaris2/hostname.rb +0 -34
- data/lib/ohai/plugins/solaris2/kernel.rb +0 -40
- data/lib/ohai/plugins/solaris2/ps.rb +0 -23
- data/lib/ohai/plugins/solaris2/uptime.rb +0 -36
- data/lib/ohai/plugins/windows/hostname.rb +0 -33
- data/lib/ohai/plugins/windows/kernel.rb +0 -58
- data/lib/ohai/plugins/windows/kernel_devices.rb +0 -39
- data/lib/ohai/plugins/windows/uptime.rb +0 -23
- data/spec/unit/mixin/from_file_spec.rb +0 -53
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
|
-
# Author::
|
3
|
-
# Copyright:: Copyright (c)
|
2
|
+
# Author:: Serdar Sutay (<serdar@opscode.com>)
|
3
|
+
# Copyright:: Copyright (c) 2014 Opscode, Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -11,22 +11,24 @@
|
|
11
11
|
#
|
12
12
|
# Unless required by applicable law or agreed to in writing, software
|
13
13
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
15
|
+
# implied.
|
15
16
|
# See the License for the specific language governing permissions and
|
16
17
|
# limitations under the License.
|
17
18
|
#
|
18
19
|
|
19
|
-
|
20
|
+
module Ohai
|
21
|
+
module Mixin
|
22
|
+
module NetworkConstants
|
23
|
+
FAMILIES = {
|
24
|
+
"inet" => "default",
|
25
|
+
"inet6" => "default_inet6"
|
26
|
+
}
|
20
27
|
|
21
|
-
#
|
22
|
-
|
23
|
-
|
24
|
-
|
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)
|
28
|
+
# From sigar: include/sigar.h sigar_net_route_t
|
29
|
+
SIGAR_ROUTE_METHODS = [:destination, :gateway, :mask, :flags,
|
30
|
+
:refcnt, :use, :metric, :mtu, :window,
|
31
|
+
:irtt, :ifname]
|
29
32
|
end
|
30
33
|
end
|
31
34
|
end
|
32
|
-
|
@@ -0,0 +1,59 @@
|
|
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
|
15
|
+
# implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
#
|
19
|
+
|
20
|
+
require 'rbconfig'
|
21
|
+
|
22
|
+
module Ohai
|
23
|
+
module Mixin
|
24
|
+
module OS
|
25
|
+
|
26
|
+
def collect_os
|
27
|
+
case ::RbConfig::CONFIG['host_os']
|
28
|
+
when /aix(.+)$/
|
29
|
+
return "aix"
|
30
|
+
when /darwin(.+)$/
|
31
|
+
return "darwin"
|
32
|
+
when /hpux(.+)$/
|
33
|
+
return "hpux"
|
34
|
+
when /linux/
|
35
|
+
return "linux"
|
36
|
+
when /freebsd(.+)$/
|
37
|
+
return "freebsd"
|
38
|
+
when /openbsd(.+)$/
|
39
|
+
return "openbsd"
|
40
|
+
when /netbsd(.*)$/
|
41
|
+
return "netbsd"
|
42
|
+
when /solaris2/
|
43
|
+
return "solaris2"
|
44
|
+
when /mswin|mingw32|windows/
|
45
|
+
# After long discussion in IRC the "powers that be" have come to a consensus
|
46
|
+
# that no Windows platform exists that was not based on the
|
47
|
+
# Windows_NT kernel, so we herby decree that "windows" will refer to all
|
48
|
+
# platforms built upon the Windows_NT kernel and have access to win32 or win64
|
49
|
+
# subsystems.
|
50
|
+
return "windows"
|
51
|
+
else
|
52
|
+
return ::RbConfig::CONFIG['host_os']
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
module_function :collect_os
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,48 @@
|
|
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
|
+
module Ohai
|
20
|
+
module Mixin
|
21
|
+
module SecondsToHuman
|
22
|
+
def seconds_to_human(seconds)
|
23
|
+
days = seconds.to_i / 86400
|
24
|
+
seconds -= 86400 * days
|
25
|
+
|
26
|
+
hours = seconds.to_i / 3600
|
27
|
+
seconds -= 3600 * hours
|
28
|
+
|
29
|
+
minutes = seconds.to_i / 60
|
30
|
+
seconds -= 60 * minutes
|
31
|
+
|
32
|
+
if days > 1
|
33
|
+
return sprintf("%d days %02d hours %02d minutes %02d seconds", days, hours, minutes, seconds)
|
34
|
+
elsif days == 1
|
35
|
+
return sprintf("%d day %02d hours %02d minutes %02d seconds", days, hours, minutes, seconds)
|
36
|
+
elsif hours > 0
|
37
|
+
return sprintf("%d hours %02d minutes %02d seconds", hours, minutes, seconds)
|
38
|
+
elsif minutes > 0
|
39
|
+
return sprintf("%d minutes %02d seconds", minutes, seconds)
|
40
|
+
else
|
41
|
+
return sprintf("%02d seconds", seconds)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
|
data/lib/ohai/plugins/aix/cpu.rb
CHANGED
@@ -17,33 +17,37 @@
|
|
17
17
|
# limitations under the License.
|
18
18
|
#
|
19
19
|
|
20
|
-
|
20
|
+
Ohai.plugin(:CPU) do
|
21
|
+
provides "cpu"
|
21
22
|
|
22
|
-
|
23
|
+
collect_data(:aix) do
|
24
|
+
cpu Mash.new
|
23
25
|
|
24
|
-
# IBM is the only maker of CPUs for AIX systems.
|
25
|
-
cpu[:vendor_id] = "IBM"
|
26
|
-
# At least one CPU will be available, but we'll wait to increment this later.
|
27
|
-
cpu[:available] = 0
|
28
|
-
cpu[:total] = 0
|
26
|
+
# IBM is the only maker of CPUs for AIX systems.
|
27
|
+
cpu[:vendor_id] = "IBM"
|
28
|
+
# At least one CPU will be available, but we'll wait to increment this later.
|
29
|
+
cpu[:available] = 0
|
30
|
+
cpu[:total] = 0
|
29
31
|
|
30
|
-
cpudevs =
|
31
|
-
cpudevs.each do |c|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
32
|
+
cpudevs = shell_out("lsdev -Cc processor").stdout.lines
|
33
|
+
cpudevs.each do |c|
|
34
|
+
cpu[:total] += 1
|
35
|
+
name, status, location = c.split
|
36
|
+
cpu[name] = Mash.new
|
37
|
+
cpu[name][:status] = status
|
38
|
+
cpu[name][:location] = location
|
39
|
+
if status =~ /Available/
|
38
40
|
cpu[:available] += 1
|
39
|
-
lsattr =
|
41
|
+
lsattr = shell_out("lsattr -El #{name}").stdout.lines
|
40
42
|
lsattr.each do |attribute|
|
41
|
-
|
42
|
-
|
43
|
+
attrib, value = attribute.split
|
44
|
+
cpu[name][attrib] = value
|
43
45
|
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# Every AIX system has proc0.
|
50
|
+
cpu[:model] = cpu[:proc0][:type]
|
51
|
+
cpu[:mhz] = cpu[:proc0][:frequency].to_i / 1024
|
44
52
|
end
|
45
53
|
end
|
46
|
-
|
47
|
-
# Every AIX system has proc0.
|
48
|
-
cpu[:model] = cpu[:proc0][:type]
|
49
|
-
cpu[:mhz] = cpu[:proc0][:frequency].to_i / 1024
|
@@ -12,62 +12,61 @@
|
|
12
12
|
#
|
13
13
|
# Unless required by applicable law or agreed to in writing, software
|
14
14
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
16
|
+
# implied.
|
16
17
|
# See the License for the specific language governing permissions and
|
17
18
|
# limitations under the License.
|
18
19
|
#
|
19
20
|
|
20
|
-
|
21
|
+
Ohai.plugin(:Filesystem) do
|
22
|
+
provides "filesystem"
|
21
23
|
|
22
|
-
|
24
|
+
collect_data(:aix) do
|
25
|
+
fs = Mash.new
|
23
26
|
|
24
|
-
# Grab filesystem data from df
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
27
|
+
# Grab filesystem data from df
|
28
|
+
so = shell_out("df -P")
|
29
|
+
so.stdout.lines.each do |line|
|
30
|
+
case line
|
31
|
+
when /^Filesystem\s+1024-blocks/
|
32
|
+
next
|
33
|
+
when /^(.+?)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+\%)\s+(.+)$/
|
34
|
+
filesystem = $1
|
35
|
+
fs[filesystem] = Mash.new
|
36
|
+
fs[filesystem][:kb_size] = $2
|
37
|
+
fs[filesystem][:kb_used] = $3
|
38
|
+
fs[filesystem][:kb_available] = $4
|
39
|
+
fs[filesystem][:percent_used] = $5
|
40
|
+
fs[filesystem][:mount] = $6
|
41
|
+
end
|
39
42
|
end
|
40
|
-
end
|
41
|
-
end
|
42
43
|
|
43
|
-
# Grab mount information from /bin/mount
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
fs[filesystem][:mount_options] = fields[7]
|
44
|
+
# Grab mount information from /bin/mount
|
45
|
+
so = shell_out("mount")
|
46
|
+
so.stdout.lines.each do |line|
|
47
|
+
case line
|
48
|
+
when /^\s*node/
|
49
|
+
next
|
50
|
+
when /^\s*---/
|
51
|
+
next
|
52
|
+
when /^\s*\/\w/
|
53
|
+
fields = line.split
|
54
|
+
filesystem = fields[0]
|
55
|
+
fs[filesystem] = Mash.new unless fs.has_key?(filesystem)
|
56
|
+
fs[filesystem][:mount] = fields[1]
|
57
|
+
fs[filesystem][:fs_type] = fields[2]
|
58
|
+
fs[filesystem][:mount_options] = fields[6]
|
59
|
+
else
|
60
|
+
fields = line.split
|
61
|
+
filesystem = fields[0] + ":" + fields[1]
|
62
|
+
fs[filesystem] = Mash.new unless fs.has_key?(filesystem)
|
63
|
+
fs[filesystem][:mount] = fields[2]
|
64
|
+
fs[filesystem][:fs_type] = fields[3]
|
65
|
+
fs[filesystem][:mount_options] = fields[7]
|
66
|
+
end
|
67
67
|
end
|
68
|
+
|
69
|
+
# Set the filesystem data
|
70
|
+
filesystem fs
|
68
71
|
end
|
69
72
|
end
|
70
|
-
|
71
|
-
# Set the filesystem data
|
72
|
-
filesystem fs
|
73
|
-
|
@@ -16,12 +16,16 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
|
19
|
+
Ohai.plugin(:Kernel) do
|
20
|
+
provides "kernel", "kernel/modules"
|
20
21
|
|
21
|
-
|
22
|
+
collect_data(:aix) do
|
23
|
+
kernel Mash.new
|
22
24
|
|
23
|
-
kernel[:name] =
|
24
|
-
kernel[:release] =
|
25
|
-
kernel[:version] =
|
26
|
-
kernel[:machine] =
|
27
|
-
kernel[:modules] = Mash.new
|
25
|
+
kernel[:name] = shell_out("uname -s").stdout.downcase
|
26
|
+
kernel[:release] = shell_out("uname -r").stdout
|
27
|
+
kernel[:version] = shell_out("uname -v").stdout
|
28
|
+
kernel[:machine] = shell_out("uname -p").stdout
|
29
|
+
kernel[:modules] = Mash.new
|
30
|
+
end
|
31
|
+
end
|
@@ -16,9 +16,13 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
|
19
|
+
Ohai.plugin(:Memory) do
|
20
|
+
provides "memory"
|
20
21
|
|
21
|
-
|
22
|
+
collect_data(:aix) do
|
23
|
+
memory = Mash.new
|
22
24
|
|
23
|
-
meminfo =
|
24
|
-
memory[:total], u, memory[:free] = meminfo.split
|
25
|
+
meminfo = shell_out("svmon -G -O unit=MB,summary=longreal | grep '[0-9]'").stdout
|
26
|
+
memory[:total], u, memory[:free] = meminfo.split
|
27
|
+
end
|
28
|
+
end
|
@@ -17,56 +17,54 @@
|
|
17
17
|
# limitations under the License.
|
18
18
|
#
|
19
19
|
|
20
|
-
|
21
|
-
|
20
|
+
Ohai.plugin(:Network) do
|
21
|
+
require 'ipaddr'
|
22
22
|
|
23
|
-
|
24
|
-
# :default_interface, :default_gateway - route -n get 0
|
25
|
-
# :interfaces
|
26
|
-
# => routes(netstat -nr | grep en0)
|
27
|
-
# => addresses (ifconfig en0 or lsattr -El en0), macaddress (entstat -d en0 = Hardware Address: be:42:80:00:b0:05)
|
28
|
-
# => flags (ifconfig en0)
|
29
|
-
# => state up/down (ifconfig/lsattr)
|
30
|
-
# => arp (arp -an)
|
23
|
+
provides "network", "counters/network"
|
31
24
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
stdout.each do |line|
|
39
|
-
case line
|
40
|
-
when /gateway: (\S+)/
|
41
|
-
network[:default_gateway] = $1
|
42
|
-
when /interface: (\S+)/
|
43
|
-
network[:default_interface] = $1
|
44
|
-
end
|
25
|
+
# Helpers
|
26
|
+
def hex_to_dec_netmask(netmask)
|
27
|
+
# example '0xffff0000' -> '255.255.0.0'
|
28
|
+
dec = netmask[2..3].to_i(16).to_s(10)
|
29
|
+
[4,6,8].each { |n| dec = dec + "." + netmask[n..n+1].to_i(16).to_s(10) }
|
30
|
+
dec
|
45
31
|
end
|
46
|
-
end
|
47
32
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
33
|
+
collect_data(:aix) do
|
34
|
+
# Loads following information.
|
35
|
+
# :default_interface, :default_gateway - route -n get 0
|
36
|
+
# :interfaces
|
37
|
+
# => routes(netstat -nr | grep en0)
|
38
|
+
# => addresses (ifconfig en0 or lsattr -El en0), macaddress (entstat -d en0 = Hardware Address: be:42:80:00:b0:05)
|
39
|
+
# => flags (ifconfig en0)
|
40
|
+
# => state up/down (ifconfig/lsattr)
|
41
|
+
# => arp (arp -an)
|
55
42
|
|
56
|
-
|
57
|
-
popen4("lsdev -Cc if") do |pid, stdin, stdout, stderr|
|
58
|
-
stdin.close
|
59
|
-
stdout.each do |line|
|
60
|
-
if line =~ /(\S+) (\S+)\s+(.+)/
|
61
|
-
interface = $1
|
62
|
-
iface[interface] = Mash.new unless iface[interface]
|
63
|
-
iface[interface][:state] = ($2 == 'Available' ? 'up' : 'down')
|
64
|
-
iface[interface][:description] = $3
|
43
|
+
iface = Mash.new
|
65
44
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
45
|
+
# :default_interface, :default_gateway - route -n get 0
|
46
|
+
so = shell_out("route -n get 0")
|
47
|
+
so.stdout.lines.each do |line|
|
48
|
+
case line
|
49
|
+
when /gateway: (\S+)/
|
50
|
+
network[:default_gateway] = $1
|
51
|
+
when /interface: (\S+)/
|
52
|
+
network[:default_interface] = $1
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# List the interfaces in system.
|
57
|
+
so = shell_out("lsdev -Cc if")
|
58
|
+
so.stdout.lines.each do |line|
|
59
|
+
if line =~ /(\S+) (\S+)\s+(.+)/
|
60
|
+
interface = $1
|
61
|
+
iface[interface] = Mash.new unless iface[interface]
|
62
|
+
iface[interface][:state] = ($2 == 'Available' ? 'up' : 'down')
|
63
|
+
iface[interface][:description] = $3
|
64
|
+
|
65
|
+
# Query the interface information
|
66
|
+
if_so = shell_out("ifconfig #{interface}")
|
67
|
+
if_so.stdout.lines.each do |line|
|
70
68
|
case line
|
71
69
|
when /^#{interface}:\sflags=\S+<(\S+)>/
|
72
70
|
iface[interface][:flags] = $1.split(',')
|
@@ -84,11 +82,11 @@ popen4("lsdev -Cc if") do |pid, stdin, stdout, stderr|
|
|
84
82
|
else
|
85
83
|
netmask = IPAddr.new("255.255.255.255").mask(tmp_prefix.to_i).to_s
|
86
84
|
end
|
87
|
-
|
85
|
+
|
88
86
|
iface[interface][:addresses] = Mash.new unless iface[interface][:addresses]
|
89
87
|
iface[interface][:addresses][tmp_addr] = { "family" => "inet", "prefixlen" => tmp_prefix }
|
90
88
|
iface[interface][:addresses][tmp_addr][:netmask] = netmask
|
91
|
-
|
89
|
+
|
92
90
|
if line =~ /broadcast\s(\S+)\s/
|
93
91
|
iface[interface][:addresses][tmp_addr][:broadcast] = $1
|
94
92
|
end
|
@@ -105,51 +103,44 @@ popen4("lsdev -Cc if") do |pid, stdin, stdout, stderr|
|
|
105
103
|
end
|
106
104
|
end
|
107
105
|
end
|
108
|
-
end
|
109
|
-
end #ifconfig stdout
|
106
|
+
end #ifconfig stdout
|
110
107
|
|
111
|
-
|
112
|
-
|
113
|
-
e_stdin.close
|
108
|
+
# Query macaddress
|
109
|
+
e_so = shell_out("entstat -d #{interface} | grep \"Hardware Address\"")
|
114
110
|
iface[interface][:addresses] = Mash.new unless iface[interface][:addresses]
|
115
|
-
|
111
|
+
e_so.stdout.lines.each do |line|
|
116
112
|
iface[interface][:addresses][$1.upcase] = { "family" => "lladdr" } if line =~ /Hardware Address: (\S+)/
|
117
113
|
end
|
118
|
-
end
|
114
|
+
end #lsdev stdout
|
119
115
|
end
|
120
|
-
end #lsdev stdout
|
121
|
-
end
|
122
116
|
|
123
|
-
# Query routes information
|
124
|
-
%w{inet inet6}.each do |family|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
117
|
+
# Query routes information
|
118
|
+
%w{inet inet6}.each do |family|
|
119
|
+
so_n = shell_out("netstat -nrf #{family}")
|
120
|
+
so_n.stdout.lines.each do |line|
|
121
|
+
if line =~ /(\S+)\s+(\S+)\s+(\S+)\s+(\d+)\s+(\d+)\s+(\S+)/
|
122
|
+
interface = $6
|
123
|
+
iface[interface][:routes] = Array.new unless iface[interface][:routes]
|
124
|
+
iface[interface][:routes] << Mash.new( :destination => $1, :family => family,
|
125
|
+
:via => $2, :flags => $3)
|
126
|
+
end
|
133
127
|
end
|
134
128
|
end
|
135
|
-
end
|
136
|
-
end
|
137
129
|
|
138
|
-
# List the arp entries in system.
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
130
|
+
# List the arp entries in system.
|
131
|
+
so = shell_out("arp -an")
|
132
|
+
count = 0
|
133
|
+
so.stdout.lines.each do |line|
|
134
|
+
network[:arp] = Mash.new unless network[:arp]
|
135
|
+
if line =~ /\s*(\S+) \((\S+)\) at ([a-fA-F0-9\:]+) \[(\w+)\] stored in bucket/
|
136
|
+
network[:arp][count] = Mash.new unless network[:arp][count]
|
137
|
+
network[:arp][count][:remote_host] = $1
|
138
|
+
network[:arp][count][:remote_ip] = $2
|
139
|
+
network[:arp][count][:remote_mac] = $3.downcase
|
140
|
+
count += 1
|
141
|
+
end
|
150
142
|
end
|
143
|
+
|
144
|
+
network["interfaces"] = iface
|
151
145
|
end
|
152
146
|
end
|
153
|
-
|
154
|
-
network["interfaces"] = iface
|
155
|
-
|