Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/gionn/linuxmetrics4j
- Owner: gionn
- License: apache-2.0
- Created: 2014-01-12T16:24:39.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2021-12-15T09:04:55.000Z (about 3 years ago)
- Last Synced: 2023-03-11T01:33:19.903Z (almost 2 years ago)
- Language: Java
- Size: 35.2 KB
- Stars: 6
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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 usageMore 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.