diff options
author | Julian C. Dunn <jdunn@aquezada.com> | 2014-10-01 07:34:48 -0700 |
---|---|---|
committer | Julian C. Dunn <jdunn@aquezada.com> | 2014-10-01 07:34:48 -0700 |
commit | a3b834004a627c7bcc5885cf106567100851b201 (patch) | |
tree | a365ff55edfb512eaa3a9712d008c234e63b172a | |
parent | 1e8510fae9d1a07360f9e4870acb903a072f7a48 (diff) | |
parent | 7b4160cfa58a39541bce6444410a21e03928d7be (diff) | |
download | ohai-a3b834004a627c7bcc5885cf106567100851b201.tar.gz |
Merge pull request #419 from ClogenyTechnologies/kd/aixuptimefix
[AIX-53] fix incorrect uptime
-rw-r--r-- | lib/ohai/plugins/aix/uptime.rb | 4 | ||||
-rw-r--r-- | spec/unit/plugins/aix/uptime_spec.rb | 13 |
2 files changed, 9 insertions, 8 deletions
diff --git a/lib/ohai/plugins/aix/uptime.rb b/lib/ohai/plugins/aix/uptime.rb index 6c33cb7b..270a692f 100644 --- a/lib/ohai/plugins/aix/uptime.rb +++ b/lib/ohai/plugins/aix/uptime.rb @@ -27,10 +27,10 @@ Ohai.plugin(:Uptime) do so = shell_out('who -b') so.stdout.lines.each do |line| if line =~ /.* boot (.+)/ - uptime_seconds Time.now.to_i - DateTime.parse($1).strftime('%s').to_i + uptime_seconds Time.now.to_i - DateTime.parse($1 + " #{Time.now.zone}").strftime('%s').to_i uptime seconds_to_human(uptime_seconds) break end end end -end +end
\ No newline at end of file diff --git a/spec/unit/plugins/aix/uptime_spec.rb b/spec/unit/plugins/aix/uptime_spec.rb index 2f66b031..6d089c8f 100644 --- a/spec/unit/plugins/aix/uptime_spec.rb +++ b/spec/unit/plugins/aix/uptime_spec.rb @@ -22,18 +22,19 @@ describe Ohai::System, "Aix plugin uptime" do before(:each) do @plugin = get_plugin("aix/uptime") @plugin.stub(:collect_os).and_return(:aix) - Time.stub_chain(:now, :to_i).and_return(1374258600) - DateTime.stub_chain(:parse, :strftime, :to_i).and_return(1373392260) - @plugin.stub(:shell_out).with("who -b").and_return(mock_shell_out(0, " . system boot Jul 9 17:51", nil)) + Time.stub_chain(:now, :to_i).and_return(1412072511) + Time.stub_chain(:now, :zone).and_return("IST") + DateTime.stub_chain(:parse, :strftime, :to_i).and_return(1411561320) + @plugin.stub(:shell_out).with("who -b").and_return(mock_shell_out(0, " . system boot Sep 24 17:52", nil)) - @plugin.run + @plugin.run end it "should set uptime_seconds to uptime" do - @plugin[:uptime_seconds].should == 866340 + @plugin[:uptime_seconds].should == 511191 end it "should set uptime to a human readable date" do - @plugin[:uptime].should == "10 days 00 hours 39 minutes 00 seconds" + @plugin[:uptime].should == "5 days 21 hours 59 minutes 51 seconds" end end |