]> git.openstreetmap.org Git - chef.git/commitdiff
Filter out FailedOpenDevice messages from areca controllers
authorTom Hughes <tom@compton.nu>
Mon, 21 Sep 2015 22:12:21 +0000 (23:12 +0100)
committerTom Hughes <tom@compton.nu>
Mon, 21 Sep 2015 22:12:21 +0000 (23:12 +0100)
cookbooks/hardware/recipes/default.rb
cookbooks/hardware/templates/default/smartd-mailer.erb [new file with mode: 0644]
cookbooks/hardware/templates/default/smartd.conf.erb

index d976e89dccbfa9bc702f9867d74c39610a0b8758..331fc8fe2380477e2cd9bd58101d62ff22964d8b 100644 (file)
@@ -409,6 +409,13 @@ end
 if disks.count > 0
   package "smartmontools"
 
+  template "/usr/local/bin/smartd-mailer" do
+    source "smartd-mailer.erb"
+    owner "root"
+    group "root"
+    mode 0755
+  end
+
   template "/etc/smartd.conf" do
     source "smartd.conf.erb"
     owner "root"
diff --git a/cookbooks/hardware/templates/default/smartd-mailer.erb b/cookbooks/hardware/templates/default/smartd-mailer.erb
new file mode 100644 (file)
index 0000000..589759d
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# DO NOT EDIT - This file is being maintained by Chef
+
+case "$SMARTD_DEVICETYPE" in
+    areca,*) [ "$SMARTD_FAILTYPE" = "FailedOpenDevice" ] && exit 0
+esac
+
+exec mail -s "$SMARTD_SUBJECT" $SMARTD_ADDRESS <<EOF
+$SMARTD_FULLMESSAGE
+EOF
index b4f2aeb5f0fe7e759fde8bc201614d6eb5851ac6..e0d86831a27226e67fb0a8a225ed5ed499c0b047 100644 (file)
@@ -2,8 +2,8 @@
   
 <% @disks.each do |disk| -%>
 <% if disk[:driver] -%>
-/dev/<%= disk[:device] %> -d <%= disk[:driver] %>,<%= disk[:id] %> -s S/../../7/02 -m admins@openstreetmap.org
+/dev/<%= disk[:device] %> -d <%= disk[:driver] %>,<%= disk[:id] %> -s S/../../7/02 -m admins@openstreetmap.org -M exec /usr/local/bin/smartd-mailer
 <% else -%>
-/dev/<%= disk[:device] %> -s S/../../7/02 -m admins@openstreetmap.org
+/dev/<%= disk[:device] %> -s S/../../7/02 -m admins@openstreetmap.org -M exec /usr/local/bin/smartd-mailer
 <% end -%>
 <% end -%>