Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I try to run some Munin plugins written in Ruby. I would like to use RVM, so Munin needs to know where to find Ruby. I tried to change the line calling munin-cron in the cron file as follows:

*/5 * * * *     munin bash -c 'source /usr/local/lib/rvm && rvm 1.9.2@munin && /usr/bin/munin-cron'

This leads to error messages in munin-node.log, saying

/usr/bin/env: ruby: No such file or directory

When I change the plugins' shebangs to the actual path of the Ruby executable it works, but the RVM environment should be set so that '/usr/bin/env ruby' works. It does when I execute the plugins as root.

Any ideas?

Update 1

Since Munin seems to reset the environment when executing the plugins, I tried to set the plugins' shebangs to the RVM wrapper script, I created with

rvm wrapper 1.9.2@munin munin

Now I get several "command not found" errors on variable names, implying that the plugins now are interpreted by the shell instead of Ruby.

Update 2

Copying the wrapper script instead of the symlink rvm creates and adding

source /usr/local/lib/rvm

doesn't help either.

share|improve this question

2 Answers 2

up vote 2 down vote accepted

I finally figured it out. Forget everything I did so far, trying to make this work. After creating the wrapper script with

rvm wrapper 1.9.2@munin munin

I only had to add the command attribute to the configuration of the plugin in question in /etc/munin/plugin-conf.d/munin-node:

[my_plugin]
group rvm
command /usr/local/rvm/bin/munin_ruby %c

Now I can use my munin gemset or create a separate gemset for each plugin.

share|improve this answer

Like the error message says, env is being called with the argument ruby, but it can't find anything called ruby to execute. That means when env runs, the path is not set up correctly to find the ruby executable. I assume that is configured in /usr/local/lib/rvm. Try running it outside of the cronjob, does it work? For example:

bash -c 'source /usr/local/lib/rvm rvm 1.9.2@munin && /usr/bin/munin-cron'

Try also calling bash with the -x argument so it outputs all commands to stderr as it executes them (bash -xc 'blah'). That should help you figure out where things are going wrong.

Grep through /usr/local/lib/rvm and see where it's calling env, and then work back from there to determine why the $PATH is not set correctly when env is called.

share|improve this answer
    
Good hint with the -x flag. It shows that the environment is set up correctly. Munin seems to reset it when executing the plugins. –  rausch Jan 15 '11 at 13:41

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.