Skip to content

Download and install Sigar

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>

2. 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

3. Use Sigar in your application

@Test
public void testGetSearchResultsGroupedByEntity() throws Exception {
  
  Sigar sigar = new Sigar();
  
  System.out.println(sigar.getCpu().getTotal());
}

 

Published inJavaProgramming

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *