Search in sources :

Example 1 with OSFileStore

use of oshi.software.os.OSFileStore in project yyl_example by Relucent.

the class OshiExample method infoFileSystem.

private static void infoFileSystem(FileSystem fs) {
    println("FileStore");
    for (OSFileStore store : fs.getFileStores()) {
        String name = store.getName();
        String mount = store.getMount();
        String type = store.getType();
        long total = store.getTotalSpace();
        long free = store.getUsableSpace();
        long used = total - free;
        double usage = ((double) used * 100) / total;
        // 文件系统名
        println("   name:   " + name);
        // 挂载路径
        println("   mount:   " + mount);
        // 盘符类型
        println("   type:   " + type);
        // 总大小
        println("   total:  " + total);
        // 剩余大小
        println("   free:   " + free);
        // 已经使用量
        println("   used:   " + used);
        // 资源的使用率
        println("   usage:   " + usage);
    }
}
Also used : OSFileStore(oshi.software.os.OSFileStore)

Example 2 with OSFileStore

use of oshi.software.os.OSFileStore in project ats-framework by Axway.

the class OshiSystemInformation method listFileSystems.

@Override
public IFileSystem[] listFileSystems() {
    FileSystem fs = this.systemInfo.getOperatingSystem().getFileSystem();
    // enumerate only local drives. (Network ones are excluded)
    List<OSFileStore> fileStores = fs.getFileStores(true);
    List<IFileSystem> fileSystems = new ArrayList<IFileSystem>();
    for (OSFileStore fileStore : fileStores) {
        fileSystems.add(new OshiFileSystem(fileStore, fileStore.getMount()));
    }
    return fileSystems.toArray(new IFileSystem[fileSystems.size()]);
}
Also used : OSFileStore(oshi.software.os.OSFileStore) FileSystem(oshi.software.os.FileSystem) IFileSystem(com.axway.ats.agent.core.monitoring.systemmonitor.systeminformation.IFileSystem) IFileSystem(com.axway.ats.agent.core.monitoring.systemmonitor.systeminformation.IFileSystem) ArrayList(java.util.ArrayList)

Example 3 with OSFileStore

use of oshi.software.os.OSFileStore in project ats-framework by Axway.

the class OshiSystemInformation method getFileSystem.

@Override
public IFileSystem getFileSystem(String devName) {
    try {
        FileSystem fs = this.os.getFileSystem();
        List<OSFileStore> fileStores = fs.getFileStores();
        for (OSFileStore fileStore : fileStores) {
            if (fileStore.getName().equals(devName)) {
                return new OshiFileSystem(fileStore, fileStore.getName());
            }
        }
        throw new SystemInformationException("No such file system drive device '" + devName + "'");
    } catch (Exception e) {
        throw new SystemInformationException("Could not obtain file system for/from device '" + devName + "'", e);
    }
}
Also used : OSFileStore(oshi.software.os.OSFileStore) FileSystem(oshi.software.os.FileSystem) IFileSystem(com.axway.ats.agent.core.monitoring.systemmonitor.systeminformation.IFileSystem) SystemInformationException(com.axway.ats.agent.core.monitoring.systemmonitor.systeminformation.exceptions.SystemInformationException) SystemInformationException(com.axway.ats.agent.core.monitoring.systemmonitor.systeminformation.exceptions.SystemInformationException)

Aggregations

OSFileStore (oshi.software.os.OSFileStore)3 IFileSystem (com.axway.ats.agent.core.monitoring.systemmonitor.systeminformation.IFileSystem)2 FileSystem (oshi.software.os.FileSystem)2 SystemInformationException (com.axway.ats.agent.core.monitoring.systemmonitor.systeminformation.exceptions.SystemInformationException)1 ArrayList (java.util.ArrayList)1