summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkaustubh-d <kaustubh@clogeny.com>2014-09-30 07:42:24 -0700
committerkaustubh-d <kaustubh@clogeny.com>2014-09-30 07:42:24 -0700
commit7b4160cfa58a39541bce6444410a21e03928d7be (patch)
tree94729a35ba32103dd2567d3a4d6841bdbe2c4a53
parent35dc3d5010dc6392f8fbb7f389534e47c0e0427a (diff)
downloadohai-7b4160cfa58a39541bce6444410a21e03928d7be.tar.gz
aix - fix uptime timezone issue.
-rw-r--r--lib/ohai/plugins/aix/uptime.rb4
-rw-r--r--spec/unit/plugins/aix/uptime_spec.rb13
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