summaryrefslogtreecommitdiff
path: root/munin/owfs_temperature_
diff options
context:
space:
mode:
authorPeter Palfrader <peter@palfrader.org>2006-05-29 02:58:43 +0000
committerweasel <weasel@bc3d92e2-beff-0310-a7cd-cc87d7ac0ede>2006-05-29 02:58:43 +0000
commit11e66f1a9792149e8b1fab010f7d03468e31c18e (patch)
tree2aab272f57862a56b00286120416d2279c5bbfe6 /munin/owfs_temperature_
parent8d552d9376baff23e291f57ae4e7306db020db36 (diff)
Add owfs_temperature_
git-svn-id: svn+ssh://asteria.noreply.org/svn/weaselutils/trunk@106 bc3d92e2-beff-0310-a7cd-cc87d7ac0ede
Diffstat (limited to 'munin/owfs_temperature_')
-rwxr-xr-xmunin/owfs_temperature_93
1 files changed, 93 insertions, 0 deletions
diff --git a/munin/owfs_temperature_ b/munin/owfs_temperature_
new file mode 100755
index 0000000..203aa0d
--- /dev/null
+++ b/munin/owfs_temperature_
@@ -0,0 +1,93 @@
+#!/usr/bin/ruby
+#
+# Copyright (c) 2006 Peter Palfrader
+#
+#%# family=auto
+#%# capabilities=autoconf suggest
+#
+# Munin plugin to moniture temperatures reported by 1-wire devices
+#
+# I use owfs to mount the 1-wire bus to /var/lib/owfs
+# http://owfs.sourceforge.net/
+#
+# Add the following to your /etc/munin/plugin-conf.d/munin-node:
+# [owfs_temperature_10.D234EE000800]
+# env.title = 'in rack 3'
+# env.label = 'rack 3'
+#
+
+$owfs_path = '/var/lib/owfs'
+$owfs_path = ENV['OWFSPATH'] if ENV['OWFSPATH']
+
+def bail_out(m)
+ STDERR.puts "#{$0}: #{m}"
+ exit 1
+end
+
+def autoconf
+ if File.directory?($owfs_path)
+ if File.directory?($owfs_path + '/structure')
+ puts "yes"
+ else
+ puts "no (#{$owfs_path}/structure does not exist or permission denied - owfs not mounted?)"
+ end
+ else
+ puts "no (#{$owfs_path} does not exist or permission denied)"
+ end
+end
+def suggest
+ Dir.glob($owfs_path+'/[0-9A-F][0-9A-F].*/temperature').each do |path|
+ puts File.basename(File.dirname(path))
+ end
+end
+
+def normalize_sensor(s)
+ s = s.downcase
+ s = s.tr('-', 'M')
+ s = s.tr('+', 'P')
+ s.tr('^a-zA-Z0-9', '_')
+end
+
+def query_device
+ match = /_([0-9A-F][0-9A-F]\..*?)$/.match($0)
+ unless match
+ bail_out "Could not figure out which device you want based on executeable name."
+ end
+ match[1]
+end
+
+def config
+ device = query_device
+ title = ENV['title'] ?
+ ENV['title'] :
+ device
+ label = ENV['label'] ?
+ ENV['label'] :
+ device
+ puts "graph_title Temperatures #{title}"
+ puts "graph_args --base 1000"
+ puts "graph_vlabel degrees Celsius";
+ puts "graph_category sensors"
+ puts "graph_info Temperature reported by 1-wire devices"
+ n = normalize_sensor device
+ puts "#{n}.label #{label}"
+end
+
+def report
+ device = query_device
+ temp = File.new($owfs_path+'/'+device+'/temperature').read
+ n = normalize_sensor device
+ puts "#{n}.value #{temp}"
+end
+
+
+case ARGV[0]
+ when "autoconf"
+ autoconf
+ when "suggest"
+ suggest
+ when "config"
+ config
+ else
+ report
+end