Table of Contents

Zabbix Configuration

App Server

Install and configure Zabbix Agent:

Install from RPM (preferred method)

cd /tmp
wget  --user=expbbbu --password=<RETRACTED> ftp://qacollab01.exphosted.com/softrepo/app/installed-software/zabbix/agent/*.rpm
yum localinstall  *.rpm
#Replace <ZABBIXSERVERIP> with IP address of the Zabbix Server / Proxy
sed 's/Server=127.0.0.1/Server=<ZABBIXSERVERIP>/' /etc/zabbix/zabbix_agentd.default >> /etc/zabbix/zabbix_agentd.conf

Install from Source

Download Zabbix source corresponding to the server version.

useradd zabbix
tar -zxvf zabbix-2.2.0.tar.gz
./configure --enable-agent --prefix=/usr/ --sysconfdir=/etc/zabbix/
make install
#Replace <ZABBIXSERVERIP> with IP address of the Zabbix Server / Proxy
mv /etc/zabbix/zabbix_agentd.conf /etc/zabbix/zabbix_agentd.default
sed 's/Server=127.0.0.1/Server=<ZABBIXSERVERIP>/' /etc/zabbix/zabbix_agentd.default >> /etc/zabbix/zabbix_agentd.conf

Additional configuration for App server:

echo "ListenPort=10051" >> /etc/zabbix/zabbix_agentd.conf
echo "UserParameter=passenger.status[*],/usr/local/bin/zab_passenger-status $1" >> /etc/zabbix/zabbix_agentd.conf

Install Munin

yum install munin-common munin-node -y

If YUM does not find munin, install DAG repository.

Install DAG's GPG key:

rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt

Download & Install DAG's YUM repository RPM:

wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el5.rf.x86_64.rpm
rpm -i rpmforge-release-0.5.3-1.el5.rf.*.rpm

You should be able to install munin with the command above. Munin-common package is soon to be merged within munin-node.

Configure Munin

Append the following to /etc/munin/plugin-conf.d/munin-node

[passenger_*]
user munin
command /opt/ruby-enterprise-1.8.7-2011.03/bin/ruby %c

Create /usr/share/munin/plugins/passenger_memory_stats

#!/usr/bin/env /opt/ruby-enterprise-1.8.7-2011.03/bin/ruby
# put in /etc/munin/plugins and restart munin-node
# by Dan Manges, http://www.dcmanges.com/blog/rails-application-visualization-with-munin
# NOTE: you might need to add munin to allow passwordless sudo for passenger-memory-stats

ENV['HTTPD'] = '/opt/apache2/bin/httpd'

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 = `sudo /opt/ruby-enterprise-1.8.7-2011.03/bin/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

Create /usr/share/munin/plugins/passenger_status

#!/bin/env /opt/ruby-enterprise-1.8.7-2011.03/bin/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
END
  exit 0
end

def output_values
  status = `sudo /opt/ruby-enterprise-1.8.7-2011.03/bin/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}"

  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

Create symbolic links to activate them

cd /etc/munin/plugins
ln -nfs /usr/share/munin/plugins/passenger_memory_stats passenger_memory_stats
ln -nfs /usr/share/munin/plugins/passenger_status passenger_status

Append to the sudoers file

munin   ALL=(ALL) NOPASSWD:/opt/ruby-enterprise-1.8.7-2011.03/bin/passenger-status, /opt/ruby-enterprise-1.8.7-2011.03/bin/passenger-memory-stats
zabbix   ALL=(ALL) NOPASSWD:/opt/ruby-enterprise-1.8.7-2011.03/bin/passenger-status, /opt/ruby-enterprise-1.8.7-2011.03/bin/passenger-memory-stats

Finally, installed initialization script under /etc/init.d/zabbix-agent. An example is available on software repository.

BBB Server Configuration

Install Zabbix Agent using the guide above for app servers.

Additional configuration for BBB server:

echo "ListenPort=10050" > /etc/zabbix/zabbix_agentd.conf

Install upstart script /etc/init/zabbix-agent.conf

# zabbix-agent - Start zabbix agent
description     "Zabbix Agent"
start on runlevel [2345]
stop on runlevel [016]
respawn
expect daemon
exec /usr/sbin/zabbix_agentd