Java 如何在基于 Ubuntu 的 Linux 上安装 SIGAR?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21894128/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 11:18:20  来源:igfitidea点击:

How to install SIGAR on Ubuntu-based Linux?

javaspringmavenubuntusigar

提问by Flame_Phoenix

I am using SIGAR in a java project with Maven and Spring. I have the Maven Dependency and Maven Repository included in my pom.xmlfile, as described in this link: http://mavenhub.com/mvn/thirdparty-uploads/org.hyperic/sigar/1.6.5.132

我在一个带有 Maven 和 Spring 的 java 项目中使用 SIGAR。我的pom.xml文件中包含 Maven 依赖项和 Maven 存储库,如此链接中所述:http: //mavenhub.com/mvn/thirdparty-uploads/org.hyperic/sigar/1.6.5.132

Furthermore, I am launching the program using Jetty (which launches the .war file created by mvn install).

此外,我正在使用 Jetty 启动程序(它启动由 .war 创建的文件mvn install)。

However, SIGAR still won't work. Aparently I also need to install libsigar-amd64-linux-1.6.4.

但是,SIGAR 仍然不起作用。显然我还需要安装 libsigar-amd64-linux-1.6.4。

So I downloaded that file, but now I have no idea what to do with it. How do I fix this? Where do I put that file?

所以我下载了那个文件,但现在我不知道如何处理它。我该如何解决?我把那个文件放在哪里?

采纳答案by Flame_Phoenix

Finally found the solution. I had to download SIGAR from the official source.

终于找到了解决办法。我不得不从官方来源下载 SIGAR 。

Then I had to copy/paste the entire "lib" folder (with all the .soand .dlland whatnot) into the folder "main/src/webapp" of the project, which is used by Spring to store needed apps (or so I assume).

然后,我不得不复制/粘贴整个“LIB”文件夹(与所有的.so.dll和诸如此类的东西)到文件夹中的项目,该项目所使用的弹簧需要存储的应用程序的“主/ src目录/ Web应用程序”(或因此我认为) .

Then after running mvn install, checking the "target" folder and running the newly generated .warfile, everything runs as expected.

然后运行后mvn install,检查“目标”文件夹并运行新生成的.war文件,一切都按预期运行。

回答by sorifiend

I believe it needs to be put into your programs library folder, alongside the "sigar.jar" file.

我相信它需要与“sigar.jar”文件一起放入您的程序库文件夹中。

If you plan to run your program on other OS variants, you should also have a bunch of ".dll", ".so" and ".dylib" files in the same lib folder.

如果您计划在其他操作系统变体上运行您的程序,您还应该在同一个 lib 文件夹中有一堆“.dll”、“.so”和“.dylib”文件。

Edit: You can download sigar at the link below, it contains the lib files for all major platforms: http://sourceforge.net/projects/sigar/?source=navbar

编辑:您可以在下面的链接下载 sigar,它包含所有主要平台的 lib 文件:http: //sourceforge.net/projects/sigar/?source=navbar

回答by aitorhh

To install sigar on Linux, here is a copy/paste option:

要在 Linux 上安装 sigar,这里有一个复制/粘贴选项:

wget https://netcologne.dl.sourceforge.net/project/sigar/sigar/1.6/hyperic-sigar-1.6.4.tar.gz
tar xvf hyperic-sigar-1.6.4.tar.gz
cd hyperic-sigar-1.6.4

# INSTALL
sudo cp sigar-bin/lib/libsigar-`dpkg --print-architecture`-`uname -s | tr '[:upper]' '[:lower]'`.so /usr/lib

回答by dambo14

@aitorhh This actually works, **But had some errors in your code, this works:

@aitorhh 这确实有效,**但是您的代码中有一些错误,这有效:

wget https://netcologne.dl.sourceforge.net/project/sigar/sigar/1.6/hyperic-sigar-1.6.4.tar.gz
tar xvf hyperic-sigar-1.6.4.tar.gz
cd hyperic-sigar-1.6.4

# INSTALL
sudo cp sigar-bin/lib/libsigar-`dpkg --print-architecture`-`uname -s | tr '[:upper:]' '[:lower:]'`.so /usr/lib

回答by Harris. Pan

just install sigar lib:

只需安装 sigar lib:

sudo apt install libhyperic-sigar-java

this works for me.

这对我有用。