0

How to find CPU, disk and memory usage of a virtual machine using Java Program? Any API or third party library that i can use? As i want to alert my client when CPU usage is more than 75, low memory and disk space.

1) OS : Redhat 7

Thank you so much for your help.

Jack
  • 89
  • 6
  • Do you want a tool, which can tell you all this? or you want a lib so that you could write a tool. I am bit confused – Dupinder Singh Apr 08 '20 at 03:56
  • There is a two tools called ''jstat" and "jcmd" defaulr installed with java installation . You can use them to get the information about your local JVM processes . https://docs.oracle.com/javase/7/docs/technotes/tools/share/jstat.html – Kaviranga Apr 08 '20 at 04:35
  • Also refer this refrrence https://dzone.com/articles/jvm-statistics-with-jstat – Kaviranga Apr 08 '20 at 04:35
  • Duplicate of https://stackoverflow.com/questions/47177/how-do-i-monitor-the-computers-cpu-memory-and-disk-usage-in-java with [this answer](https://stackoverflow.com/a/56143016/1161484) duplicating the answer below. – Daniel Widdis Apr 08 '20 at 17:18
  • Yeah. i need a library to write a program to check the CPU, memory and Disk Usage and send warning to user if required – Jack Apr 09 '20 at 05:28

1 Answers1

1

Quoted from oshi Github Project Page

OSHI is a free JNA-based (native) Operating System and Hardware Information library for Java. It does not require the installation of any additional native libraries and aims to provide a cross-platform implementation to retrieve system information, such as OS version, processes, memory & CPU usage, disks & partitions, devices, sensors, etc.

ImtiazeA
  • 1,272
  • 14
  • 19