Last active
January 11, 2018 18:49
-
-
Save tomlobato/444e0454f8b2da09aaee93e578010c56 to your computer and use it in GitHub Desktop.
munin-plugins-rails-0.2.13 adjusts for passenger 5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[passenger_*] | |
user root | |
command /root/.rbenv/shims/ruby %c | |
env.passenger_status /root/.rbenv/shims/passenger-status | |
env.passenger_memory_stats /root/.rbenv/shims/passenger-memory-stats | |
env.graph_category Passenger | |
env.PASSENGER_INSTANCE_REGISTRY_DIR /tmp/aptmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env ruby | |
# encoding: utf-8 | |
module Munin | |
class PassengerStatus < RequestLogAnalyzerPlugin | |
def ensure_configuration | |
require_passenger_status | |
super | |
end | |
def config | |
status = `#{passenger_status}` | |
status =~ /max\s+=\s+(\d+)/ | |
upper_limit = $1 || 150 | |
puts <<-CONFIG | |
graph_category #{graph_category} | |
graph_title Passenger stats | |
graph_vlabel count | |
graph_args --base 1000 -l 0 | |
graph_info Passenger stats - railsdoctors.com | |
max_pool_size.label max pool size | |
app_groups.label app groups | |
processes.label processes | |
requests_in_top_level_queue.label requests in top level queue | |
requests_in_queue.label requests in queue | |
sessions.label sessions | |
processed.label processed /10000 | |
cpu.label %cpu /10 | |
memory.label memory /100 | |
CONFIG | |
# --upper-limit #{upper_limit} | |
exit 0 | |
end | |
def str_list str | |
str | |
.split(/\n/) | |
.map(&:strip) | |
.reject(&:empty?) | |
end | |
def run | |
status = run_command(passenger_status, debug) | |
str_list(" | |
Max pool size | |
App groups | |
Processes | |
Requests in top-level queue | |
").each do |str| | |
key = str.downcase.gsub(/(\s|-)+/, '_') | |
status =~ /#{str}\s*:\s*(\d+)/i | |
puts "#{key}.value #{$1}" | |
end | |
str_list(" | |
Requests in queue | |
Sessions | |
Processed /10000 | |
CPU /10 | |
Memory /100 | |
").each do |str| | |
divisor = 1 | |
if str =~ /^(.*?)\s*\/\s*(\d+)\s*$/ | |
str = $1 | |
divisor = $2.to_f | |
end | |
key = str.downcase.gsub(/\s+/, '_') | |
total = 0 | |
status.scan(/#{str}\s*:\s*(\d+)/).flatten.each { |count| total += count.to_i } | |
puts "#{key}.value #{total/divisor}" | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment