-1

I'm working and discovering the world of Zabbix. In particular I am trying to monitor an Oracle database with the Zabbix server through an external script. Given that other external scripts work, however, I created one with sqlplus, but on Zabbix I get "command not found". Can you tell me why? The code is:

check.pl
#!/usr/bin/perl
use strict;
use warnings;
my $out=`echo "select * from v$version;" | sqlplus user/password@ip_database:port`;
print $out;

The code is very simple. I created an item as always, passed as type "external check" and a key I entered my script. Can anyone solve my problem? Also if I was not clear, just ask for more information rather than "insult" on the forum: Thanks to everyone in advance

I RESOLVED IT WITH:

echo "/usr/lib/oracle/11.2/client64/lib" > /etc/ld.so.conf.d/oracle.conf
echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/oracle/11.2/client64/lib" >> /etc/profile

THANKS TO ALL!!!!

user7209199
  • 59
  • 1
  • 10
  • Is the machine on which your executing this script is linux or windows? If Linux then did you installed Oracle client/SQL client on it? – Ankit Feb 01 '17 at 09:29
  • @Ankit Hi, the machine is Linux. Oracle client/SQL client is installed on. If try the code on terminal it works, but when I insert it on Zabbix, I get "command not found". Sorry for my english. – user7209199 Feb 01 '17 at 09:33

2 Answers2

0

Apparently, your zabbix server does not have the necessary environment to find sqlplus. You could simply use the full path to sqlplus in your script (but that alone might not be enough) or create a wrapper script that sets all the necessary environment variables for your script.

From TFM:

The command will be executed as the user Zabbix server runs as, so any access permissions or environment variables should be handled in a wrapper script, if necessary, and permissions on the command should allow that user to execute it.

Erich Kitzmueller
  • 36,381
  • 5
  • 80
  • 102
  • Hi, I think too that the problem is permission but I don't how to set it. Can you help me? – user7209199 Feb 01 '17 at 09:35
  • In a linux console window, type this: `which sqlplus`. The output could be something like `/opt/oracle/product/11.2.0/bin/sqlplus`. In your script, replace `sqlplus` with the output of the `which` command, e.g. `my $out='echo "select * from v$version;" | /opt/oracle/product/11.2.0/bin/sqlplus user/password@ip_database:port';` (beware that I had to change the backticks in your script, because this site uses them for formatting) – Erich Kitzmueller Feb 01 '17 at 09:40
  • I try it and this is my new error: /usr/lib/oracle/11.2/client64/bin/sqlplus: error while loading shared libraries: libsqlplus.so: cannot open shared object file: No such file or directory – user7209199 Feb 01 '17 at 09:43
  • To make it work, you need several environment variables set to appropriate values: `ORACLE_HOME`, `LD_LIBRARY_PATH` and maybe more. – Erich Kitzmueller Feb 01 '17 at 09:51
0

You also have to configure the sqlplus libraries required to run sqlplus. The script which you use to start the zabbix server you can configure below oracle things in the startup script so that zabbix can find all necessary libraries to run.

export ORACLE_HOME={path to Oracle Client}

export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${ORACLE_HOME}/lib

If still there are issues related to .so files then there must be some issues in your SQL client installation.

Community
  • 1
  • 1
Ankit
  • 2,753
  • 1
  • 19
  • 26