summaryrefslogtreecommitdiff
path: root/lib/ohai/plugins/openbsd/uptime.rb
diff options
context:
space:
mode:
authorClaire McQuin <claire@opscode.com>2013-07-31 17:10:15 -0700
committerClaire McQuin <claire@opscode.com>2013-08-07 10:16:39 -0700
commit2fdf7078f3497c84ee8469d294030a3b169ea5d0 (patch)
treeb17bb9f89ee7c789e438e87d3a9a974b494a794d /lib/ohai/plugins/openbsd/uptime.rb
parent07a1512d4b941c76bd62dcd27e1aa94969814e52 (diff)
downloadohai-2fdf7078f3497c84ee8469d294030a3b169ea5d0.tar.gz
convert plugins to new dsl.
Diffstat (limited to 'lib/ohai/plugins/openbsd/uptime.rb')
-rw-r--r--lib/ohai/plugins/openbsd/uptime.rb21
1 files changed, 12 insertions, 9 deletions
diff --git a/lib/ohai/plugins/openbsd/uptime.rb b/lib/ohai/plugins/openbsd/uptime.rb
index 6028d1e7..82f16383 100644
--- a/lib/ohai/plugins/openbsd/uptime.rb
+++ b/lib/ohai/plugins/openbsd/uptime.rb
@@ -16,17 +16,20 @@
# limitations under the License.
#
-provides "uptime", "uptime_seconds"
+Ohai.plugin(:Uptime) do
+ provides "uptime", "uptime_seconds"
-# kern.boottime=Tue Nov 1 14:45:52 2011
+ # kern.boottime=Tue Nov 1 14:45:52 2011
-popen4("/sbin/sysctl kern.boottime") do |pid, stdin, stdout, stderr|
- stdin.close
- stdout.each do |line|
- if line =~ /kern.boottime=(.+)/
- uptime_seconds Time.new.to_i - Time.parse($1).to_i
- uptime seconds_to_human(uptime_seconds)
+ collect_data do
+ popen4("/sbin/sysctl kern.boottime") do |pid, stdin, stdout, stderr|
+ stdin.close
+ stdout.each do |line|
+ if line =~ /kern.boottime=(.+)/
+ uptime_seconds Time.new.to_i - Time.parse($1).to_i
+ uptime seconds_to_human(uptime_seconds)
+ end
+ end
end
end
end
-