Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sudo check-barman "no such file to load -- rbarman" #2

Closed
bernard-c opened this issue Apr 24, 2014 · 7 comments
Closed

Sudo check-barman "no such file to load -- rbarman" #2

bernard-c opened this issue Apr 24, 2014 · 7 comments

Comments

@bernard-c
Copy link

Hello,

I have an error when I try to execute the check with the user nagios and sudo :

-sh-4.1$ whoami
nagios
-sh-4.1$ sudo /usr/lib64/nagios/plugins/check-barman/check-barman.rb -a pg -h /opt/data/MSA/barman -s KBILL-SAP
/usr/lib64/nagios/plugins/check-barman/check-barman.rb:26:in `require': no such file to load -- rbarman (LoadError)
from /usr/lib64/nagios/plugins/check-barman/check-barman.rb:26

However, I have the rbarman gem installed :

-sh-4.1$ gem list rbarman

*** LOCAL GEMS ***

rbarman (0.0.13, 0.0.12)

And in sudoers file, I followed your advice and I added these lines :

Defaults:nagios !requiretty
nagios ALL=NOPASSWD: /usr/lib64/nagios/plugins/check-barman/check-barman.rb

And when I list gem with the command sudo, I also add rbarman gem :

-sh-4.1$ sudo gem list rbarman

*** LOCAL GEMS ***

rbarman (0.0.13, 0.0.12)

Isn't there something missing in your documentation to use check-barman with sudo command and nagios user?

@hamann
Copy link
Owner

hamann commented Apr 24, 2014

What do you get if you execute it without sudo?

@bernard-c
Copy link
Author

-sh-4.1$ /usr/lib64/nagios/plugins/check-barman/check-barman.rb -a pg -h /opt/data/MSA/barman -s KBILL-SAP
/usr/local/rvm/gems/ruby-2.1.0/gems/mixlib-shellout-1.3.0/lib/mixlib/shellout.rb:253:in invalid!': Expected process to exit with [0], but received '1' (Mixlib::ShellOut::ShellCommandFailed) ---- Begin output of /usr/bin/barman show-server KBILL-SAP ---- STDOUT: STDERR: ERROR: please run barman as 'barman' user ---- End output of /usr/bin/barman show-server KBILL-SAP ---- Ran /usr/bin/barman show-server KBILL-SAP returned 1 from /usr/local/rvm/gems/ruby-2.1.0/gems/mixlib-shellout-1.3.0/lib/mixlib/shellout.rb:239:inerror!'
from /usr/local/rvm/gems/ruby-2.1.0/gems/rbarman-0.0.13/lib/rbarman/cli_command.rb:345:in run_barman_command' from /usr/local/rvm/gems/ruby-2.1.0/gems/rbarman-0.0.13/lib/rbarman/cli_command.rb:88:inserver'
from /usr/local/rvm/gems/ruby-2.1.0/gems/rbarman-0.0.13/lib/rbarman/server.rb:65:in by_name' from /usr/lib64/nagios/plugins/check-barman/check-barman.rb:56:incheck_pg'
from /usr/lib64/nagios/plugins/check-barman/check-barman.rb:196:in `

'
-sh-4.1$ vim /usr/lib64/nagios/plugins/check-barman/check-barman.rb

Because, I do not have the right to execute 'barman' with nagios user :

-sh-4.1$ barman status KBILL-SAP
ERROR: please run barman as 'barman' user

I can execute barman with sudo, but it's not compatible with your code :)

-sh-4.1$ sudo /usr/bin/barman status KBILL-SAP
Server KBILL-SAP:
Description: KBILL-SAP PostgreSQL Database
...

@hamann
Copy link
Owner

hamann commented Apr 24, 2014

Yes, that's ok, just wanted to know if gem could be found. So it seems to be a problem with sudo.
Could you paste your /etc/sudoers? Which distribution?

@hamann
Copy link
Owner

hamann commented Apr 24, 2014

You're using rvm?

@hamann
Copy link
Owner

hamann commented Apr 24, 2014

I'm not familiar with rvm, but you should have a look at https://rvm.io/integration/sudo

@bernard-c
Copy link
Author

Thank you, this link https://rvm.io/integration/sudo helped me.

I added this line on sudoers file :

Defaults env_keep +="rvm_bin_path GEM_HOME IRBRC MY_RUBY_HOME rvm_path rvm_prefix rvm_version GEM_PATH rvmsudo_secure_path RUBY_VERSION rvm_ruby_string rvm_delete_flag PATH"

And commented out this :

Defaults secure_path

Then, I added this line on bash_profile user :

export rvmsudo_secure_path=0

And, with rvmsudo command, I can execute the plugin to check barman :

-sh-4.1$ rvmsudo /usr/lib64/nagios/plugins/check-barman/check-barman.rb -a pg -h /opt/data/MSA/barman -s KBILL-SAP
PG connection ok

Thank you for your help !

@hamann
Copy link
Owner

hamann commented Apr 24, 2014

Alright

@hamann hamann closed this as completed Apr 24, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants