31 Jan 2020 02:08 PM - last edited on 18 May 2023 03:17 PM by Michal_Gebacki
Hello,
I developed a remote OneAgent plugin to fetch metrics from Oracle.
In the plugin Python I call the cx_Oracle library. When I built the plugin the following library is generated:
cx_Oracle.cpython-36m-x86_64-linux-gnu.so.
The code does not work because it does not know about libclntsh library.
How can I use the generated library?
Best Regards,
Fousseyni B.
31 Jan 2020 08:41 PM
Did you declare all the required modules in your plugin.json file before you build it?
oneagent_build_plugin --no_upload
Dynatrace is not using the local python installation, so all the modules need to be available on the one that Dynatrace is using.
01 Feb 2020 09:03 AM
Hello Alonso,
I have declared all required modules in my plugin.json file before building it.
In my plugin, I making a call to an Oracle Database.
My plugin is not working at the line when I make call to the cx_Oracle library to open a connection to database :
error while loading shared libraries: libclntsh.so : cannot open shared object file: No such file or directory.
Best Regards,
Fousseyni B.
04 Feb 2020 07:01 PM
Hi Fousseyni,
Validate that all the required modules are in your plugin folder located at /opt/dynatrace/remotepluginmodule/plugin_deployment/
Regards,
Alonso
07 Feb 2020 09:26 AM
Hello Alonso,
When I built my plugin I had all the required library generated in the /opt/dynatrace/remotepluginmodule/plugin_deployment/. In my case it was cx_Oracle.cpython-36m-x86_64-linux-gnu.so.
Best Regards,
Fousseyni B.
14 Feb 2020 06:53 AM
Hi Fousseyni,
I found dynatrace plugin can't recognise anything outside the plugin folder (or outside of oneagent/agent folder), in my case, i copied the .so library into plugin folder then it was able to find it.
I now have new issues, but hope above helps resolve yours.
Cheers,
Laura
07 Feb 2020 09:08 AM
I'm trying to connect to mssql using pyodbc module and libmsodbcsql. I'm facing exactly the same issue as Fousseyni, the error msg is as below:
File "/opt/dynatrace/oneagent/plugin_deployment/custom.python.xxx_plugin/xxx_plugin.py", line 6, in <module>
import pyodbc
ImportError: libodbc.so.2: cannot open shared object file: No such file or directory
I searched the internet, almost everyone say above error means python can't find libodbc.so.2, this library is provided by unixOdbc which I have installed on the oneagent host.
/usr/lib/x86_64-linux-gnu#ls -ltr
-rw-r--r-- 1 root root 436064 Dec 12 2016 libodbc.so.2.0.0
lrwxrwxrwx 1 root root 16 Dec 12 2016 libodbc.so.2 -> libodbc.so.2.0.0
My plugin_deployment structure looks like below:
-rw-r--r-- 1 root root 1189 Feb 7 08:00 query_collection.py
-rw-r--r-- 1 root root 684488 Feb 7 08:00 pyodbc.cpython-36m-x86_64-linux-gnu.so
drwxr-xr-x 9 root root 288 Feb 7 08:00 pyodbc-4.0.28.dist-info
-rwxr-xr-x 1 root root 3850 Feb 7 08:00 plugin.json
drwxr-xr-x 6 root root 192 Feb 7 08:00 msodbcsql17
-rwxr-xr-x 1 root root 2843 Feb 7 08:00 xxx_plugin.py
drwxr-xr-x 9 root root 288 Feb 7 08:00 xxx_plugin-1.0.dist-info
In plugin.json I have:
"install_requires": [
"pyodbc>=4.0.28"
],
I can't add msodbcsql17 here as it's not a python module, nor can I include libodbc.so.2 as it's a system library.
How can we solve this problem?
07 Feb 2020 09:32 AM
Hello Laura,
You have already installed the library on the host, you now could execute the export (environment variable) in your python code. It is workaround.
import os
os.environ["My_DATA"] = "my_export"
Best Regards,
Fousseyni B.
11 Feb 2020 12:49 AM
Hi Fousseyni,
Setting environ in python doesn't work for current process, correct me if I'm wrong. I even added the env variable manually and printed out in the python script, yet it still can't find the .so file.
It seems to me the oneagent built-in python doesn't look for os libraries in normal locations.
Laura.