/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package vut.msa.monitor.system;

import org.apache.log4j.Logger;
import org.hyperic.sigar.FileSystem;
import org.hyperic.sigar.FileSystemMap;
import org.hyperic.sigar.FileSystemUsage;
import org.hyperic.sigar.Sigar;
import org.hyperic.sigar.SigarException;

/**
 * Trieda sluzi na ziskanie informacii o suborovom systeme zariadenia.
 */
public class FileSystemInformation {

    private static final Logger log = Logger.getLogger(FileSystemInformation.class);

    private Sigar sigar;

    private FileSystemMap fileSystemMap;
    private FileSystemUsage fsUsage;

    public FileSystemInformation(Sigar sigar) throws SigarException{
        this.sigar = sigar;

        FileSystem[] list = sigar.getFileSystemList();
        fileSystemMap = new FileSystemMap();
        fileSystemMap.init(list);
    }

    /**
     * Metoda sluzi na ziskanie informacii o zadanom uloznom medii. Informacie
     * sa tykaju vyuzivania daneho media, napr. celkovy objem dat a podobne.
     *
     * @param name nazov disku, o ktorom chceme informacie
     * @return objekt FileSystemUsage poskytujuci informacie o disku
     * @see org.hyperic.sigar.FileSystemUsage
     * @throws SigarException vynimka v pripade problemu nacitania objektu Sigar
     */
    public FileSystemUsage getFileSystemUsage (String name) throws SigarException {

        FileSystem system = fileSystemMap.getFileSystem(name);
        FileSystemUsage usage = new FileSystemUsage();
        usage.gather(sigar, system.getDevName());
        return usage;
    }
}
