From d2529b0cb443dbd362813ae8a83be72a556a08b3 Mon Sep 17 00:00:00 2001 From: sugamasao Date: Tue, 10 Mar 2015 09:52:45 +0900 Subject: [PATCH] unicorn_memory_status/unicorn_status change pid name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit User to be able to change the pid name fixed at “unicorn.pid, but can be changed use `env.pid_name my_unicorn.pid` --- plugins/unicorn/unicorn_memory_status | 9 ++++++--- plugins/unicorn/unicorn_status | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/plugins/unicorn/unicorn_memory_status b/plugins/unicorn/unicorn_memory_status index 7fa092f2..7e5e4dd1 100755 --- a/plugins/unicorn/unicorn_memory_status +++ b/plugins/unicorn/unicorn_memory_status @@ -10,12 +10,15 @@ # set path to your rails app RAILS_ROOT = "/path/to/rails/app" +# set name to your unicorn.pid +PID_NAME = "unicorn.pid" + module Munin class UnicornMemoryStatus attr_reader :pid_file - def initialize(rails_root) - @pid_file = "#{rails_root}/tmp/pids/unicorn.pid" + def initialize(rails_root, pid_name) + @pid_file = "#{rails_root}/tmp/pids/#{pid_name}" end def master_pid @@ -75,6 +78,6 @@ when "config" puts "total_memory.label total_memory" puts "total_memory.draw LINE2" else - m = Munin::UnicornMemoryStatus.new(ENV['rails_root'] || RAILS_ROOT) + m = Munin::UnicornMemoryStatus.new(ENV['rails_root'] || RAILS_ROOT, ENV['pid_name'] || PID_NAME) puts "total_memory.value #{m.total_memory}" end diff --git a/plugins/unicorn/unicorn_status b/plugins/unicorn/unicorn_status index 69e4a716..2088d4b7 100755 --- a/plugins/unicorn/unicorn_status +++ b/plugins/unicorn/unicorn_status @@ -10,12 +10,15 @@ # set path to your rails app RAILS_ROOT = "/path/to/rails/app" +# set name to your unicorn.pid +PID_NAME = "unicorn.pid" + module Munin class UnicornStatus attr_reader :pid_file - def initialize(rails_root) - @pid_file = "#{rails_root}/tmp/pids/unicorn.pid" + def initialize(rails_root, pid_name) + @pid_file = "#{rails_root}/tmp/pids/#{pid_name}" end def master_pid @@ -73,7 +76,7 @@ when "config" puts "total_worker.label total_workers" puts "idle_worker.label idle_workers" else - m = Munin::UnicornStatus.new(ENV['rails_root'] || RAILS_ROOT) + m = Munin::UnicornStatus.new(ENV['rails_root'] || RAILS_ROOT, ENV['pid_name'] || PID_NAME) puts "total_worker.value #{m.worker_count}" puts "idle_worker.value #{m.idle_worker_count}" end