From 36292f85732f6ba51df2acee74a561f588eb430c Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Mon, 29 May 2006 03:33:29 +0000 Subject: owfs is weird git-svn-id: svn+ssh://asteria.noreply.org/svn/weaselutils/trunk@108 bc3d92e2-beff-0310-a7cd-cc87d7ac0ede --- munin/owfs_temperature_ | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'munin') diff --git a/munin/owfs_temperature_ b/munin/owfs_temperature_ index 3c87c21..dfdf883 100755 --- a/munin/owfs_temperature_ +++ b/munin/owfs_temperature_ @@ -75,9 +75,29 @@ end def report device = query_device - temp = File.new($owfs_path+'/'+device+'/temperature').read - n = normalize_sensor device - puts "#{n}.value #{temp}" + Process.gid=0 + Process.egid=0 + temp = nil + # fuse does weird checks. this fails: + # File.new($owfs_path+'/'+device+'/temperature', "r") ---> FAILS: in `initialize': Permission denied - /var/lib/owfs/10.D234EE000800/temperature (Errno::EACCES) + IO.popen("-") do |f| + unless f # child + begin + exec('cat', $owfs_path+'/'+device+'/temperature') + rescue => e + puts "Cannot exec cat: "+e.message + exit 1 + end + end + temp = f.readlines + end + + if $? != 0 + STDERR.puts "Child exited with non-zero exit code(%d): %s"%[$? >> 8, temp.join('')] + else + n = normalize_sensor device + puts "#{n}.value #{temp.join('')}" + end end -- cgit v1.2.3