Package org.hyperic.sigar

Examples of org.hyperic.sigar.FileSystem


    public void output(String[] args) throws SigarException {
        if (args.length == 1) {
            FileSystemMap mounts = this.proxy.getFileSystemMap();
            String name = FileCompleter.expand(args[0]);
            FileSystem fs = mounts.getMountPoint(name);

            if (fs != null) {
                printHeader();
                output(fs);
                return;
View Full Code Here


        String dir = System.getProperty("user.home");
        assertTrueTrace("\nMountPoint for " + dir,
                        mounts.getMountPoint(dir).getDirName());

        for (int i=0; i<fslist.length; i++) {
            FileSystem fs = fslist[i];

            assertTrue(mounts.getFileSystem(fs.getDirName()) != null);
            assertLengthTrace("DevName", fs.getDevName());
            assertLengthTrace("DirName", fs.getDirName());
            assertLengthTrace("TypeName", fs.getTypeName());
            assertLengthTrace("SysTypeName", fs.getSysTypeName());

            FileSystemUsage usage;

            try {
                usage = sigar.getFileSystemUsage(fs.getDirName());
            } catch (SigarException e) {
                if (fs.getType() == FileSystem.TYPE_LOCAL_DISK) {
                    throw e;
                }
                //else ok, e.g. floppy drive on windows
                continue;
            }

            switch (fs.getType()) {
              case FileSystem.TYPE_LOCAL_DISK:
                assertGtZeroTrace("  Total", usage.getTotal());
                //possible machines have full filesystems
                assertGtEqZeroTrace("  Free", usage.getFree());
                assertGtEqZeroTrace("  Avail", usage.getAvail());
View Full Code Here

    }

    public void outputFileSystem(String arg) throws SigarException {
        FileSystemMap mounts = this.proxy.getFileSystemMap();
        String name = FileCompleter.expand(arg);
        FileSystem fs = mounts.getMountPoint(name);

        if (fs != null) {
            printHeader();
            output(fs);
            return;
View Full Code Here

    private void addChildImplementations() {
        if (sigarService.sigarAvailable() && nodeEnvironment.hasNodeFile()) {
            try {
                FileSystem[] fsList = sigarService.sigar().getFileSystemList();
                for (File dataLocation : nodeEnvironment.nodeDataLocations()) {
                    FileSystem winner = null;
                    String absDataLocation = dataLocation.getCanonicalPath();
                    for (FileSystem fs : fsList) {
                        // ignore rootfs as ist might shadow another mount on /
                        if (!FileSystems.SUPPORTED_FS_TYPE.apply(fs) || "rootfs".equals(fs.getDevName())) {
                            continue;
                        }
                        if (absDataLocation.startsWith(fs.getDirName())
                                && (winner == null || winner.getDirName().length() < fs.getDirName().length())) {
                            winner = fs;
                        }
                    }
                    childImplementations.add(new NodeFsDataChildExpression(
                            winner != null ? new BytesRef(winner.getDevName()) : null,
                            new BytesRef(absDataLocation)
                    ));
                }
            } catch (Exception e) {
                logger.warn("error getting fs['data'] expression", e);
View Full Code Here

            FsStats.Info info = new FsStats.Info();
            info.path = dataLocation.getAbsolutePath();

            try {
                FileSystem fileSystem = fileSystems.get(dataLocation);
                Sigar sigar = sigarService.sigar();
                if (fileSystem == null) {
                    FileSystemMap fileSystemMap = sigar.getFileSystemMap();
                    if (fileSystemMap != null) {
                        fileSystem = fileSystemMap.getMountPoint(dataLocation.getPath());
                        fileSystems.put(dataLocation, fileSystem);
                    }
                }
                if (fileSystem != null) {
                    info.mount = fileSystem.getDirName();
                    info.dev = fileSystem.getDevName();
                    FileSystemUsage fileSystemUsage = sigar.getFileSystemUsage(fileSystem.getDirName());
                    if (fileSystemUsage != null) {
                        // total/free/available seem to be in megabytes?
                        info.total = fileSystemUsage.getTotal() * 1024;
                        info.free = fileSystemUsage.getFree() * 1024;
                        info.available = fileSystemUsage.getAvail() * 1024;
 
View Full Code Here

      FileSystem[] filesystems = sigar.getFileSystemList();
      logger.debug("file systems: {}", Arrays.toString(filesystems));

      List<String> disks = new ArrayList<String>();
      for (int i = 0; i < filesystems.length; i++) {
          FileSystem fs = filesystems[i];
          if (fs.getType() == FileSystem.TYPE_LOCAL_DISK){
            disks.add(fs.getDevName());
          }
      }
     
      logger.debug("valid disk names: {}", Arrays.toString(disks.toArray()));
    } catch (SigarException e) {
View Full Code Here

TOP

Related Classes of org.hyperic.sigar.FileSystem

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.