Rework squid compound requests graph
authorTom Hughes <tom@compton.nu>
Thu, 1 Sep 2016 19:29:34 +0000 (20:29 +0100)
committerTom Hughes <tom@compton.nu>
Thu, 1 Sep 2016 19:30:06 +0000 (20:30 +0100)
cookbooks/munin/libraries/expand.rb
cookbooks/munin/templates/default/munin.conf.erb

index f9c4473..248c5ad 100644 (file)
@@ -1,6 +1,6 @@
 class Chef
   class Munin
-    def self.expand(template, nodes)
+    def self.expand(template, nodes, separator = " ")
       nodes.map do |node|
         if node.is_a?(Hash)
           template
@@ -11,7 +11,7 @@ class Chef
             .gsub("%%%", node.tr("-", "_"))
             .gsub("%%", node)
         end
-      end.join(" ")
+      end.join(separator)
     end
   end
 end
index 1e4e75f..1076685 100644 (file)
@@ -330,18 +330,22 @@ unknown_limit 144
     squid_requests.graph_title Squid client requests
     squid_requests.graph_args --base 1000 -l 0
     squid_requests.graph_vlabel requests / ${graph_period}
-    squid_requests.graph_order hits errors requests
+    squid_requests.graph_order <%= Chef::Munin.expand "%%%name%%%_hits=%%name%%.openstreetmap:squid_requests.hits %%%name%%%_errors=%%name%%.openstreetmap:squid_requests.errors %%%name%%%_requests=%%name%%.openstreetmap:squid_requests.requests", @tilecaches %> hits errors requests
     squid_requests.graph_total total
     squid_requests.graph_category squid
-    squid_requests.hits.sum <%= Chef::Munin.expand "%%name%%.openstreetmap:squid_requests.hits", @tilecaches %>
+<% @tilecaches.each do |tc| -%>
+    squid_requests.<%= tc[:name].tr("-", "_") %>_hits.graph no
+    squid_requests.<%= tc[:name].tr("-", "_") %>_errors.graph no
+    squid_requests.<%= tc[:name].tr("-", "_") %>_requests.graph no
+<% end -%>
+    squid_requests.hits.cdef 0,<%= Chef::Munin.expand "%%%name%%%_hits", @tilecaches, ",+," %>,+
     squid_requests.hits.label hits
     squid_requests.hits.draw AREA
-    squid_requests.errors.sum <%= Chef::Munin.expand "%%name%%.openstreetmap:squid_requests.errors", @tilecaches %>
+    squid_requests.errors.cdef 0,<%= Chef::Munin.expand "%%%name%%%_errors", @tilecaches, ",+," %>,+
     squid_requests.errors.label errors
     squid_requests.errors.draw STACK
-    squid_requests.requests.sum <%= Chef::Munin.expand "%%name%%.openstreetmap:squid_requests.requests", @tilecaches %>
+    squid_requests.requests.cdef 0,<%= Chef::Munin.expand "%%%name%%%_requests", @tilecaches, ",+," %>,+,hits,-,errors,-
     squid_requests.requests.label misses
-    squid_requests.requests.cdef requests,hits,-,errors,-
     squid_requests.requests.draw STACK
     squid_traffic.graph_title Squid traffic status
     squid_traffic.graph_args --base 1000