Skip to content
forked from teragrep/jos_01

Java Operating System Statistics

License

AGPL-3.0, Unknown licenses found

Licenses found

AGPL-3.0
LICENSE
Unknown
license-header
Notifications You must be signed in to change notification settings

Laukkala/jos_01

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 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:

<dependency>
  <groupId>com.teragrep</groupId>
  <artifactId>jos_01</artifactId>
</dependency>

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 opening an issue or submitting a pull request.

Contribution requirements:

  1. 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.

  2. Security checks must pass

  3. Pull requests must align with the principles and values of extreme programming.

  4. Pull requests must follow the principles of Object Thinking and Elegant Objects (EO).

Read more in our Contributing Guideline.

Contributor License Agreement

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.

About

Java Operating System Statistics

Resources

License

AGPL-3.0, Unknown licenses found

Licenses found

AGPL-3.0
LICENSE
Unknown
license-header

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 96.3%
  • M4 1.3%
  • Makefile 1.2%
  • C 1.2%