Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/gionn/linuxmetrics4j

A very simple java library to gather cpu, memory, network, load average stats from procfs on Linux machines.
https://github.com/gionn/linuxmetrics4j

Last synced: 4 months ago
JSON representation

A very simple java library to gather cpu, memory, network, load average stats from procfs on Linux machines.

Awesome Lists containing this project

README

        

linuxmetrics4j
==============

A very simple java library to gather cpu, memory, network, load average stats from procfs on Linux machines.

Actually have been implemented retrieving from:
* /proc/loadavg to get load average
* /proc/stat to get cpu usage
* /proc/meminfo to get memory usage
* /proc/net/dev to get network usage

More information of what is possibile to retrieve from procfs can be found on the proc man page: http://linux.die.net/man/5/proc

Usage
=====

```java
LinuxMetricsClient client = new LinuxMetricsClientImpl();

CpuUsage cpuUsage = client.getCpuUsage();
Integer count = cpuUsage.getCoreCount();
BigDecimal idle = cpuUsage.getIdle();
BigDecimal user = cpuUsage.getUser();

MemoryUsage memory = client.getMemoryInfo();
memory.getMemTotal();

LoadAverage loadAverage = client.getLoadAverage();
double five = loadAverage.getFiveMinutes();

List networks = client.getNetworkUsage();
for (NetworkUsage network : networks)
{
String device = network.getDevice();
Integer received = network.getBytesReceived();
Integer sent = network.getBytesTransmitted();
}

```

Maven repository
================

Add to your pom.xml:
```xml


github.linuxmetrics4j.repo
https://raw.github.com/gionn/linuxmetrics4j/mvn-repo/


net.gionn.linuxmetrics4j
metrics-core
0.0.1

```

Contribute
==========

If you find a problem, please open an issue or submit a PR.