Skip to content

Instantly share code, notes, and snippets.

@crofty
Created September 9, 2009 07:39
Show Gist options
  • Save crofty/183552 to your computer and use it in GitHub Desktop.
Save crofty/183552 to your computer and use it in GitHub Desktop.
Munin setup on Slicehost
sudo apt-get install munin munin-node
# Edit the config file: sudo vim /etc/munin/munin.conf
dbdir /var/lib/munin/
htmldir /var/www/munin/
logdir /var/log/munin
rundir /var/run/munin/
[localhost.localdomain]
address 127.0.0.1
use_node_name yes
# Restart munin
sudo /etc/init.d/munin-node restart
# Set up the vhost: sudo vim /etc/apache2/sites-available/munin
<VirtualHost *:80>
ServerName munin.domain.com
DocumentRoot /var/www/munin
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
LogLevel notice
CustomLog /var/log/apache2/access.log combined
ErrorLog /var/log/apache2/error.log
ServerSignature On
</VirtualHost>
# Enable the site
sudo a2ensite munin
# reload apache
sudo /etc/init.d/apache2 reload
# Enable passwordless sudo for passenger-memory-stats
sudo bash
visudo
nobody ALL=(ALL) NOPASSWD:/usr/bin/passenger-status, /usr/bin/passenger-memory-stats
# Place the following in /usr/share/munin/plugins named passenger_stats
sudo chmod 755 /usr/share/munin/plugins/passenger_stats
# Create a symlink to /etc/munin/plugins
sudo ln -s /usr/share/munin/plugins/passenger_stats /etc/munin/plugins/passenger_stats
# Restart munin-node so it picks up the new plugin
sudo /etc/init.d/munin-node restart
# You can test the plugin by seeing if it works via telnet
telnet localhost 4949
fetch passenger_stats
##--- Passenger memory-stats plugin below:
#!/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
END
exit 0
end
def output_values
status = `sudo /usr/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
## Password protect munin directory
sudo vi /var/www/munin/.htaccess
AuthType Basic
AuthName "Members Only"
AuthUserFile /var/www/munin/.htpasswd
<limit GET PUT POST>
require valid-user
</limit>
# create the htaccess file
sudo htpasswd -c /var/www/munin/.htpasswd admin
# NOTE: if the password protection isn't working, check that AllowOverride is not set to None in apache config or vhosts file (set to all).
if munin still isn't working, try running the processes as the munin user in debug mode:
su
su -s /bin/bash munin
cd /usr/share/munin
/usr/share/munin/munin-update --debug
/usr/share/munin/munin-graph --debug
/usr/share/munin/munin-html --debug
# if trying to monitor a remote server, might need to add following to /etc/munin/munin-node.conf
allow ^65\.207\.128\.20$ #ip of server that is trying to connect
sudo /etc/init.d/munin-node restart
if crontab isn't running try restarting cron
sudo /etc/init.d/cron restart
# if that doesn't work, try manually entering it as per:
http://www.freebsdmadeeasy.com/tutorials/web-server/monitoring-with-munin.php
su
su -s /bin/bash munin
*/5 * * * * /usr/bin/munin-cron
########## Install postgres monitoring ########
sudo aptitude install libdbd-pg-perl
cd ~/src
wget http://pgfoundry.org/frs/download.php/2096/muninpgplugins-0.2.2.tar.gz
tar xvzf muninpgplugins-*.tar.gz
cd muninpgplugins*
# Configure postgres to allow monitoring: put the following in postgresql.conf (sudo vim /etc/postgresql/8.3/main/postgresql.conf)
# NOTE: don't think this step is needed anymore
#stats_start_collector = true
#stats_block_level = true
sudo /etc/init.d/postgresql-8.3 restart
cd ~/src/muninpgplugins
./install.sh database_production # this will output the symlinks and config that you need
# finally restart munin node
sudo /etc/init.d/munin-node restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment