aanari / NewRelic-Agent

Perl Agent for NewRelic
7 stars 5 forks source link

Location of sdk files #2

Open brianphillips opened 9 years ago

brianphillips commented 9 years ago

I was attempting to use this module and ran into an issue where it's looking for the included SDK files (i.e. libnewrelic-common.so) in the build directory (i.e. ~/.cpanm/work/1437143371.23845/NewRelic-Agent-0.0510/sdk/lib/). Here's the relevant part of the strace:

[snip]
open("/home/bphillips/[snip]/local/lib/perl5/x86_64-linux-thread-multi/auto/NewRelic/Agent/Agent.so", O_RDONLY) = 4
open("/home/bphillips/.cpanm/work/1437151780.30969/NewRelic-Agent-0.0510/sdk/lib/tls/x86_64/libnewrelic-common.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/bphillips/.cpanm/work/1437151780.30969/NewRelic-Agent-0.0510/sdk/lib/tls/libnewrelic-common.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/bphillips/.cpanm/work/1437151780.30969/NewRelic-Agent-0.0510/sdk/lib/x86_64/libnewrelic-common.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/bphillips/.cpanm/work/1437151780.30969/NewRelic-Agent-0.0510/sdk/lib/libnewrelic-common.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/[snip]-perl/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE/libnewrelic-common.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 4
open("/lib64/tls/x86_64/libnewrelic-common.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/lib64/tls/libnewrelic-common.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/lib64/x86_64/libnewrelic-common.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/lib64/libnewrelic-common.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib64/tls/x86_64/libnewrelic-common.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib64/tls/libnewrelic-common.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib64/x86_64/libnewrelic-common.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib64/libnewrelic-common.so", O_RDONLY) = -1 ENOENT (No such file or directory)
[snip]

The only way I can figure out how to fix it is to set the $LD_LIBRARY_PATH to include the full path of the sdk/lib directory as installed.

$ export LD_LIBRARY_PATH=$(perl -le 'my($dir) = grep { -d $_ } map { "$_/NewRelic/sdk/lib" } @INC; print $dir')
[snip]
open("/home/bphillips/[snip]/local/lib/perl5/x86_64-linux-thread-multi/auto/NewRelic/Agent/Agent.so", O_RDONLY) = 4
open("/home/bphillips/.cpanm/work/1437151780.30969/NewRelic-Agent-0.0510/sdk/lib/tls/x86_64/libnewrelic-common.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/bphillips/.cpanm/work/1437151780.30969/NewRelic-Agent-0.0510/sdk/lib/tls/libnewrelic-common.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/bphillips/.cpanm/work/1437151780.30969/NewRelic-Agent-0.0510/sdk/lib/x86_64/libnewrelic-common.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/bphillips/.cpanm/work/1437151780.30969/NewRelic-Agent-0.0510/sdk/lib/libnewrelic-common.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/opt/[snip]-perl/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE/libnewrelic-common.so", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/bphillips/[snip]/local/lib/perl5/x86_64-linux-thread-multi/NewRelic/sdk/lib/libnewrelic-common.so", O_RDONLY) = 4
[snip]

Is this something that can be fixed as part of the distribution? Unfortunately, I'm not well-versed enough on compilers/linkers/MakeMaker to submit a pull request but I'm hoping you might have an idea or two.

Judging from the fact that you include the sdk as part of the distribution, I'm guessing you intended it to be used in the location its installed via CPAN?

brianphillips commented 9 years ago

Just FYI, I solved this by building an RPM to install the SDK .so files in /usr/lib64...

aanari commented 9 years ago

@brianphillips Good point, we ran into similar issues when attempting to get this module working on our production boxes. So far the best way to get these .so files in place have been chef scripts or using our OS's distribution to install these files for us (deb/RPM packages). If we can't come up with an automated way to make this work so that it's configured out of the box, then we'll just need to update the module's instructions to make it clear that these shared libraries need to be installed separately.

brianphillips commented 9 years ago

@aanari - I think it's reasonable to make that a documented binary dependency instead trying to bundle it as part of the CPAN module. That way things don't suddenly break when you try and deploy this to something that isn't your build server :)

I could try and put a PR together if that'd be helpful.

timbunce commented 8 years ago

I took a look at this and agree that removing the .so files from the distro is the best way to go. That forces the issue upfront and makes the installer responsible for installing the SDK.

p.s. I'm not sure if/when I'll get to work on this.