https://github.com/teragrep/jos_01
Teragrep Operating System Statistics Library for Java
https://github.com/teragrep/jos_01
java library linux monitoring operating-system-statistics statistics teragrep
Last synced: about 2 months ago
JSON representation
Teragrep Operating System Statistics Library for Java
- Host: GitHub
- URL: https://github.com/teragrep/jos_01
- Owner: teragrep
- License: agpl-3.0
- Created: 2024-05-17T08:59:48.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-23T09:50:16.000Z (almost 2 years ago)
- Last Synced: 2025-12-31T13:37:33.445Z (5 months ago)
- Topics: java, library, linux, monitoring, operating-system-statistics, statistics, teragrep
- Language: Java
- Homepage: https://teragrep.com
- Size: 49.8 KB
- Stars: 0
- Watchers: 2
- Forks: 2
- Open Issues: 3
-
Metadata Files:
- Readme: README.adoc
- License: LICENSE
Awesome Lists containing this project
README
= Java Operating System Statistics (jos_01)
This project will extract statistics from the operating system and running processes into Java objects.
You can use this to easily get information such as memory usage about running processes and the operating system itself.
The information provided is based on the Linux filesystem's `/proc` files.
== Features
- Can be used to check if a process is alive by using process ID.
- Provides the statistics of OS or any running process by using your system's `/proc` files as the source of truth.
- Provides high level methods that calculate OS or process performance statistics automatically, such as `residentSetSize()`.
- Can be used to create Java objects representing the current state of a `/proc` file and get access to the file's values.
This project can be used to easily create system or process monitoring solutions in Java applications.
== Documentation
See the official documentation on https://docs.teragrep.com[docs.teragrep.com].
== Limitations
- Only supports Linux-based operating systems
- Requires access to `/proc` files in order to function
== How to use
=== Requirements
- Java version 1.8
- Maven
=== Installation
Include the following dependency into your project's pom.xml file:
com.teragrep
jos_01
=== Usage
==== Operating system statistics
Start by creating a LinuxOS object.
Optionally provide a configuration object by implementing `SysconfInterface` to manually configure the Operating system CPU tick rate.
Use methods of LinuxOS object to get information on operating system.
==== Process statistics
Create a Process object by supplying a valid process ID to Process' constructor.
Optionally provide a specific LinuxOS object during construction, so that OS configuration is applied to Process object's methods.
=== Examples of use
==== Creating a new LinuxOS object with automatic configuration
LinuxOS os = new LinuxOS();
==== Creating a new Process object with automatic configuration
Process process = new Process(250);
==== Creating a new LinuxOS object with manual CPU tickrate configuration
LinuxOS os = new LinuxOS(SysconfInterface.Fake(100));
==== CPU count of current system
LinuxOS os = new LinuxOS();
System.out.println(os.cpuCount());
==== Manually configure CPU tickrate and get CpuTime of process with ID 1
LinuxOS os = new LinuxOS(SysconfInterface.Fake(1000));
Process process = new Process(1,os);
System.out.println(process.cpuTime());
==== Access /proc/stat files of process with ID 250 and print out "comm" value
Process process = new Process(250);
Stat stat = process.stat();
System.out.println(stat.comm());
== Contributing
You can involve yourself with our project by https://github.com/teragrep/jos_01/issues/new/choose[opening an issue] or submitting a pull request.
Contribution requirements:
. *All changes must be accompanied by a new or changed test.* If you think testing is not required in your pull request, include a sufficient explanation as why you think so.
. Security checks must pass
. Pull requests must align with the principles and http://www.extremeprogramming.org/values.html[values] of extreme programming.
. Pull requests must follow the principles of Object Thinking and Elegant Objects (EO).
Read more in our https://github.com/teragrep/teragrep/blob/main/contributing.adoc[Contributing Guideline].
=== Contributor License Agreement
Contributors must sign https://github.com/teragrep/teragrep/blob/main/cla.adoc[Teragrep Contributor License Agreement] before a pull request is accepted to organization's repositories.
You need to submit the CLA only once. After submitting the CLA you can contribute to all Teragrep's repositories.