Java lightweight hardware monitoring tool, with a size of only 12KB, provides CPU load, disk IO, memory occupation and network traffic monitoring; The monitoring data will be output in the terminal and log file (optional).
Not yet released
public class example implements UseCallback {
public void text() {
try {
// Create collection work
// Param1 is use callback
// Param2 is collection interval time (seconds)
Work work = new Work(this, 60);
// Set the location to save the log, it will not be saved if not set
work.save("./")
// No collection CPU data
.excludeCPU()
// No collection Disk data
.excludeDisk()
// No collection Memory data
.excludeMemory()
// No collection Network data
.excludeNetwork()
// Start work
.run();
} catch (NoCollectorException e) {
// Minimum 1 collection item needs to be enabled!
}
}
@Override
public void receive(UsePacker packer) {
CpuUse cpu = packer.getCpu();
DiskUse disk = packer.getDisk();
MemoryUse memory = packer.getMemory();
NetworkUse network = packer.getNetwork();
}
}
public class example {
public void text() {
try {
Work work = new Work();
work.run();
} catch (NoCollectorException e) {
// Minimum 1 collection item needs to be enabled!
}
}
}
public class example {
public void text() {
try {
Work work = new Work();
// Param is file save location
work.save("./").run();
} catch (NoCollectorException e) {
// Minimum 1 collection item needs to be enabled!
}
}
}
public class example implements UseCallback {
public void text() {
try {
Work work = new Work(this);
work.run();
} catch (NoCollectorException e) {
// Minimum 1 collection item needs to be enabled!
}
}
@Override
public void receive(UsePacker packer) {
CpuUse cpu = packer.getCpu();
DiskUse disk = packer.getDisk();
MemoryUse memory = packer.getMemory();
NetworkUse network = packer.getNetwork();
}
}
public class example {
public void text() {
// no callback, no save, collect all data
Obtain obtain = new Obtain();
UsePacker packer = obtain.syncCollectionData();
// custom collection items
obtain = new Obtain(false, false, true, true);
packer = obtain.syncCollectionData();
// customizing collection items and save locations
obtain = new Obtain(".", true, true, false, false);
packer = obtain.syncCollectionData();
}
}
The Work
provides 4 exclusion methods, you will get this exception if you exclude all collection items
sc-monitor
uses Maven as its build tool.
Since we rely on oshi-core
requires Java 8 or later.
This project is licensed under the MIT License.