Override network speed to virtio interfaces
authorTom Hughes <tom@compton.nu>
Sun, 9 Oct 2016 21:25:49 +0000 (22:25 +0100)
committerTom Hughes <tom@compton.nu>
Sun, 9 Oct 2016 21:31:49 +0000 (22:31 +0100)
cookbooks/munin/recipes/default.rb
cookbooks/munin/templates/default/if.erb [new file with mode: 0644]

index 677d79d..fb98079 100644 (file)
@@ -162,6 +162,17 @@ end
 
 node[:network][:interfaces].each do |ifname, ifattr|
   if ifattr[:encapsulation] == "Ethernet" && ifattr[:state] == "up"
+    if node[:hardware][:network][ifname][:device] =~ /^virtio/
+      munin_plugin_conf "if_#{ifname}" do
+        template "if.erb"
+        variables :ifname => ifname
+      end
+    else
+      munin_plugin_conf "if_#{ifname}" do
+        action :delete
+      end
+    end
+
     munin_plugin "if_err_#{ifname}" do
       target "if_err_"
     end
diff --git a/cookbooks/munin/templates/default/if.erb b/cookbooks/munin/templates/default/if.erb
new file mode 100644 (file)
index 0000000..1f36d50
--- /dev/null
@@ -0,0 +1,4 @@
+# DO NOT EDIT - This file is being maintained by Chef
+
+[if_<%= @ifname %>]
+env.speed 1000