Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provisioning failure for MacOS #3

Open
pdeschen opened this issue Oct 1, 2015 · 5 comments
Open

Provisioning failure for MacOS #3

pdeschen opened this issue Oct 1, 2015 · 5 comments

Comments

@pdeschen
Copy link

pdeschen commented Oct 1, 2015

I'm getting odd behaviour on sigar provisioning on macos where while first provisioning works out of the box, subsequent ones just fail with a UnsatisfiedLinkError.

To reproduce, here is a small groovy file:

@Grab('io.kamon:sigar-loader:1.6.6-rev002') 

import java.io.File;
import kamon.sigar.SigarProvisioner;
import org.hyperic.sigar.*;

class CPU {
    static {
        SigarProvisioner.provision();
    }
    double percent(long pid) {
        final Sigar sigar = new Sigar();

        try {
            ProcCpu curPc = sigar.getProcCpu(pid);
            println curPc.getPercent();
            return curPc.getPercent();
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    }
}

cpu = new CPU();
cpu.percent(Long.valueOf(this.args[0]));

Then simply

groovy test.groovy `pidof iTerm`

Which returns with

Oct 01, 2015 4:26:49 PM kamon.sigar.SigarProvisioner discoverLocation
INFO: Using location provided by hard coded value.
Oct 01, 2015 4:26:49 PM kamon.sigar.SigarProvisioner provision
INFO: Sigar library provisioned: /Users/pdeschen/native/libsigar-universal64-macosx.dylib
0.0

Where we have

› ls -l ~/native
total 392
-rw-r--r-- 1 pdeschen staff 397440 Oct  1 16:26 libsigar-universal64-macosx.dylib

Then launching the script once more gets me:

› groovy test.groovy `pidof iTerm`
Oct 01, 2015 4:30:36 PM kamon.sigar.SigarProvisioner discoverLocation
INFO: Using location provided by hard coded value.
Caught: java.lang.UnsatisfiedLinkError: /Users/pdeschen/native/libsigar-universal64-macosx.dylib: dlopen(/Users/pdeschen/native/libsigar-universal64-macosx.dylib, 1): no suitable image found.  Did find:
    /Users/pdeschen/native/libsigar-universal64-macosx.dylib: file too short
java.lang.UnsatisfiedLinkError: /Users/pdeschen/native/libsigar-universal64-macosx.dylib: dlopen(/Users/pdeschen/native/libsigar-universal64-macosx.dylib, 1): no suitable image found.  Did find:
    /Users/pdeschen/native/libsigar-universal64-macosx.dylib: file too short
    at kamon.sigar.SigarProvisioner.provision(SigarProvisioner.java:179)
    at kamon.sigar.SigarProvisioner.provision(SigarProvisioner.java:135)
    at kamon.sigar.SigarProvisioner$provision.call(Unknown Source)
    at CPU.<clinit>(test.groovy:9)
    at test.run(test.groovy:24)

Because we have

› ls -l ~/native
total 0
-rw-r--r-- 1 pdeschen staff 0 Oct  1 16:30 libsigar-universal64-macosx.dylib
› uname -v
Darwin Kernel Version 14.5.0: Wed Jul 29 02:26:53 PDT 2015; root:xnu-2782.40.9~1/RELEASE_X86_64
@Andrei-Pozolotin
Copy link
Contributor

  1. copy/paste provisioner class in your project, see if you can reliably reproduce the error
    https://github.com/kamon-io/sigar-loader/blob/master/core/src/main/java/kamon/sigar/SigarProvisioner.java

  2. if so, add targetStream.flush(); at #L174, see if makes a difference
    https://github.com/kamon-io/sigar-loader/blob/master/core/src/main/java/kamon/sigar/SigarProvisioner.java#L174

@pdeschen
Copy link
Author

pdeschen commented Oct 2, 2015

@Andrei-Pozolotin I'm a bit puzzled: I've cloned the project, issued sbt package from master, used the resulting jar in my groovy test script and I can't duplicate the error. I'll try to investigate the difference in the actual jars and report back.

@pdeschen
Copy link
Author

pdeschen commented Oct 3, 2015

Version 1.6.6 seems to be missing the native/libsigar-universal64-macosx.dylib from within the sigar-loader-1.6.6.jar file.

Using version 1.6.5 with or without adding the provisioner class in my java project, I cannot reproduce the error I got with groovy.

All in all, 1.6.6 is definitely broken and missing the necessary native lib for macos. As for 1.6.5, I have no clue about what's going beside pointing finger at groovy. I would be curious to know whether you can duplicate yourself using groovy?

Edit: java v. groovy project

@Andrei-Pozolotin
Copy link
Contributor

  1. if you extract 1.6.6 jar content
    http://search.maven.org/#artifactdetails%7Cio.kamon%7Csigar-loader%7C1.6.6-rev002%7Cjar
    you will find native/libsigar-universal64-macosx.dylib inside; not sure how it is missing

  2. no groovy here, only scala - sorry. try to play with the provisioner class in groovy.
    it's just one little class :-) you can re-do it in groovy. did you try to add stream.flush()?

  3. if it is 100% reproducible error, please post here your code snippet

@dpsoft
Copy link
Contributor

dpsoft commented Oct 5, 2015

@Andrei-Pozolotin if you extract http://maven.hyperic.org/external/org/hyperic/sigar/1.6.6.12/sigar-1.6.6.12-libs.zip there is not libsigar-universal64-macosx.dylib inside... :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants