After playing some more with my installation, I figured that my plugin actually works when I run it manually (executing something shell command like sh -c "/usr/bin/env ruby my_plugin.rb"
). However, when Sensu tries to run the same check I’m getting the same issue described above.
Here’s the state of ENV
when Sensu runs the check:
{"RUBY_MAJOR"=>"2.7", "HOSTNAME"=>"8fb9f4bac467", "LD_LIBRARY_PATH"=>"/var/cache/sensu/sensu-agent/505cf2f8cabbcf8be64149a522d9080025366cc2d5ccafe38e842131e37234a46811a2126b3480c1b9f4faa1912984be5fb9a9aca7b456027ccd5df964c56792/lib::", "SHLVL"=>"1", "HOME"=>"/root", "BUNDLE_APP_CONFIG"=>"/usr/local/bundle", "RUBY_VERSION"=>"2.7.0", "PATH"=>"/var/cache/sensu/sensu-agent/505cf2f8cabbcf8be64149a522d9080025366cc2d5ccafe38e842131e37234a46811a2126b3480c1b9f4faa1912984be5fb9a9aca7b456027ccd5df964c56792/bin:/usr/local/bundle/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/bundle/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", "GEM_HOME"=>"/usr/local/bundle", "RUBY_DOWNLOAD_SHA256"=>"27d350a52a02b53034ca0794efe518667d558f152656c2baaf08f3d0c8b02343", "PWD"=>"/root", "BUNDLE_SILENCE_ROOT_WARNING"=>"1", "CPATH"=>"/var/cache/sensu/sensu-agent/505cf2f8cabbcf8be64149a522d9080025366cc2d5ccafe38e842131e37234a46811a2126b3480c1b9f4faa1912984be5fb9a9aca7b456027ccd5df964c56792/include::"}
Here’s ENV
when I run it manually:
{"RUBY_MAJOR"=>"2.7", "HOSTNAME"=>"8fb9f4bac467", "SHLVL"=>"2", "HOME"=>"/root", "OLDPWD"=>"/root", "BUNDLE_APP_CONFIG"=>"/usr/local/bundle", "RUBY_VERSION"=>"2.7.0", "TERM"=>"xterm", "PATH"=>"/usr/local/bundle/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", "GEM_HOME"=>"/usr/local/bundle", "RUBY_DOWNLOAD_SHA256"=>"27d350a52a02b53034ca0794efe518667d558f152656c2baaf08f3d0c8b02343", "PWD"=>"/var/cache/sensu/sensu-agent/505cf2f8cabbcf8be64149a522d9080025366cc2d5ccafe38e842131e37234a46811a2126b3480c1b9f4faa1912984be5fb9a9aca7b456027ccd5df964c56792/bin", "BUNDLE_SILENCE_ROOT_WARNING"=>"1"}
And here’s the error:
/usr/local/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require': Error loading shared library libssl.so.10: No such file or directory (needed by /var/cache/sensu/sensu-agent/505cf2f8cabbcf8be64149a522d9080025366cc2d5ccafe38e842131e37234a46811a2126b3480c1b9f4faa1912984be5fb9a9aca7b456027ccd5df964c56792/lib/libpq.so.5) - /usr/local/bundle/gems/pg-1.2.1/lib/pg_ext.so (LoadError)
from /usr/local/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'
from /usr/local/bundle/gems/pg-1.2.1/lib/pg.rb:5:in `<top (required)>'
from /usr/local/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:168:in `require'
from /usr/local/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:168:in `rescue in require'
from /usr/local/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:156:in `require'
from /var/cache/sensu/sensu-agent/505cf2f8cabbcf8be64149a522d9080025366cc2d5ccafe38e842131e37234a46811a2126b3480c1b9f4faa1912984be5fb9a9aca7b456027ccd5df964c56792/bin/db_helpers.rb:3:in `<top (required)>'
from /var/cache/sensu/sensu-agent/505cf2f8cabbcf8be64149a522d9080025366cc2d5ccafe38e842131e37234a46811a2126b3480c1b9f4faa1912984be5fb9a9aca7b456027ccd5df964c56792/bin/ratio_check.rb:10:in `require_relative'
from /var/cache/sensu/sensu-agent/505cf2f8cabbcf8be64149a522d9080025366cc2d5ccafe38e842131e37234a46811a2126b3480c1b9f4faa1912984be5fb9a9aca7b456027ccd5df964c56792/bin/ratio_check.rb:10:in `<main>'
/usr/local/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require': cannot load such file -- pg (LoadError)
from /usr/local/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'
from /var/cache/sensu/sensu-agent/505cf2f8cabbcf8be64149a522d9080025366cc2d5ccafe38e842131e37234a46811a2126b3480c1b9f4faa1912984be5fb9a9aca7b456027ccd5df964c56792/bin/db_helpers.rb:3:in `<top (required)>'
from /var/cache/sensu/sensu-agent/505cf2f8cabbcf8be64149a522d9080025366cc2d5ccafe38e842131e37234a46811a2126b3480c1b9f4faa1912984be5fb9a9aca7b456027ccd5df964c56792/bin/ratio_check.rb:10:in `require_relative'
from /var/cache/sensu/sensu-agent/505cf2f8cabbcf8be64149a522d9080025366cc2d5ccafe38e842131e37234a46811a2126b3480c1b9f4faa1912984be5fb9a9aca7b456027ccd5df964c56792/bin/ratio_check.rb:10:in `<main>'