没有这样的文件加载 - sensu-handler

时间:2014-07-15 23:21:44

标签: ruby gem sensu

刚开始使用Sensu并遇到以下错误,尝试测试处理程序:

/etc/sensu/handlers$ ./hipchat.rb
/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- sensu-handler (LoadError)
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
from ./hipchat.rb:4

处理程序是Hipchat handler from Github。我有处理程序hipchat.rb和hipchat.json在同一目录(/ etc / sensu / handlers)中,API键和房间设置,但当我故意触发应该触发的严重错误时,没有消息出现:

 {"timestamp":"2014-07-15T22:32:38.936944+0000","level":"info","message":"handling event","event":{"client":{"name":"foo.bar.com","address":"10.101.105.41","subscriptions":["test","webservers","base"],"timestamp":1405463543},"check":{"handlers":["default","hipchat"],"command":"/etc/sensu/plugins/check-procs.rb -p cron -C 1 ","interval":60,"subscribers":["webservers"],"name":"cron_check","issued":1405463558,"executed":1405463558,"output":"CheckProcs CRITICAL: Found 0 matching processes; cmd /cron/\n","status":2,"duration":0.571,"history":["0","0","0","0","0","0","0","0","0","2","2","2","2","2","2","2","2","2","2","2","2"]},"occurrences":12,"action":"create"},"handler":{"type":"pipe","command":"cat","name":"stdout"}}

 $ which -a ruby
 /usr/bin/ruby
 $ which gem
 /usr/bin/gem
 $ ruby --version
 ruby 1.8.7 (2010-01-10 patchlevel 249) [x86_64-linux]
 $ lsb_release -a
 Description:   Ubuntu 10.04.4 LTS
 Codename:  lucid

其他感觉似乎很愉快。如果我设置EMBEDDED_RUBY = true并运行

$ /opt/sensu/embedded/bin/ruby hipchat.rb

我没有输出,但是当我退出ruby时,我得到了:

^C/opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-0.3.0/lib/sensu-plugin/utils.rb:23:in `read': Interrupt
from /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-0.3.0/lib/sensu-plugin/utils.rb:23:in `read_event'
from /opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugin-0.3.0/lib/sensu-handler.rb:53:in `block in <class:Handler>'
/opt/sensu/embedded/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:53:in `require': cannot load such file -- hipchat (LoadError)
from /opt/sensu/embedded/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:53:in `require'
from hipchat.rb:5:in `<main>'

显然,Ruby不是我的第一语言 我需要做些什么才能让Ruby找到/使用sensu-handler?

编辑:

在sensu服务器日志中也注意到这一点:

 {"timestamp":"2014-07-15T23:33:17.827369+0000","level":"info","message":"handler output","handler":{"type":"pipe","command":"/etc/sensu/handlers/hipchat.rb","severities":["critical","ok"],"name":"hipchat"},"output":"/opt/sensu/embedded/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:53:in `require': cannot load such file -- hipchat (LoadError)\n"}

hipchat.rb指的是什么时候它试图在第5行要求'hipchat'? hipchat.json?

2 个答案:

答案 0 :(得分:3)

由于没有人通过回答问题获得免费积分。答案是:

使用Sensu的嵌入式Ruby安装Hipchat gem:

sudo /opt/sensu/embedded/bin/gem install hipchat

在任何地方都提到有一个Hipchat宝石,会不会很好。正如我所提到的,我是Ruby的新手,所以这是不明显的。

至于非Sensu Ruby问题,看起来我只需要找到一种安装Ruby 1.9的方法。

答案 1 :(得分:0)

我遇到了类似的问题,但是使用了sensu邮件程序。我发现它必须与rvm不能搭配嵌入式sensu ruby​​。基本上,我不得不使用系统ruby重新安装sensu主服务器和rvm。

rvm --default use system

重新安装sensu后,我能够安装实际安装到sensu嵌入式ruby gem文件夹中的所需宝石。

/opt/sensu/embedded/bin/gem install mail --no-ri --no-rdoc -v 2.5.4