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.
-
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.
See the official documentation on docs.teragrep.com.
-
Only supports Linux-based operating systems
-
Requires access to
/proc
files in order to function
Include the following dependency into your project’s pom.xml file:
<dependency> <groupId>com.teragrep</groupId> <artifactId>jos_01</artifactId> </dependency>
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.
LinuxOS os = new LinuxOS(SysconfInterface.Fake(100));
LinuxOS os = new LinuxOS(SysconfInterface.Fake(1000)); Process process = new Process(1,os); System.out.println(process.cpuTime());
You can involve yourself with our project by 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 values of extreme programming.
-
Pull requests must follow the principles of Object Thinking and Elegant Objects (EO).
Read more in our Contributing Guideline.
Contributors must sign 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.