diff options
author | Micah Anderson <micah@riseup.net> | 2010-04-26 17:30:11 -0400 |
---|---|---|
committer | Micah Anderson <micah@riseup.net> | 2010-04-26 17:30:11 -0400 |
commit | 8b8254af56943e761289d54d5c57fd942303f914 (patch) | |
tree | 05b41635c97310683be94a18612c69b52b1dc60a |
initial commit
-rw-r--r-- | README | 22 | ||||
-rwxr-xr-x | files/munin/passenger_mem | 31 | ||||
-rwxr-xr-x | files/munin/passenger_stats | 45 | ||||
-rw-r--r-- | manifests/init.pp | 50 |
4 files changed, 148 insertions, 0 deletions
@@ -0,0 +1,22 @@ +Passenger (mod_rails) puppet module +----------------------------------- + +This puppet module handles a passenger setup, it installs the +packages, and configures some munin graphs. + +Dependencies +------------ + +This module expects you to have the munin module installed. + +Getting started +--------------- + +Simply do 'include passenger' and it will be installed. + +If you need to install a specific version of passenger or +librack-ruby, you can specify the version to be installed by providing +a variable, for example: + +$passenger_ensure_version = "2.2.3-2~bpo50+1" +$librack-ruby_ensure_version = "1.0.0-2~bpo50+1" diff --git a/files/munin/passenger_mem b/files/munin/passenger_mem new file mode 100755 index 0000000..47fba09 --- /dev/null +++ b/files/munin/passenger_mem @@ -0,0 +1,31 @@ +#!/usr/bin/env ruby +# by Dan Manges, http://www.dcmanges.com/blog/rails-application-visualization-with-munin + +def output_config + puts <<-END +graph_category App +graph_title Passenger memory stats +graph_vlabel count + +memory.label memory +END + exit 0 +end + +def output_values + status = `/usr/sbin/passenger-memory-stats | tail -1` + unless $?.success? + $stderr.puts "failed executing passenger-memory-stats" + exit 1 + end + status =~ /(\d+\.\d+)/ + puts "memory.value #{$1}" +end + +if ARGV[0] == "config" + output_config +else + output_values +end + + diff --git a/files/munin/passenger_stats b/files/munin/passenger_stats new file mode 100755 index 0000000..00bf5e4 --- /dev/null +++ b/files/munin/passenger_stats @@ -0,0 +1,45 @@ +#!/usr/bin/env ruby + +def output_config + puts <<-END +graph_category App +graph_title passenger status +graph_vlabel count + +sessions.label sessions +max.label max processes +running.label running processes +active.label active processes +inactive.label inactive processes +END + exit 0 +end + +def output_values + status = `/usr/sbin/passenger-status` + unless $?.success? + $stderr.puts "failed executing passenger-status" + exit 1 + end + status =~ /max\s+=\s+(\d+)/ + puts "max.value #{$1}" + + status =~ /count\s+=\s+(\d+)/ + puts "running.value #{$1}" + + status =~ /active\s+=\s+(\d+)/ + puts "active.value #{$1}" + + status =~ /inactive\s+=\s+(\d+)/ + puts "inactive.value #{$1}" + + total_sessions = 0 + status.scan(/Sessions: (\d+)/).flatten.each { |count| total_sessions += count.to_i } + puts "sessions.value #{total_sessions}" +end + +if ARGV[0] == "config" + output_config +else + output_values +end diff --git a/manifests/init.pp b/manifests/init.pp new file mode 100644 index 0000000..62166e7 --- /dev/null +++ b/manifests/init.pp @@ -0,0 +1,50 @@ +# passenger module +# +# Copyright 2010, Riseup Networks +# Micah Anderson micah(at)riseup.net +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 3 as +# published by the Free Software Foundation. +# +# If you need to install a specific version of passenger or +# librack-ruby, you can specify the version to be installed by +# providing a variable, for example: +# +# $passenger_ensure_version = "2.2.3-2~bpo50+1" +# $librack-ruby_ensure_version = "1.0.0-2~bpo50+1" + +class passenger { + + if !defined(Package["libapache2-mod-passenger"]) { + if $passenger_ensure_version == '' { $passenger_ensure_version = 'installed' } + package { + "libapache2-mod-passenger": + ensure => $passenger_ensure_version; + } + } + if !defined(Package["librack-ruby"]) { + if $librack-ruby_ensure_version == '' { $librack-ruby_ensure_version = 'installed' } + package { + "librack-ruby": + ensure => $librack-ruby_ensure_version; + } + } + + file { + "/usr/local/share/munin-plugins/passenger_mem": + source => [ "puppet://$server/modules/site-passenger/munin/passenger_mem", + "puppet://$server/modules/passenger/munin/passenger_mem" ], + mode => 0755, owner => root, group => root; + + "/usr/local/share/munin-plugins/passenger_stats": + source => [ "puppet://$server/modules/site-passenger/munin/passenger_stats", + "puppet://$server/modules/passenger/munin/passenger_stats" ], + mode => 0755, owner => root, group => root; + } + + munin::plugin { [ passenger_mem, passenger_stats ]: + config => "user root", + script_path_in => "/usr/local/share/munin-plugins"; + } +} |