]> git.openstreetmap.org Git - chef.git/commitdiff
Rework tile cache logging to avoid duplication
authorTom Hughes <tom@compton.nu>
Tue, 3 Oct 2017 17:46:28 +0000 (18:46 +0100)
committerTom Hughes <tom@compton.nu>
Tue, 3 Oct 2017 18:08:26 +0000 (19:08 +0100)
Closes #94

cookbooks/nginx/attributes/default.rb
cookbooks/nginx/templates/default/nginx.conf.erb
cookbooks/squid/attributes/default.rb
cookbooks/squid/recipes/default.rb
cookbooks/squid/templates/default/squid.conf.erb
cookbooks/tilecache/recipes/default.rb
cookbooks/tilecache/templates/default/logrotate.squid.erb
roles/tilecache.rb

index fc2573314efca3721091c0897fbc67b7ad8f19e4..44fb5bc10339d71a7f3a8a57a1c3b5dd69426ef1 100644 (file)
@@ -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"
index a895af303c46e8b930625ada40ddee164e267b4b..67b080bf16d443a613b0faaf6076d730e915a07a 100644 (file)
@@ -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;
 
index 990b0dc170f9f6bc5159199e814088a5839e6895..f26853fa82ae39309e7c4ae40344c0dbe16c9aa9 100644 (file)
@@ -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"
index 54e6e4af4848d5a3056cf05c1d8dc7d397e7d3aa..f024adcc6dfba19f1d0c5be94d083a4349092768 100644 (file)
@@ -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
index 35b336cada2eed2794e54f9eeaf2ebe05f4d1802..f290f730d22b16f7f1174f435a03dc0e3552d064 100644 (file)
@@ -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}<h" %>a "%{User-Agent}>h" %<st
-access_log /var/log/squid/zere.log zerelog
-
+logformat openstreetmap %ts.%03tu %tr %>a %Ss/%03Hs %<st %rm %rp %Sh/%<A %mt "%{Referer}>h" "%{User-Agent}>h"
 access_log <%= node[:squid][:access_log] %>
 cache_log /var/log/squid/cache.log
 cache_store_log none
index 41a4e7f71935e018806e296b53ef4ac4b659ce57..0a02e1567edfac8c19ce52df47e44b55b724685d 100644 (file)
@@ -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
index 2112b85cde2f631e38679ad42cd1eba2c7852b53..0c45dcab0b13a5a8c2763ad1b0c0705c52b5ba3a 100644 (file)
@@ -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
 }
index 313c262f49e148cea605e46881f1b750d84a13e8..a579079ff15e2a176a351890cb7c789a90e8066e 100644 (file)
@@ -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",