summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2018-09-27 08:47:06 -0700
committerGitHub <noreply@github.com>2018-09-27 08:47:06 -0700
commit9073d82255e8b66707c03a01b1aea7ca78c739d1 (patch)
tree80c75ffcd3aa1e412e8134e5fa1f651b443f4861
parent13d35c039deada4f523b28c75630831ab3137dd2 (diff)
parent3863962ecfae634999c9fd4f60fc120e1f3e9199 (diff)
downloadohai-9073d82255e8b66707c03a01b1aea7ca78c739d1.tar.gz
Merge pull request #1259 from chef/sysctl_less
Avoid gathering all data with sysctl which seems to hang
-rw-r--r--lib/ohai/plugins/darwin/cpu.rb4
-rw-r--r--spec/unit/plugins/darwin/cpu_spec.rb4
2 files changed, 4 insertions, 4 deletions
diff --git a/lib/ohai/plugins/darwin/cpu.rb b/lib/ohai/plugins/darwin/cpu.rb
index a0c90532..d8210c9d 100644
--- a/lib/ohai/plugins/darwin/cpu.rb
+++ b/lib/ohai/plugins/darwin/cpu.rb
@@ -1,7 +1,7 @@
#
# Author:: Nathan L Smith (<nlloyds@gmail.com>)
# Author:: Tim Smith (<tsmith@chef.io>)
-# Copyright:: Copyright (c) 2013-2016 Chef Software, Inc.
+# Copyright:: Copyright (c) 2013-2018 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,7 +22,7 @@ Ohai.plugin(:CPU) do
collect_data(:darwin) do
cpu Mash.new
- shell_out("sysctl -a").stdout.lines.each do |line|
+ shell_out("sysctl hw machdep").stdout.lines.each do |line|
case line
when /^hw.packages: (.*)$/
cpu[:real] = Regexp.last_match[1].to_i
diff --git a/spec/unit/plugins/darwin/cpu_spec.rb b/spec/unit/plugins/darwin/cpu_spec.rb
index 1ad65e30..8743283e 100644
--- a/spec/unit/plugins/darwin/cpu_spec.rb
+++ b/spec/unit/plugins/darwin/cpu_spec.rb
@@ -1,6 +1,6 @@
#
# Author:: Nathan L Smith (<nlloyds@gmail.com>)
-# Copyright:: Copyright (c) 2013-2016 Chef Software, Inc.
+# Copyright:: Copyright (c) 2013-2018 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -78,7 +78,7 @@ describe Ohai::System, "Darwin cpu plugin" do
CTL
allow(@plugin).to receive(:collect_os).and_return(:darwin)
- allow(@plugin).to receive(:shell_out).with("sysctl -a").and_return(mock_shell_out(0, @stdout, ""))
+ allow(@plugin).to receive(:shell_out).with("sysctl hw machdep").and_return(mock_shell_out(0, @stdout, ""))
@plugin.run
end