Download And Install Sigar

less than 1 minute read

Sigar is a Java library that allows you to monitor various aspects of your system. Including Network, Memory, and CPU.

To use Sigar in you Java application follow these steps:

  1. Copy the following Maven dependency into your project:
 <dependency>
 <groupId>org.gridkit.lab</groupId>
 <artifactId>sigar-lib</artifactId>
 <version>1.6.4</version>
</dependency>
  1. Download the necessary system files:

Note: This example will demonstrate how with the Linux based .so file. Make sure you copy across the correct file for you system. If you are unsure, there is no harm in copying all of the .dll and .so files across.

 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
 sudo cp sigar-bin/lib/libsigar-amd64-linux.so /usr/lib
  1. Use Sigar in your application
@Test
public void testGetSearchResultsGroupedByEntity() throws Exception {
  
  Sigar sigar = new Sigar();
  
  System.out.println(sigar.getCpu().getTotal());
}

 

Updated: