javaperformancedisksigar

How to get disk performance info?


How can I get the disk performance using sigar, I know that iostat returns the disk usage, but I need the information related to speed to write and read in disk.

The native iostat on unix returns this data, but, I'm developing an application based on java where one of the purposes is be multi-platform, and sigar has worked perfectly until now.

My major concern is the Windows, so someone know how to get this information under Sigar or even under Windows?


Solution

  • Look at the source code of org.hyperic.sigar.cmd.Iostat.java . You can get all the filesystems that represents a local disk by:

    FileSystem[] fileSystemList = this.proxy.getFileSystemList();
    for (int i = 0; i < fileSystemList.length; i++) {
        FileSystem fs = fileSystemList[i];
        if (fs.getType() == FileSystem.TYPE_LOCAL_DISK){
        FileSystemUsage usage = this.sigar.getFileSystemUsage(fs.getDirName());
    
        String devName = fs.getDevName();
    
        long read = usage.getDiskReadBytes();
        long write = usage.getDiskWriteBytes();
    
    
        }
    
    }