From 2fdf7078f3497c84ee8469d294030a3b169ea5d0 Mon Sep 17 00:00:00 2001 From: Claire McQuin Date: Wed, 31 Jul 2013 17:10:15 -0700 Subject: convert plugins to new dsl. --- lib/ohai/plugins/openbsd/uptime.rb | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'lib/ohai/plugins/openbsd/uptime.rb') 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 - -- cgit v1.2.1