Check_oracle with director

Hi, I’m trying to define the check_oracle command with the director. When I run the command in terminal, it resolves fine but icinga web shows “cannot determine oracle_home for sid…”.
what could it be?
thanks

you need to inject the oracle env_vars.

Hi, I have the same problem.
Could you explain me ho to inject oracle variables into the service template from Director?

Thanks a lor
Mario

I would do it in the service with systemctl edit icinga2.service or use a wrapper for the check but if you must use the director go to fields and set it via DSL.

Wrapper example:

#!/usr/bin/env bash
export TNS_ADMIN=/etc/icinga2/plugin-configs
export ORACLE_HOME=/usr/lib/oracle/12.1/client64/lib
export LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client64/lib

/opt/python_cx_Oracle/bin/python /usr/lib64/nagios/plugins/check_ora "$@"

In Icinga Director I see:

and, at the end:
}
vars.check_ipv4 = false
vars.check_ipv6 = false
vars.oracle_health_commit = false
vars.oracle_health_ident = false
vars.oracle_health_noperfdata = false
vars.oracle_health_notemp = false
vars.oracle_health_regexp = false
vars.oracle_health_report = “long”
vars.oracle_home = “/usr/lib/oracle/11.2/client64/lib”
vars.oracle_ld_library_path = “/usr/lib/oracle/11.2/client64/lib”
vars.oracle_tns_admin = “/etc/icinga2/plugin-configs”
}

Perhaps I have to cheange that entries.

But I am not able to understand how to modify it.

So, have I to change in field of Director?
Thanks for your help

External object means, it’s a file in your icinga2 config somewhere under /etc/icinga2/. Just edit the file and re import it into the director.

Yes, I have found the command in:
/usr/share/icinga2/include/plugins-contrib.d/databases.conf
and I modified it into:
vars.oracle_home = “/usr/lib/oracle/19.8”
vars.oracle_ld_library_path = “/usr/lib/oracle/19.8”
vars.oracle_tns_admin = ConfigDir + “/plugin-configs”

I have executed “Director-Kickstart” and restarted icinga, now the command is:
vars.oracle_home = “/usr/lib/oracle/19.8”
vars.oracle_ld_library_path = “/usr/lib/oracle/19.8”
vars.oracle_tns_admin = ConfigDir + “/plugin-configs”

But the problem stuck.
By command line it works, and from Icinga doesn’t work, I obtain:

ORA-12545: Connect failed because target host or object does not exist (DBD ERROR: OCIServerAttach)

What does inspect tell you and how does your env differ from the env the check runs in?

when I copy/paste the inspect, and I use in the command line, it works, so… I don’t understand the problem.

My guess, it’s the env. Do you use the same user to run the check and what happens if you put a line in the check to dump the env into a file and compare the envs?

Yes, I adjusted it, because there was a problem with the user executer of icinga (user nagios), so I put in the file /etc/environment:
ORACLE_HOME=“/usr/lib/oracle/19.8”
TNS_ADMIN=“/usr/lib/oracle/19.8/network/admin”
LD_LIBRARY_PATH=“/usr/lib/oracle/19.8”

and when I choose:
sudo su nagios
nagios@servername:~$‘/usr/lib/nagios/plugins/check_oracle_health’ ‘–connect’ ‘INSTANCENAME’ ‘–critical’ ‘10’ ‘–mode’ ‘connection-time’ ‘–password’ ‘passwordabc’ ‘–report’ ‘long’ ‘–username’ ‘system’ ‘–warning’ ‘7’

OK - 0.08 seconds to connect as SYSTEM | connection_time=0.0770;7;10

so it works by commandline but doesn’t work from Icinga.

I solved…
There was a problem on:
/etc/icinga2/plugin-configs/tnsnames.ora

When I used from command line, probably it use another path and it works, insted from Icinga it use:
/etc/icinga2/plugin-configs/tnsnames.ora
I adjusted it and I solved.

Sorry for the time that you wasted with me.
Thanks a lot for your help.
Mario

1 Like