diff options
author | kaustubh-d <kaustubh@clogeny.com> | 2013-07-31 04:46:20 -0700 |
---|---|---|
committer | adamedx <adamed@opscode.com> | 2013-09-23 16:02:49 -0700 |
commit | 24516f496147b98b08100912f3f69215a6ea8bc0 (patch) | |
tree | af24b0c3b99f478e430ed9b8ea573ff023b70c92 | |
parent | 225c6a69b1ac8b426e25dfe0af88bac2fb5ceedd (diff) | |
download | ohai-24516f496147b98b08100912f3f69215a6ea8bc0.tar.gz |
aix uptime lookup is similar to solaris one.
-rw-r--r-- | lib/ohai/plugins/aix/uptime.rb | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/lib/ohai/plugins/aix/uptime.rb b/lib/ohai/plugins/aix/uptime.rb index 23aa89f3..68e99b79 100644 --- a/lib/ohai/plugins/aix/uptime.rb +++ b/lib/ohai/plugins/aix/uptime.rb @@ -1,6 +1,6 @@ # -# Author:: Doug MacEachern <dougm@vmware.com> -# Copyright:: Copyright (c) 2010 VMware, Inc. +# Author:: Kurt Yoder (<ktyopscode@yoderhome.com>) +# Copyright:: Copyright (c) 2013 Opscode, Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,5 +15,20 @@ # See the License for the specific language governing permissions and # limitations under the License. # +require 'date' -require_plugin "sigar::uptime" +provides "uptime", "uptime_seconds" + +# Example output: +# $ who -b +# . system boot Jul 9 17:51 +popen4('who -b') do |pid, stdin, stdout, stderr| + stdin.close + stdout.each do |line| + if line =~ /.* boot (.+)/ + uptime_seconds Time.now.to_i - DateTime.parse($1).strftime('%s').to_i + uptime self._seconds_to_human(uptime_seconds) + break + end + end +end |