5 # Copyright:: 2010, OpenStreetMap Foundation
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
11 # https://www.apache.org/licenses/LICENSE-2.0
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
20 include_recipe "apache"
24 package "libcgi-fast-perl"
26 template "/etc/default/rrdcached" do
27 source "rrdcached.erb"
33 directory "/var/lib/munin/rrdcached" do
39 service "rrdcached" do
40 action [:enable, :start]
41 subscribes :restart, "template[/etc/default/rrdcached]"
44 munin_plugin "rrdcached"
46 expiry_time = 14 * 86400
48 clients = search(:node, "recipes:munin\\:\\:default").sort_by(&:name)
49 frontends = search(:node, "recipes:web\\:\\:frontend").reject { |n| Time.now - Time.at(n[:ohai_time]) > expiry_time }.sort_by(&:name).map do |n|
50 { :name => n.name.split(".").first, :interface => n.interfaces(:role => :external).first[:interface].tr(".", "_") }
52 backends = search(:node, "recipes:web\\:\\:backend").reject { |n| Time.now - Time.at(n[:ohai_time]) > expiry_time }.sort_by(&:name).map do |n|
53 { :name => n.name.split(".").first }
55 tilecaches = search(:node, "roles:tilecache").reject { |n| Time.now - Time.at(n[:ohai_time]) > expiry_time }.sort_by(&:name).map do |n|
56 { :name => n.name.split(".").first, :interface => n.interfaces(:role => :external).first[:interface].tr(".", "_") }
58 renderers = search(:node, "roles:tile").reject { |n| Time.now - Time.at(n[:ohai_time]) > expiry_time }.sort_by(&:name).map do |n|
59 { :name => n.name.split(".").first, :interface => n.interfaces(:role => :external).first[:interface].tr(".", "_") }
61 geocoders = search(:node, "roles:nominatim").reject { |n| Time.now - Time.at(n[:ohai_time]) > expiry_time }.sort_by(&:name).map do |n|
62 { :name => n.name.split(".").first, :interface => n.interfaces(:role => :external).first[:interface].tr(".", "_") }
65 template "/etc/munin/munin.conf" do
66 source "munin.conf.erb"
70 variables :expiry_time => expiry_time, :clients => clients,
71 :frontends => frontends, :backends => backends,
72 :tilecaches => tilecaches, :renderers => renderers,
73 :geocoders => geocoders
77 apache_module "rewrite"
78 apache_module "headers"
80 remote_directory "/srv/munin.openstreetmap.org" do
90 # directory to put dumped files in
91 directory "/srv/munin.openstreetmap.org/dumps" do
97 ssl_certificate "munin.openstreetmap.org" do
98 domains ["munin.openstreetmap.org", "munin.osm.org"]
99 notifies :reload, "service[apache2]"
102 apache_site "munin.openstreetmap.org" do
103 template "apache.erb"
106 template "/etc/cron.daily/munin-backup" do
107 source "backup.cron.erb"
113 munin_plugin "munin_stats"
114 munin_plugin "munin_update"
115 munin_plugin "munin_rrdcached"