# embedded Ruby vs. system Ruby

**URL:** <https://discourse.sensu.io/t/embedded-ruby-vs-system-ruby/242>\
**Category:** Sensu Classic (EOL)\
**Created:** [August 29, 2014, 5:59pm UTC](https://discourse.sensu.io/t/embedded-ruby-vs-system-ruby/242 "2014-08-29T17:59:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Florin\_Andrei](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.sensu.io/florin_andrei/32/674_2.png) [@Florin\_Andrei](https://discourse.sensu.io/u/Florin_Andrei)\
**Post date:** [August 29, 2014, 5:59pm UTC](https://discourse.sensu.io/t/embedded-ruby-vs-system-ruby/242/1 "2014-08-29T17:59:13Z")

</div>

I’m evaluating Sensu for production.

I’ve started with a pretty minimal install of Ubuntu 14.04 Server, and followed the docs on the Sensu website to install Sensu (BTW, the docs are very helpful). I didn’t even have Ruby installed initially, but Sensu appears to include its own Ruby (version 2.0.0 or something) in the .deb package. Eventually I did install the system Ruby afterwards (version 1.9.3).

I’m getting this error in the client log:

{“timestamp”:“2014-08-29T10:34:35.827841-0700”,“level”:“info”,“message”:“received check request”,“check”:{“name”:“cron\_check”,“issued”:1409333674,“command”:"/etc/sensu/plugins/check-procs.rb -p crond -C 1 "}}

{“timestamp”:“2014-08-29T10:34:35.879048-0700”,“level”:“info”,“message”:“publishing check result”,“payload”:{“client”:“client1”,“check”:{“name”:“cron\_check”,“issued”:1409333674,“command”:"/etc/sensu/plugins/check-procs.rb -p crond -C 1 “,“executed”:1409333675,“duration”:0.051,“output”:”/usr/lib/ruby/1.9.1/rubygems/custom\_require.rb:36:in `require': cannot load such file -- sensu-plugin/check/cli (LoadError)\n\tfrom /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in`require’\n\tfrom /etc/sensu/plugins/check-procs.rb:29:in `’\n",“status”:1}}}

I’ve tried to run that plugin manually but I got the same thing:

$ /etc/sensu/plugins/check-procs.rb -p crond -C 1

/usr/lib/ruby/1.9.1/rubygems/custom\_require.rb:36:in `require’: cannot load such file – sensu-plugin/check/cli (LoadError)

```
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'

from /etc/sensu/plugins/check-procs.rb:29:in `<main>'

```

According to the FAQ, I switched EMBEDDED\_RUBY to true and restarted the client. That seemed to have killed the error:

{“timestamp”:“2014-08-29T10:46:35.772363-0700”,“level”:“info”,“message”:“received check request”,“check”:{“name”:“cron\_check”,“issued”:1409334394,“command”:"/etc/sensu/plugins/check-procs.rb -p crond -C 1 "}}

{“timestamp”:“2014-08-29T10:46:35.888243-0700”,“level”:“info”,“message”:“publishing check result”,“payload”:{“client”:“client1”,“check”:{“name”:“cron\_check”,“issued”:1409334394,“command”:"/etc/sensu/plugins/check-procs.rb -p crond -C 1 ",“executed”:1409334395,“duration”:0.116,“output”:“CheckProcs CRITICAL: Found 0 matching processes; cmd /crond/\n”,“status”:2}}}

But my question is - if the embedded Ruby seems to be preferred, why is EMBEDDED\_RUBY not already made true?

And, of course, that still doesn’t solve the problem of running Sensu plugins manually - I still get that error when I run the plugin standalone. What can I do to fix that - add the embedded Ruby to the shell PATH before anything else?

---

<div class="post-metadata">

**Author:** ![Kyle\_Anderson](https://avatars.discourse-cdn.com/v4/letter/k/e5b9ba/32.png) [@Kyle\_Anderson](https://discourse.sensu.io/u/Kyle_Anderson)\
**Post date:** [August 30, 2014, 5:03am UTC](https://discourse.sensu.io/t/embedded-ruby-vs-system-ruby/242/2 "2014-08-30T05:03:58Z")

</div>

I don't know if it is preferred globally, it can be confusing if you  
are not aware of it, which is probably why it is off by default  
(principle of least surprise).

Using the embedded ruby does give you the benefit of using Sensu's  
ruby, but it also makes it a little less obvious on how to get more  
gems installed.  
Then, what happens when you start messing up the available gems in the  
sensu ruby?

I personally leave the Sensu ruby alone, so I can't possibly break it.  
The sensu-omnibus package owns those files. I can install gems  
normally by other means if I need them. (into other locations)

Yes, you can set the #! in any ruby script to use the embeded ruby  
directly to take advantage of it on a case-by-case basis.  
If you want to run in that envinroment for manual testing, you can do  
what the init script does yourself:

set\_sensu\_paths() {  
&nbsp;&nbsp;&nbsp;&nbsp;if ["x$EMBEDDED\_RUBY" = "xtrue"]; then  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;export PATH=/opt/sensu/embedded/bin:$PATH:$PLUGINS\_DIR:$HANDLERS\_DIR  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;export GEM\_PATH=/opt/sensu/embedded/lib/ruby/gems/2.0.0:$GEM\_PATH  
&nbsp;&nbsp;&nbsp;&nbsp;else  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;export PATH=$PATH:$PLUGINS\_DIR:$HANDLERS\_DIR  
&nbsp;&nbsp;&nbsp;&nbsp;fi  
}

Or I think you can just say

/opt/sensu/embedded/bin/ruby your-script.rb

> **···**
>
> On Fri, Aug 29, 2014 at 10:59 AM, Florin Andrei \<florin.andrei@gmail.com\> wrote:
> 
> > I'm evaluating Sensu for production.
> > 
> > I've started with a pretty minimal install of Ubuntu 14.04 Server, and  
> > followed the docs on the Sensu website to install Sensu (BTW, the docs are  
> > very helpful). I didn't even have Ruby installed initially, but Sensu  
> > appears to include its own Ruby (version 2.0.0 or something) in the .deb  
> > package. Eventually I did install the system Ruby afterwards (version  
> > 1.9.3).
> > 
> > I'm getting this error in the client log:
> > 
> > {"timestamp":"2014-08-29T10:34:35.827841-0700","level":"info","message":"received  
> > check  
> > request","check":{"name":"cron\_check","issued":1409333674,"command":"/etc/sensu/plugins/check-procs.rb  
> > -p crond -C 1 "}}  
> > {"timestamp":"2014-08-29T10:34:35.879048-0700","level":"info","message":"publishing  
> > check  
> > result","payload":{"client":"client1","check":{"name":"cron\_check","issued":1409333674,"command":"/etc/sensu/plugins/check-procs.rb  
> > -p crond -C 1  
> > ","executed":1409333675,"duration":0.051,"output":"/usr/lib/ruby/1.9.1/rubygems/custom\_require.rb:36:in  
> > `require': cannot load such file -- sensu-plugin/check/cli  
> > (LoadError)\n\tfrom /usr/lib/ruby/1.9.1/rubygems/custom\_require.rb:36:in  
> > `require'\n\tfrom /etc/sensu/plugins/check-procs.rb:29:in  
> > `\<main\>'\n","status":1}}}
> > 
> > I've tried to run that plugin manually but I got the same thing:
> > 
> > $ /etc/sensu/plugins/check-procs.rb -p crond -C 1  
> > /usr/lib/ruby/1.9.1/rubygems/custom\_require.rb:36:in `require': cannot load  
> > such file -- sensu-plugin/check/cli (LoadError)  
> > from /usr/lib/ruby/1.9.1/rubygems/custom\_require.rb:36:in `require'  
> > from /etc/sensu/plugins/check-procs.rb:29:in `\<main\>'
> > 
> > According to the FAQ, I switched EMBEDDED\_RUBY to true and restarted the  
> > client. That seemed to have killed the error:
> > 
> > {"timestamp":"2014-08-29T10:46:35.772363-0700","level":"info","message":"received  
> > check  
> > request","check":{"name":"cron\_check","issued":1409334394,"command":"/etc/sensu/plugins/check-procs.rb  
> > -p crond -C 1 "}}  
> > {"timestamp":"2014-08-29T10:46:35.888243-0700","level":"info","message":"publishing  
> > check  
> > result","payload":{"client":"client1","check":{"name":"cron\_check","issued":1409334394,"command":"/etc/sensu/plugins/check-procs.rb  
> > -p crond -C 1 ","executed":1409334395,"duration":0.116,"output":"CheckProcs  
> > CRITICAL: Found 0 matching processes; cmd /crond/\n","status":2}}}
> > 
> > But my question is - if the embedded Ruby seems to be preferred, why is  
> > EMBEDDED\_RUBY not already made true?
> > 
> > And, of course, that still doesn't solve the problem of running Sensu  
> > plugins manually - I still get that error when I run the plugin standalone.  
> > What can I do to fix that - add the embedded Ruby to the shell PATH before  
> > anything else?

---

<div class="post-metadata">

**Author:** ![Jesus\_Roncero](https://avatars.discourse-cdn.com/v4/letter/j/eb8c5e/32.png) [@Jesus\_Roncero](https://discourse.sensu.io/u/Jesus_Roncero)\
**Post date:** [September 2, 2014, 10:48pm UTC](https://discourse.sensu.io/t/embedded-ruby-vs-system-ruby/242/3 "2014-09-02T22:48:01Z")

</div>

Hi,

> **···**
>
> On 30/08/2014 06:03, Kyle Anderson wrote:
> 
> > I personally leave the Sensu ruby alone, so I can't possibly break it.  
> > The sensu-omnibus package owns those files. I can install gems  
> > normally by other means if I need them. (into other locations)
> > 
> > Yes, you can set the #! in any ruby script to use the embeded ruby  
> > directly to take advantage of it on a case-by-case basis.  
> > If you want to run in that envinroment for manual testing, you can do  
> > what the init script does yourself:
> 
> What I have ended up doing is creating a debian package that will install the gems needed by the embedded ruby in an external location. Then, in /etc/default/sensu I define GEM\_PATH to point to that location. This way, I use the embedded ruby but I don't mess around with the omnibus package and its gems. Seems to work fine.
> 
> J.
