Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nagios doesn't get exports from /etc/profile

I've got Nagios and Oracle sqlplus client installed on my server. Sqlplus needs few environment variables for its run, so I added exports to /etc/profile.
Login as root sets variables right, login as user nagios sets is also OK but when I run some checks from nagios web interface (these checks are written in bash), they end with an error Error: Empty result from sqlplus. Check plugin settings and Oracle status.
When I run these checks from terminal as root or as nagios user, everything is OK, that's how I found out that problem is in env variables.

I will be glad for any suggestions.

like image 997
Jakub Turcovsky Avatar asked Dec 03 '25 16:12

Jakub Turcovsky


2 Answers

I found that is a bug from nagios, you can check documentation from this link.

You will find in file /etc/init.d/nagios this code.

# Load any extra environment variables for Nagios and its plugins
if test -f /etc/sysconfig/nagios; then
       . /etc/sysconfig/nagios
fi

Just create the file nagios on the /etc/sysconfig/ path for Fedora or rhel with the extra variables that you need. on case.

[root@server sysconfig]# cat nagios 
export ORACLE_HOME=/usr/lib/oracle/11.2/client64
export TNS_ADMIN=$ORACLE_HOME/network/admin
export PATH=$PATH:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib

and that's it.

Best regard Marco.

like image 143
Marco Avatar answered Dec 06 '25 13:12

Marco


It is the same issue with the NRPE as Marco mentionned before.

you have to add the environement variables into /etc/sysconfig/nrpe then you have to restart nrpe : service nrpe restart

Thanks Youssef

like image 37
Youssef ASEBRIY Avatar answered Dec 06 '25 12:12

Youssef ASEBRIY



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!