Restart squid if any statistics counters have wrapped
authorTom Hughes <tom@compton.nu>
Tue, 20 Sep 2016 08:17:30 +0000 (09:17 +0100)
committerTom Hughes <tom@compton.nu>
Tue, 20 Sep 2016 08:17:30 +0000 (09:17 +0100)
cookbooks/squid/recipes/default.rb

index 917834eb2ad1a33ef5ae4bce0224ecd1640fda01..def3d9187f2aa642c2c90a654ad588a83cc8b3f1 100644 (file)
@@ -62,6 +62,16 @@ service "squid" do
   subscribes :reload, "template[/etc/resolv.conf]"
 end
 
   subscribes :reload, "template[/etc/resolv.conf]"
 end
 
+log "squid-restart" do
+  message "Restarting squid due to counter wraparound"
+  notifies :restart, "service[squid]"
+  only_if do
+    IO.popen(["squidclient", "--host=127.0.0.1", "--port=80", "mgr:counters"]) do |io|
+      io.each.grep(/^[a-z][a-z_.]+ = -[0-9]+$/).count > 0
+    end
+  end
+end
+
 munin_plugin "squid_cache"
 munin_plugin "squid_delay_pools"
 munin_plugin "squid_delay_pools_noreferer"
 munin_plugin "squid_cache"
 munin_plugin "squid_delay_pools"
 munin_plugin "squid_delay_pools_noreferer"