Nagios enviroment variables for Oracle

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
whitest
Posts: 107
Joined: Tue Dec 30, 2014 8:16 am

Nagios enviroment variables for Oracle

Post 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.
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: Nagios enviroment variables for Oracle

Post 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$
}
Be sure to check out our Knowledgebase for helpful articles and solutions!
whitest
Posts: 107
Joined: Tue Dec 30, 2014 8:16 am

Re: Nagios enviroment variables for Oracle

Post 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!
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Nagios enviroment variables for Oracle

Post by tmcdonald »

I'll be closing this thread now, but feel free to open another if you need anything in the future!
Former Nagios employee
Locked