Page 1 of 1

Nagios enviroment variables for Oracle

Posted: Tue Jun 23, 2015 1:35 pm
by whitest
Hi everyone! Could somebody help me?
I use check_oracle_health and check_sql_query plugins for Oracle monitoring. Everything works fine, but after reboot Nagios server they can't see Envirement variables (TNS_ADMIN, ORACLE_HOME and etc.). Therefore in web interface I see CRITICAL errors. For example TNSPING in web interface returns: "CRITICAL - cannot connect to storacle. Died ."

Every time after reboot I have to restart nagios service (/etc/init.d/nagios restart) manually, then Nagios can see oracles again.

At the same time I can sqlplus to oracles under user nagios from SSH withot restart nagios-service. Mentioned above scripts work fine from command-line after reboot also, but in Web interface shows it's cannot connect to oracles.
-bash-3.2$ ./check_oracle_health --mode tnsping --connect ebpp --user nagios --password nagmonpw --method sqlplus
OK - connection established to ebpp.
I set oracle variables via startup script oracle.sh:

Code: Select all

# cat [b]/etc/profile.d/oracle.sh[/b]
#!/bin/bash
 export ORACLE_HOME=/usr/lib/oracle/11.2/client
 export PATH=$PATH:$ORACLE_HOME/bin
 export LD_LIBRARY_PATH=$ORACLE_HOME/lib
 export TNS_ADMIN=$ORACLE_HOME
Here is my ENV after reboot under nagios user:

Code: Select all

-bash-3.2$ env
HOSTNAME=nagios.corp.domain.loc
TERM=xterm
SHELL=/bin/bash
HISTSIZE=1000
MIBDIRS=/usr/local/share/snmp/mibs
SSH_TTY=/dev/pts/0
USER=nagios
[b]LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client/lib[/b]
LS_COLORS=no=00:fi=00:di=00;34:ln=00;36:pi=40;33:so=00;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=00;32:*.cmd=00;32:*.exe=00;32:*.com=00;32:*.btm=00;32:*.bat=00;32:*.sh=00;32:*.csh=00;32:*.tar=00;31:*.tgz=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.zip=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.bz=00;31:*.tz=00;31:*.rpm=00;31:*.cpio=00;31:*.jpg=00;35:*.gif=00;35:*.bmp=00;35:*.xbm=00;35:*.xpm=00;35:*.png=00;35:*.tif=00;35:
SNMPCONFPATH=/etc/snmp/snmp.conf
[b]TNS_ADMIN=/usr/lib/oracle/11.2/client[/b]
MAIL=/var/spool/mail/nagios
[b]PATH=/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/lib/oracle/11.2/client/bin[/b]
INPUTRC=/etc/inputrc
PWD=/home/nagios
EDITOR=/bin/vi
LANG=en_US.UTF-8
SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass
SHLVL=1
HOME=/home/nagios
LOGNAME=nagios
CVS_RSH=ssh
LESSOPEN=|/usr/bin/lesspipe.sh %s
[b]ORACLE_HOME=/usr/lib/oracle/11.2/client[/b]
G_BROKEN_FILENAMES=1
_=/bin/env
Oracle 11 g2 client installed on Nagios (4.0.8) server. OS Centos 5.11 x386.

Re: Nagios enviroment variables for Oracle

Posted: Tue Jun 23, 2015 1:57 pm
by tgriep
What you did already is the way to set the environment globally on your system but the other way is to edit the check commands and put the path to where the Oracle environments are in the command.
The example below is how it is done.

Code: Select all

define command {
       command_name                             check_oracle_db
      /usr/bin/env LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client64/lib ORACLE_HOME=/usr/lib/oracle/12.1/client64 TNSADMIN=/usr/lib/oracle/12.1/client64/network/admin /usr/local/nagios/libexec/check_oracle_health --connect '$ARG1$' --username '$USER13$' --password '$USER14$' --mode $ARG2$ $ARG3$
}

Re: Nagios enviroment variables for Oracle

Posted: Wed Jun 24, 2015 10:01 am
by whitest
tgriep wrote:What you did already is the way to set the environment globally on your system but the other way is to edit the check commands and put the path to where the Oracle environments are in the command.
The example below is how it is done.

Code: Select all

define command {
       command_name                             check_oracle_db
      /usr/bin/env LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client64/lib ORACLE_HOME=/usr/lib/oracle/12.1/client64 TNSADMIN=/usr/lib/oracle/12.1/client64/network/admin /usr/local/nagios/libexec/check_oracle_health --connect '$ARG1$' --username '$USER13$' --password '$USER14$' --mode $ARG2$ $ARG3$
}
It wotks! Thank you very much!

Re: Nagios enviroment variables for Oracle

Posted: Wed Jun 24, 2015 10:04 am
by tmcdonald
I'll be closing this thread now, but feel free to open another if you need anything in the future!