NRPE - Environment Variable

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
paulol
Posts: 159
Joined: Wed Jul 02, 2014 11:39 am

NRPE - Environment Variable

Post by paulol »

Hi there, i'm triyng to set a new path in $PATH variable in /etc/sysconfig/nrpe to NRPE. But it doesn't work...

Code: Select all

vim /etc/sysconfig/nrpe

PATH="/usr/local/rvm/gems/ruby-2.1.5/bin:/usr/local/rvm/gems/ruby-2.1.5@global/bin:/usr/local/rvm/rubies/ruby-2.1.5/bin:/usr/local/rvm/gems/ruby-2.1.5/bin:/usr/local/rvm/gems/ruby-2.1.5@global/bin:/usr/local/rvm/rubies/ruby-2.1.5/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/rvm/bin:/root/bin"
GEM_HOME='/usr/local/rvm/gems/ruby-2.1.5'
GEM_PATH='/usr/local/rvm/gems/ruby-2.1.5:/usr/local/rvm/gems/ruby-2.1.5@global'
MY_RUBY_HOME='/usr/local/rvm/rubies/ruby-2.1.5'
IRBRC='/usr/local/rvm/rubies/ruby-2.1.5/.irbrc'
RUBY_VERSION='ruby-2.1.5'

Code: Select all

vim /usr/lib/systemd/system/nagios.service

[Install]
WantedBy=multi-user.target

[Service]
Type=simple
Restart=on-abort
PIDFile=/usr/local/nagios/var/nrpe.pid
RuntimeDirectory=nrpe
RuntimeDirectoryMode=0755
EnvironmentFile=-/etc/sysconfig/nrpe
ExecStart=/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -f
ExecReload=/bin/kill -HUP $MAINPID
ExecStopPost=/bin/rm -f /usr/local/nagios/var/nrpe.pid
TimeoutStopSec=60
User=nagios
Group=nagios
PrivateTmp=true
OOMScoreAdjust=-500

Code: Select all

vim /usr/loca/nagios/etc/nrpe.cfg

command[echo_foo]=/usr/bin/env; exit 0
command[echo_foo2]=/usr/bin/echo $PATH; exit 0

Code: Select all

[root@TREVOUX libexec]# ./check_nrpe -H 127.0.0.1 -c echo_foo2
/usr/bin:/bin:/usr/sbin:/sbin
[root@TREVOUX libexec]# ./check_nrpe -H 127.0.0.1 -c echo_foo
MAIL=/var/mail/root
PATH=/sbin:/bin:/usr/sbin:/usr/bin
LOGNAME=root
USER=root
USERNAME=root
HOME=/root
SHELL=/bin/bash
TERM=unknown
SUDO_COMMAND=/usr/bin/env
SUDO_USER=nagios
SUDO_UID=2043654
SUDO_GID=1000
XDG_SESSION_ID=c368892
XDG_RUNTIME_DIR=/run/user/0
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: NRPE - Environment Variable

Post by lmiltchev »

EnvironmentFile=-/etc/sysconfig/nrpe
Is this a typo? You have "-" in front of the path...
Be sure to check out our Knowledgebase for helpful articles and solutions!
paulol
Posts: 159
Joined: Wed Jul 02, 2014 11:39 am

Re: NRPE - Environment Variable

Post by paulol »

I found a solution.

I removed this variable EnvironmentFile=-/etc/sysconfig/nrpe and I configured the nrpe.cfg to do the following:

Code: Select all

command[check_amazon_metrics]=source /etc/sysconfig/nrpe; rvmsudo /usr/local/nagios/libexec/Amazon/nagios-cloudwatch-master/check_cloudwatch.rb $ARG1$ -C config_app.yml
and I commented in the following line:

Code: Select all

#command_prefix=/usr/bin/sudo
and I configured the /etc/sysconfig/nrpe like this:

Code: Select all

PATH="/usr/local/rvm/gems/ruby-2.1.5/bin:/usr/local/rvm/gems/ruby-2.1.5@global/bin:/usr/local/rvm/rubies/ruby-2.1.5/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/rvm/bin"
export GEM_HOME='/usr/local/rvm/gems/ruby-2.1.5'
export GEM_PATH='/usr/local/rvm/gems/ruby-2.1.5:/usr/local/rvm/gems/ruby-2.1.5@global'
export MY_RUBY_HOME='/usr/local/rvm/rubies/ruby-2.1.5'
export IRBRC='/usr/local/rvm/rubies/ruby-2.1.5/.irbrc'
export RUBY_VERSION='ruby-2.1.5'
User avatar
mbellerue
Posts: 1403
Joined: Fri Jul 12, 2019 11:10 am

Re: NRPE - Environment Variable

Post by mbellerue »

Excellent! Thank you for posting the solution. Closing thread.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked