summaryrefslogtreecommitdiff
path: root/munin
diff options
context:
space:
mode:
Diffstat (limited to 'munin')
-rwxr-xr-xmunin/owfs_temperature_26
1 files changed, 23 insertions, 3 deletions
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