]> git.openstreetmap.org Git - chef.git/blobdiff - cookbooks/hardware/recipes/default.rb
Configure SMART collector for prometheus
[chef.git] / cookbooks / hardware / recipes / default.rb
index 6e155f04ffbf6e27fd7e41062489c03707357512..27046a1f78c3e5fa067ad2fd644f2d6520f94d4c 100644 (file)
@@ -20,6 +20,7 @@
 include_recipe "apt"
 include_recipe "git"
 include_recipe "munin"
+include_recipe "prometheus"
 include_recipe "sysfs"
 include_recipe "tools"
 
@@ -402,6 +403,13 @@ disks = disks.compact.uniq
 if disks.count.positive?
   package "smartmontools"
 
+  template "/etc/cron.daily/update-smart-drivedb" do
+    source "update-smart-drivedb.erb"
+    owner "root"
+    group "root"
+    mode "755"
+  end
+
   template "/usr/local/bin/smartd-mailer" do
     source "smartd-mailer.erb"
     owner "root"
@@ -424,7 +432,7 @@ if disks.count.positive?
     mode "644"
   end
 
-  service "smartd" do
+  service "smartmontools" do
     action [:enable, :start]
     subscribes :reload, "template[/etc/smartd.conf]"
     subscribes :restart, "template[/etc/default/smartmontools]"
@@ -443,6 +451,18 @@ if disks.count.positive?
       conf_variables :disk => disk
     end
   end
+
+  template "/etc/prometheus/collectors/smart.devices" do
+    source "smart.devices.erb"
+    owner "root"
+    group "root"
+    mode "644"
+    variables :disks => disks
+  end
+
+  prometheus_collector "smart" do
+    interval "15m"
+  end
 else
   service "smartd" do
     action [:stop, :disable]