end
end
+disks.each do |disk|
+ if disk[:device] =~ /^cciss\/(.*)$/
+ id = File.read("/sys/bus/cciss/devices/#{Regexp.last_match[1]}/unique_id").chomp
+
+ disk[:munin] = "cciss-3#{id.downcase}"
+ else
+ disk[:munin] = disk[:device]
+ end
+
+ if disk[:id]
+ disk[:munin] = "#{disk[:munin]}-#{disk[:id].to_s.tr('/', ':')}"
+ end
+
+ disk[:hddtemp] = disk[:munin].tr("-:", "_")
+end
+
if disks.count > 0
package "smartmontools"
service "smartmontools" do
action [:enable, :start]
end
+
+ disks.each do |disk|
+ munin_plugin "smart_#{disk[:munin]}" do
+ target "smart_"
+ conf "munin.smart.erb"
+ conf_variables :disk => disk
+ end
+ end
+
+ munin_plugin "hddtemp_smartctl" do
+ conf "munin.hddtemp.erb"
+ conf_variables :disks => disks
+ end
else
service "smartmontools" do
action [:stop, :disable]
end
+
+ munin_plugin "hddtemp_smartctl" do
+ action :delete
+ end
+end
+
+plugins = Dir.glob("/etc/munin/plugins/smart_*").map { |p| File.basename(p) } -
+ disks.map { |d| "smart_#{d[:munin_name]}" }
+
+plugins.each do |plugin|
+ munin_plugin plugin do
+ action :delete
+ end
end
if File.exist?("/etc/mdadm/mdadm.conf")
--- /dev/null
+# DO NOT EDIT - This file is being maintained by Chef
+
+[hddtemp_smartctl]
+env.drives <%= @disks.map { |d| d[:hddtemp] }.sort.join(" ") %>
+<% @disks.sort_by { |d| d[:hddtemp] }.each do |disk| -%>
+<% if disk[:driver] -%>
+env.type_<%= disk[:hddtemp] %> <%= disk[:driver] %>,<%= disk[:id] %>
+<% end -%>
+env.dev_<%= disk[:hddtemp] %> <%= disk[:device] %>
+<% end -%>
--- /dev/null
+# DO NOT EDIT - This file is being maintained by Chef
+
+[smart_<%= @disk[:munin] %>]
+<% if @disk[:driver] -%>
+env.smartargs -H -d <%= @disk[:driver] %>,<%= @disk[:id] %>
+<% else -%>
+env.smartargs -H
+<% end -%>
end
end
-disks = node[:block_device].select do |_, attributes|
- ["ATA", "FUJITSU", "SEAGATE", "DELL", "COMPAQ", "IBM-ESXS"].include?(attributes[:vendor])
-end
-
-if disks.empty?
- munin_plugin "hddtemp_smartctl" do
- action :delete
- end
-else
- munin_plugin "hddtemp_smartctl" do
- conf "hddtemp.erb"
- conf_variables :disks => disks
- end
-end
-
if File.exist?("/sbin/hpasmcli")
munin_plugin "hpasmcli2_temp" do
target "hpasmcli2_"
end
end
-node[:block_device].each do |name, attributes|
- if attributes[:vendor] == "ATA"
- munin_plugin "smart_#{name}" do
- target "smart_"
- conf "smart.erb"
- conf_variables :disk => name
- end
- else
- munin_plugin "smart_#{name}" do
- action :delete
- end
- end
-end
-
munin_plugin "swap"
munin_plugin "tcp"
munin_plugin "threads"
+++ /dev/null
-# DO NOT EDIT - This file is being maintained by Chef
-
-[hddtemp_smartctl]
-env.drives <%= @disks.keys.sort.join(" ") %>
+++ /dev/null
-# DO NOT EDIT - This file is being maintained by Chef
-
-[smart_<%= @disk %>]
-env.smartargs -H