From: Tom Hughes Date: Tue, 3 Oct 2017 17:46:28 +0000 (+0100) Subject: Rework tile cache logging to avoid duplication X-Git-Url: https://git.openstreetmap.org/chef.git/commitdiff_plain/6b8e67103d90b327fb6eb1dd859cfd7f7d18340f Rework tile cache logging to avoid duplication Closes #94 --- diff --git a/cookbooks/nginx/attributes/default.rb b/cookbooks/nginx/attributes/default.rb index fc2573314..44fb5bc10 100644 --- a/cookbooks/nginx/attributes/default.rb +++ b/cookbooks/nginx/attributes/default.rb @@ -1,3 +1,6 @@ +# Tuning for access logging +default[:nginx][:access_log] = "/var/log/nginx/access.log" + # Tuning for nginx fastcgi cache zone default[:nginx][:cache][:fastcgi][:enable] = false default[:nginx][:cache][:fastcgi][:keys_zone] = "fastcgi_cache_zone:32M" diff --git a/cookbooks/nginx/templates/default/nginx.conf.erb b/cookbooks/nginx/templates/default/nginx.conf.erb index a895af303..67b080bf1 100644 --- a/cookbooks/nginx/templates/default/nginx.conf.erb +++ b/cookbooks/nginx/templates/default/nginx.conf.erb @@ -19,11 +19,13 @@ http { server_names_hash_bucket_size 128; +<% if node[:nginx][:access_log] -%> log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; - access_log /var/log/nginx/access.log main buffer=32k flush=1m; + access_log <%= node[:nginx][:access_log] %> main buffer=32k flush=1m; +<% end -%> keepalive_timeout 65; diff --git a/cookbooks/squid/attributes/default.rb b/cookbooks/squid/attributes/default.rb index 990b0dc17..f26853fa8 100644 --- a/cookbooks/squid/attributes/default.rb +++ b/cookbooks/squid/attributes/default.rb @@ -1,4 +1,4 @@ default[:squid][:cache_mem] = "256 MB" default[:squid][:cache_dir] = "ufs /var/spool/squid 256 16 256" -default[:squid][:access_log] = "/var/log/squid/access.log squid" +default[:squid][:access_log] = "/var/log/squid/access.log openstreetmap" diff --git a/cookbooks/squid/recipes/default.rb b/cookbooks/squid/recipes/default.rb index 54e6e4af4..f024adcc6 100644 --- a/cookbooks/squid/recipes/default.rb +++ b/cookbooks/squid/recipes/default.rb @@ -85,3 +85,7 @@ munin_plugin "squid_icp" munin_plugin "squid_objectsize" munin_plugin "squid_requests" munin_plugin "squid_traffic" + +Dir.glob("/var/log/squid/zere.log*") do |log| + File.unlink(log) +end diff --git a/cookbooks/squid/templates/default/squid.conf.erb b/cookbooks/squid/templates/default/squid.conf.erb index 35b336cad..f290f730d 100644 --- a/cookbooks/squid/templates/default/squid.conf.erb +++ b/cookbooks/squid/templates/default/squid.conf.erb @@ -84,10 +84,7 @@ http_access deny purge forwarded_for on follow_x_forwarded_for allow localhost -#Loggin used for analysis -logformat zerelog %ts.%03tu %rp "%{Etag}a "%{User-Agent}>h" %a %Ss/%03Hs %h" "%{User-Agent}>h" access_log <%= node[:squid][:access_log] %> cache_log /var/log/squid/cache.log cache_store_log none diff --git a/cookbooks/tilecache/recipes/default.rb b/cookbooks/tilecache/recipes/default.rb index 41a4e7f71..0a02e1567 100644 --- a/cookbooks/tilecache/recipes/default.rb +++ b/cookbooks/tilecache/recipes/default.rb @@ -138,3 +138,7 @@ tilerenders.each do |render| conf_variables :host => render[:fqdn] end end + +Dir.glob("/var/log/nginx/access.log*") do |log| + File.unlink(log) +end diff --git a/cookbooks/tilecache/templates/default/logrotate.squid.erb b/cookbooks/tilecache/templates/default/logrotate.squid.erb index 2112b85cd..0c45dcab0 100644 --- a/cookbooks/tilecache/templates/default/logrotate.squid.erb +++ b/cookbooks/tilecache/templates/default/logrotate.squid.erb @@ -14,6 +14,6 @@ test ! -e /var/run/squid.pid || /usr/sbin/squid -k rotate endscript lastaction - /usr/bin/rsync --preallocate /var/log/squid/zere.log.1.xz ironbelly::logs/tile.openstreetmap.org/<%= node[:hostname] %>-`date -d "-1 days" +%Y-%m-%d`.xz || true + /usr/bin/rsync --preallocate /var/log/squid/access.log.1.xz ironbelly::logs/tile.openstreetmap.org/<%= node[:hostname] %>-`date -d "-1 days" +%Y-%m-%d`.xz || true endscript } diff --git a/roles/tilecache.rb b/roles/tilecache.rb index 313c262f4..a579079ff 100644 --- a/roles/tilecache.rb +++ b/roles/tilecache.rb @@ -12,6 +12,9 @@ default_attributes( :apt => { :sources => ["nginx"] }, + :nginx => { + :access_log => nil + }, :sysctl => { :network_conntrack_time_wait => { :comment => "Only track completed connections for 30 seconds",