简体   繁体   English

用Java监视磁盘活动

[英]Monitor disk activity in Java

I am looking for ways to monitor disk activity in a Java, closed-source, commercial, desktop application. 我正在寻找监控Java,闭源,商业,桌面应用程序中的磁盘活动的方法。 In particular, what I'd like to do is monitor how frequently the app is accessing database/disk - it would appear as "HDD led" indicator in the app and would work exactly the same (so, essentially real-time activity monitoring). 特别是,我想要做的是监控应用程序访问数据库/磁盘的频率 - 它在应用程序中显示为“HDD led”指示器并且将完全相同(因此,基本上是实时活动监控) 。 I would also like to have as little as possible external libraries. 我也希望尽可能少的外部库。

What I've found so far, doesn't seem too encouraging - I haven't seen the exact examples of anything like that and the best hits I've managed to dig either reference huge frameworks (like Sigar) or libraries like JPicus (which doesn't support Java7 and doesn't seem like it'd support my case). 我到目前为止所发现的,似乎并不太令人鼓舞 - 我还没有看到这样的确切例子和我设法挖掘的最佳点击参考巨大的框架(如Sigar)或像JPicus这样的库(它不支持Java7,似乎不支持我的情况)。 JMX instrumentation doesn't seem to support this either, so I am pretty much open for any ideas/suggestions. JMX仪器似乎也不支持这一点,因此我对任何想法/建议都非常开放。

The tech stack is - Java7, Eclipse RCP, SQL Server 2008. 技术堆栈是 - Java7,Eclipse RCP,SQL Server 2008。

EDIT: To make matters totally clear, I want to monitor disk I/O activity of a Java program with a pure, platform agnostic Java solution. 编辑:为了使事情完全清楚,我想用一个纯粹的,平台无关的Java解决方案来监控Java程序的磁盘I / O活动。

If you want to know how to monitor the disk I/O activity of a windows process: please ask that question on server fault. 如果您想知道如何监视Windows进程的磁盘I / O活动:请在服务器故障上询问该问题。

If you want to know how to monitor disk I/O activity of a Java program with a pure, platform agnostic Java solution: There is none, especially meeting your requirements. 如果您想了解如何使用纯粹的,与平台无关的Java解决方案来监视Java程序的磁盘I / O活动:没有,尤其是满足您的要求。 Technically the only option would be to wrap all I/O operations with instrumented code, which is rather costly. 从技术上讲,唯一的选择是使用检测代码包装所有I / O操作,这相当昂贵。

You could replace the implementation of FileInputStream/FileOutputStream with classes in an extension directory. 您可以使用扩展目录中的类替换FileInputStream / FileOutputStream的实现。 If that isn't picked up early enough, try setting java.system.class.loader to your own classloader that can intercept requests for those classes. 如果没有尽早java.system.class.loader ,请尝试将java.system.class.loader设置为您自己的类加载器, java.system.class.loader加载器可以拦截对这些类的请求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM