Skip to content
This repository has been archived by the owner on Jan 13, 2023. It is now read-only.

Commit

Permalink
Updated README.md
Browse files Browse the repository at this point in the history
Closes #1.
  • Loading branch information
the-c0d3br34k3r authored and silvs110 committed Feb 10, 2021
1 parent 6f498bf commit f7a68f4
Showing 1 changed file with 81 additions and 22 deletions.
103 changes: 81 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,27 @@
*** https://www.markdownguide.org/basic-syntax/#reference-style-links
-->
<div align="center">
<h1 align="center">Project Name</h1>
<h1 align="center">jVaidhiyar</h1>
<p align="center">
A template for Java maven projects.
A library for retrieving JVM related resource usage and configuration information.
<br />
<a href="https://github.com/padaiyal/jMavenProjectTemplate/issues/new/choose">Report Bug/Request Feature</a>
<a href="https://github.com/padaiyal/jVaidhiyar/issues/new/choose">Report Bug/Request Feature</a>
</p>

[![Contributors][contributors-shield]][contributors-url]
[![Forks][forks-shield]][forks-url]
[![Stargazers][stars-shield]][stars-url]
[![Issues][issues-shield]][issues-url]
[![Apache License][license-shield]][license-url] <br>
![Maven build - Ubuntu latest](https://github.com/padaiyal/jMavenProjectTemplate/workflows/Maven%20build%20-%20Ubuntu%20latest/badge.svg?branch=main)
![Maven build - Windows latest](https://github.com/padaiyal/jMavenProjectTemplate/workflows/Maven%20build%20-%20Windows%20latest/badge.svg?branch=main)
![Maven build - MacOS latest](https://github.com/padaiyal/jMavenProjectTemplate/workflows/Maven%20build%20-%20MacOS%20latest/badge.svg?branch=main)
![Publish to GitHub packages](https://github.com/padaiyal/jMavenProjectTemplate/workflows/Publish%20to%20GitHub%20packages/badge.svg)
![Maven build - Ubuntu latest](https://github.com/padaiyal/jVaidhiyar/workflows/Maven%20build%20-%20Ubuntu%20latest/badge.svg?branch=main)
![Maven build - Windows latest](https://github.com/padaiyal/jVaidhiyar/workflows/Maven%20build%20-%20Windows%20latest/badge.svg?branch=main)
![Maven build - MacOS latest](https://github.com/padaiyal/jVaidhiyar/workflows/Maven%20build%20-%20MacOS%20latest/badge.svg?branch=main)
![Publish to GitHub packages](https://github.com/padaiyal/jVaidhiyar/workflows/Publish%20to%20GitHub%20packages/badge.svg)
</div>

<!--
*** To avoid retyping too much info. Do a search and replace with your text editor for the following:
'jMavenProjectTemplate'
'jVaidhiyar'
-->

<!-- TABLE OF CONTENTS -->
Expand All @@ -54,15 +54,74 @@

<!-- ABOUT THE PROJECT -->
## About The Project
Describe the project.
This library retrieves the following JVM related information:
- Thread Information (Name, Priority, ID, Stack, CPU usage etc)
- Heap usage information
- Non heap usage information
- VM options
- Heap dump

<!-- USAGE -->
## Usage
Specify the steps to set up and use the project.
This project is to be used as a dependency to other projects.
Adding this project as a dependency is as follows:
1. Download the latest jar for this project from [GitHub packages](https://github.com/orgs/padaiyal/packages?repo_name=jVaidhiyar) and place it within
the dependant project.
2. Add the following dependency tag to the pom.xml of the dependant project:
```
<dependency>
<groupId>org.java.padaiyal.utilities</groupId>
<artifactId>vaidhiyar</artifactId>
<version>2021.02.09</version>
<scope>system</scope>
<systemPath>${basedir}/<PATH_TO_JAR></systemPath>
</dependency>
```
NOTE: Refer the [GitHub packages](https://github.com/orgs/padaiyal/packages?repo_name=jVaidhiyar)
/ [releases](https://github.com/padaiyal/jVaidhiyar/releases) section for this repo to know
the latest released version of this project.

Here's a sample snippet showing the usage of JvmUtility:
```
// Get the heap or non heap memory info.
ExtendedMemoryUsage extendedMemoryUsage = JvmUtility.getHeapMemoryUsage(); // Or JvmUtility.getNonHeapMemoryUsage()
double memoryUsagePercentage = extendedMemoryUsage.getMemoryUsagePercentage();
long initMemoryInBytes = extendedMemoryUsage.getInit();
long committedMemoryInBytes = extendedMemoryUsage.getCommitted();
long maxMemoryInBytes = extendedMemoryUsage.getMax();
// Get the configured VM options.
JsonArray vmOptions = JvmUtility.getAllVmOptions();
// Information on the most recent garbage collection.
GarbageCollectionInfo[] gcInfos = JvmUtility.getGarbageCollectionInfo();
// IDs of all threads running in the JVM.
long[] threadIds = JvmUtility.getAllThreadsId();
// Get information on JVM threads.
int threadStackDepth = 10;
ExtendedThreadInfo[] extendedThreadInfos = JvmUtility.getAllExtendedThreadInfo(threadStackDepth);
double threadCpuUsage = extendedThreadInfos[0].getCpuUsage();
ThreadInfo threadInfo = extendedThreadInfos[0].getThreadInfo();
long threadMemoryAllocatedInBytes = extendedThreadInfos[0].getMemoryAllocatedInBytes();
// Generate a heap dump.
Path destinationDirectory = ...;
String heapDumpFileName = "heapDump.hprof";
boolean dumpOnlyLiveObjects = false;
JvmUtility.generateHeapDump(
destinationDirectory,
heapDumpFileName,
dumpOnlyLiveObjects
);
...
```
For more such examples, checkout [JvmUtilityTest](https://github.com/padaiyal/jVaidhiyar/tree/main/src/test/java/org/padaiyal/utilities/vaidhiyar/JvmUtilityTest.java)

<!-- ROADMAP -->
## Roadmap
See the [open issues](https://github.com/padaiyal/jMavenProjectTemplate/issues) for a list of proposed features (and known issues).
See the [open issues](https://github.com/padaiyal/jVaidhiyar/issues) for a list of proposed features (and known issues).

<!-- CONTRIBUTING -->
## Contributing
Expand All @@ -77,18 +136,18 @@ Contributions are what make the open source community such an amazing place to b

<!-- LICENSE -->
## License
Distributed under the Apache License. See [`LICENSE`](https://github.com/padaiyal/jMavenProjectTemplate/blob/main/LICENSE) for more information.
Distributed under the Apache License. See [`LICENSE`](https://github.com/padaiyal/jVaidhiyar/blob/main/LICENSE) for more information.


<!-- MARKDOWN LINKS & IMAGES -->
<!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->
[contributors-shield]: https://img.shields.io/github/contributors/padaiyal/jMavenProjectTemplate.svg?style=for-the-badge
[contributors-url]: https://github.com/padaiyal/jMavenProjectTemplate/graphs/contributors
[forks-shield]: https://img.shields.io/github/forks/padaiyal/jMavenProjectTemplate.svg?style=for-the-badge
[forks-url]: https://github.com/padaiyal/jMavenProjectTemplate/network/members
[stars-shield]: https://img.shields.io/github/stars/padaiyal/jMavenProjectTemplate.svg?style=for-the-badge
[stars-url]: https://github.com/padaiyal/jMavenProjectTemplate/stargazers
[issues-shield]: https://img.shields.io/github/issues/padaiyal/jMavenProjectTemplate.svg?style=for-the-badge
[issues-url]: https://github.com/padaiyal/jMavenProjectTemplate/issues
[license-shield]: https://img.shields.io/github/license/padaiyal/jMavenProjectTemplate.svg?style=for-the-badge
[license-url]: https://github.com/padaiyal/jMavenProjectTemplate/blob/master/LICENSE
[contributors-shield]: https://img.shields.io/github/contributors/padaiyal/jVaidhiyar.svg?style=for-the-badge
[contributors-url]: https://github.com/padaiyal/jVaidhiyar/graphs/contributors
[forks-shield]: https://img.shields.io/github/forks/padaiyal/jVaidhiyar.svg?style=for-the-badge
[forks-url]: https://github.com/padaiyal/jVaidhiyar/network/members
[stars-shield]: https://img.shields.io/github/stars/padaiyal/jVaidhiyar.svg?style=for-the-badge
[stars-url]: https://github.com/padaiyal/jVaidhiyar/stargazers
[issues-shield]: https://img.shields.io/github/issues/padaiyal/jVaidhiyar.svg?style=for-the-badge
[issues-url]: https://github.com/padaiyal/jVaidhiyar/issues
[license-shield]: https://img.shields.io/github/license/padaiyal/jVaidhiyar.svg?style=for-the-badge
[license-url]: https://github.com/padaiyal/jVaidhiyar/blob/master/LICENSE

0 comments on commit f7a68f4

Please sign in to comment.