Category: Hosting

Making Munin work with Mysql on Debian

Easier than I thought (all stuff as SU or using SUDO):

First we need to install some Mysql-Munin perl libraries:

apt-get install libipc-sharelite-perl

Also some Perl stuff will be needed:

perl -MCPAN -eshell
install IPC::ShareLite

Next let's activate Munin Mysql plugin:

# Assuming you have already installed both munin & mysql
ln -s /usr/share/munin/plugins/mysql_* /etc/munin/plugins

Create a user for a Mysql database (so Munin will be able to get stats as this user):

mysql> CREATE USER `munin` @`localhost` IDENTIFIED BY 'somepassword';
mysql> GRANT SUPER ON *.* TO `munin` @`localhost`;
mysql> FLUSH PRIVILEGES;

Edit /etc/munin/plugin-conf.d/munin-node file and find [mysql*] section:

[mysql*]
user root
env.mysqlopts --defaults-file=/etc/mysql/debian.cnf
env.mysqluser munin

Let's also disable WARN: MySQL InnoDB free tablespace information (in most cases it is not valid):

Create a file /etc/munin/plugin-conf.d/mysql_innodb and place following lines into it:

[mysql_innodb]
env.warning 0
env.critical 0

or if You don't need InnoDB part, just turn it off by removing the symlink:

rm /etc/munin/plugins/mysql_innodb

Restart both Apache & Munin:

/etc/init.d/apache2 restart
/etc/init.d/munin-node restart
su munin -c /usr/bin/munin-cron

Wait until charts regenerate and You're ready to go! Example (generated for the first time):

Ruby, Mongoid and (again) memory leaks – next Identity map problem

Lately I've fixed an issue with Mongoid driver (read more about this). Memory consumption stabilized at a relatively low level until... gem update mongo. Below you can see Munin memory and CPU consumption charts from a frontend server (frontend only presents data):

There were some heavy issues on october 23d. Server went really crazy. Behavior was similar to one mentioned in previous post about Mongoid. But IdentityMap has been turned off so WTF? Well I don't know what happend, but what do I know is how to fix it. Edit your Padrino/Sinatra app file (app/app.rb) and place this in your project class:

after do
  Mongoid::IdentityMap.clear
end

This will clear IdentityMap after each request.

I know, that this is not the best solution, however it is good enough for me - and what's more important - it works fine.

Copyright © 2025 Closer to Code

Theme by Anders NorenUp ↑