]> git.openstreetmap.org Git - chef.git/commitdiff
Report selected apache configuration options to prometheus
authorTom Hughes <tom@compton.nu>
Thu, 7 Sep 2023 16:07:27 +0000 (17:07 +0100)
committerTom Hughes <tom@compton.nu>
Thu, 7 Sep 2023 16:07:27 +0000 (17:07 +0100)
cookbooks/apache/recipes/default.rb
cookbooks/apache/templates/default/apache.prom.erb [new file with mode: 0644]

index f47d500b5163c60bd240491334ceafaa89f42866..4d91da140e061d30389de52992b3edcc801bcf48 100644 (file)
@@ -97,6 +97,13 @@ munin_plugin "apache_accesses"
 munin_plugin "apache_processes"
 munin_plugin "apache_volume"
 
 munin_plugin "apache_processes"
 munin_plugin "apache_volume"
 
+template "/var/lib/prometheus/node-exporter/apache.prom" do
+  source "apache.prom.erb"
+  owner "root"
+  group "root"
+  mode "644"
+end
+
 prometheus_exporter "apache" do
   port 9117
   options "--scrape_uri=http://localhost/server-status?auto"
 prometheus_exporter "apache" do
   port 9117
   options "--scrape_uri=http://localhost/server-status?auto"
diff --git a/cookbooks/apache/templates/default/apache.prom.erb b/cookbooks/apache/templates/default/apache.prom.erb
new file mode 100644 (file)
index 0000000..8c0b5b0
--- /dev/null
@@ -0,0 +1,27 @@
+# HELP apache_server_limit Value of ServerLimit directive
+# TYPE apache_server_limit gauge
+<% if node[:apache][:mpm] == "prefork" -%>
+apache_server_limit{} <%= node[:apache][:prefork][:server_limit] || 256 %>
+<% elsif node[:apache][:mpm] == "worker" -%>
+apache_server_limit{} <%= node[:apache][:worker][:server_limit] || 16 %>
+<% elsif node[:apache][:mpm] == "event" -%>
+apache_server_limit{} <%= node[:apache][:event][:server_limit] || 16 %>
+<% end -%>
+# HELP apache_threads_per_child Value of ThreadsPerChild directive
+# TYPE apache_threads_per_child gauge
+<% if node[:apache][:mpm] == "prefork" -%>
+apache_threads_per_child{} 1
+<% elsif node[:apache][:mpm] == "worker" -%>
+apache_threads_per_child{} <%= node[:apache][:worker][:threads_per_child] || 25 %>
+<% elsif node[:apache][:mpm] == "event" -%>
+apache_threads_per_child{} <%= node[:apache][:event][:threads_per_child] || 25 %>
+<% end -%>
+# HELP apache_async_request_worker_factor Value of AsyncRequestWorkerFactor directive
+# TYPE apache_async_request_worker_factor gauge
+<% if node[:apache][:mpm] == "prefork" -%>
+apache_async_request_worker_factor{} 0
+<% elsif node[:apache][:mpm] == "worker" -%>
+apache_async_request_worker_factor{} 0
+<% elsif node[:apache][:mpm] == "event" -%>
+apache_async_request_worker_factor{} <%= node[:apache][:event][:async_request_worker_factor] || 2 %>
+<% end -%>