]> git.openstreetmap.org Git - chef.git/commitdiff
Fix api munin plugins
authorTom Hughes <tom@compton.nu>
Tue, 31 Mar 2015 09:49:49 +0000 (10:49 +0100)
committerTom Hughes <tom@compton.nu>
Tue, 31 Mar 2015 09:56:08 +0000 (10:56 +0100)
cookbooks/munin/files/default/plugins/api_calls_
cookbooks/munin/files/default/plugins/api_calls_num
cookbooks/munin/files/default/plugins/api_waits_

index 8b4dd770da199b8e63271a39c4c57827eb5f2232..74c5bbe16895dc53d5e28f6656edbc8f22242b57 100755 (executable)
@@ -9,10 +9,10 @@ def uris_from_status(server)
   file = open("http://#{server}/server-status").read
   doc = Hpricot.parse(file)
   tables = doc / "table"
-  rows = (tables[0] / "tr")[1..-1]
+  rows = (tables[1] / "tr")[1..-1]
   data = rows.collect { |r| (r  / "td").collect(&:inner_html) }
   # filter where the PID is numeric, status is 'W' and host matches the server
-  matching_data = data.select { |r| (r[1].to_i > 0) && r[3].match(/W/) && r[11].match(server) }
+  matching_data = data.select { |r| r[1].to_i > 0 && r[3].match(/W/) && r[11].match(server) }
   # return only the URI part
   matching_data.collect { |r| r[12] }
 end
@@ -54,7 +54,7 @@ if ARGV[0] == "config"
 else
   counts = uris_from_status(server)
            .collect { |x| categorise_uri(x) }
-           .each_with_object({}) do |h, e|
+           .each_with_object({}) do |e, h|
     if h.key? e
       h[e] += 1
     else
index fbc64f387df3ce29bfcf43d94cb7e57a8f4a4efc..c86275e693b1bedd27d3fadab6eb53d6f6369ebe 100755 (executable)
@@ -64,7 +64,7 @@ else
   delta_t = (max_time - min_time).to_f * 24 * 60
   counts = lines
            .collect { |x| categorise_uri(x) }
-           .each_with_object({}) do |h, e|
+           .each_with_object({}) do |e, h|
     if h.key? e
       h[e] += 1
     else
index e4a991a4c2511d57544b450168195985ceb57cfd..ba068f1b5938d88d3693ab47988596b413cd03cb 100755 (executable)
@@ -9,10 +9,10 @@ def uri_and_times_from_status(server)
   file = open("http://#{server}/server-status").read
   doc = Hpricot.parse(file)
   tables = doc / "table"
-  rows = (tables[0] / "tr")[1..-1]
+  rows = (tables[1] / "tr")[1..-1]
   data = rows.collect { |r| (r  / "td").collect(&:inner_html) }
   # filter where the PID is numeric, status is 'W' and host matches the server
-  matching_data = data.select { |r| (r[1].to_i > 0) && r[3].match(/W/) && r[11].match(server) }
+  matching_data = data.select { |r| r[1].to_i > 0 && r[3].match(/W/) && r[11].match(server) }
   # return URI and number of seconds processing for each request
   matching_data.collect { |r| [r[12], r[5].to_i] }
 end
@@ -54,7 +54,7 @@ if ARGV[0] == "config"
 else
   counts = uri_and_times_from_status(server)
            .collect { |x, y| [categorise_uri(x), y] }
-           .each_with_object({}) do |h, e|
+           .each_with_object({}) do |e, h|
     category, time = e
     if h.key? category
       h[category] += [time]