Springboot dynamically loads sigar

  java

maven

        <dependency>
            <groupId>com.github.cb372</groupId>
            <artifactId>metrics-sigar</artifactId>
            <version>0.2.2</version>
        </dependency>

native

        <dependency>
            <groupId>org.fusesource</groupId>
            <artifactId>sigar</artifactId>
            <version>1.6.4</version>
            <classifier>native</classifier>
        </dependency>

Unzip the jar package and copy the so and dylib files to the resources folder of the spring boot common module project.

Load so file

  • According to os.name, what kind of so files need to be loaded

  • System.load

Static method block load, load before newsig

doc