org.hyperic.sigar.FileSystemUsage Java Examples

The following examples show how to use org.hyperic.sigar.FileSystemUsage. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SystemRuntime.java    From sigar-system_runtime with MIT License 6 votes vote down vote up
public void file() throws Exception {
    FileSystem fslist[] = sigar.getFileSystemList();
    for (int i = 0; i < fslist.length; i++) {
        System.out.println("分区的盘符名称" + i);
        FileSystem fs = fslist[i];
        // 分区的盘符名称
        System.out.println("盘符名称:    " + fs.getDevName());
        // 分区的盘符名称
        System.out.println("盘符路径:    " + fs.getDirName());
        System.out.println("盘符标志:    " + fs.getFlags());//
        // 文件系统类型,比如 FAT32、NTFS
        System.out.println("盘符类型:    " + fs.getSysTypeName());
        // 文件系统类型名,比如本地硬盘、光驱、网络文件系统等
        System.out.println("盘符类型名:    " + fs.getTypeName());
        // 文件系统类型
        System.out.println("盘符文件系统类型:    " + fs.getType());
        FileSystemUsage usage = null;
        usage = sigar.getFileSystemUsage(fs.getDirName());
        System.out.println(fs.getDevName() + "读出:    " + usage.getDiskReads());
        System.out.println(fs.getDevName() + "写入:    " + usage.getDiskWrites());
    }
    return;
}
 
Example #2
Source File: NodeMetricsManager.java    From onos with Apache License 2.0 6 votes vote down vote up
private void pollMetrics() {
    try {
        CpuPerc cpu = sigar.getCpuPerc();
        Mem mem = sigar.getMem();
        FileSystemUsage disk = sigar.getFileSystemUsage(SLASH);

        NodeMemoryUsage memoryNode = new NodeMemoryUsage.Builder().free(mem.getFree())
                .used(mem.getUsed()).total(mem.getTotal()).withUnit(Units.BYTES)
                .withNode(localNodeId).build();
        NodeCpuUsage cpuNode = new NodeCpuUsage.Builder().withNode(localNodeId)
                .usage(cpu.getCombined() * PERCENTAGE_MULTIPLIER).build();
        NodeDiskUsage diskNode = new NodeDiskUsage.Builder().withNode(localNodeId)
                .free(disk.getFree()).used(disk.getUsed()).withUnit(Units.KBYTES)
                .total(disk.getTotal()).build();
        diskStore.put(localNodeId, diskNode);
        memoryStore.put(localNodeId, memoryNode);
        cpuStore.put(localNodeId, cpuNode);

    } catch (SigarException e) {
        log.error("Exception occurred ", e);
    }

}
 
Example #3
Source File: sigar.java    From sigar-system_runtime with MIT License 4 votes vote down vote up
private static void file() throws Exception {
    Sigar sigar = new Sigar();
    FileSystem fslist[] = sigar.getFileSystemList();
    for (int i = 0; i < fslist.length; i++) {
        System.out.println("分区的盘符名称" + i);
        FileSystem fs = fslist[i];
        // 分区的盘符名称
        System.out.println("盘符名称:    " + fs.getDevName());
        // 分区的盘符名称
        System.out.println("盘符路径:    " + fs.getDirName());
        System.out.println("盘符标志:    " + fs.getFlags());//
        // 文件系统类型,比如 FAT32、NTFS
        System.out.println("盘符类型:    " + fs.getSysTypeName());
        // 文件系统类型名,比如本地硬盘、光驱、网络文件系统等
        System.out.println("盘符类型名:    " + fs.getTypeName());
        // 文件系统类型
        System.out.println("盘符文件系统类型:    " + fs.getType());
        FileSystemUsage usage = null;
        usage = sigar.getFileSystemUsage(fs.getDirName());
        switch (fs.getType()) {
        case 0: // TYPE_UNKNOWN :未知
            break;
        case 1: // TYPE_NONE
            break;
        case 2: // TYPE_LOCAL_DISK : 本地硬盘
            // 文件系统总大小
            System.out.println(fs.getDevName() + "总大小:    " + usage.getTotal() + "KB");
            // 文件系统剩余大小
            System.out.println(fs.getDevName() + "剩余大小:    " + usage.getFree() + "KB");
            // 文件系统可用大小
            System.out.println(fs.getDevName() + "可用大小:    " + usage.getAvail() + "KB");
            // 文件系统已经使用量
            System.out.println(fs.getDevName() + "已经使用量:    " + usage.getUsed() + "KB");
            double usePercent = usage.getUsePercent() * 100D;
            // 文件系统资源的利用率
            System.out.println(fs.getDevName() + "资源的利用率:    " + usePercent + "%");
            break;
        case 3:// TYPE_NETWORK :网络
            break;
        case 4:// TYPE_RAM_DISK :闪存
            break;
        case 5:// TYPE_CDROM :光驱
            break;
        case 6:// TYPE_SWAP :页面交换
            break;
        }
        System.out.println(fs.getDevName() + "读出:    " + usage.getDiskReads());
        System.out.println(fs.getDevName() + "写入:    " + usage.getDiskWrites());
    }
    return;
}
 
Example #4
Source File: FileSystemInfo.java    From maintain with MIT License 4 votes vote down vote up
public FileSystemInfo(FileSystem fileSystem, FileSystemUsage fileSystemUsage) {
	this.fileSystem = fileSystem;
	this.fileSystemUsage = fileSystemUsage;
}
 
Example #5
Source File: FileSystemInfo.java    From maintain with MIT License 4 votes vote down vote up
public FileSystemUsage getFileSystemUsage() {
	return fileSystemUsage;
}
 
Example #6
Source File: FileSystemInfo.java    From maintain with MIT License 4 votes vote down vote up
public void setFileSystemUsage(FileSystemUsage fileSystemUsage) {
	this.fileSystemUsage = fileSystemUsage;
}