From: jrallen9 <jus...@te...> - 2010-01-08 18:57:54
|
I was able to correct the problem I described in this thread. I should have added a try/catch block for SigarFileNotFoundException as this code shows: FileSystem[] devices = session.getFileSystemList(); for (FileSystem dev : devices){ try{ switch(dev.getType()){ case FileSystem.TYPE_LOCAL_DISK: DiskUsage disk = session.getDiskUsage(dev.getDirName()); log.debug("DiskUsage for " + dev.getDirName() + " = " + disk.toString()); // do more stuff with the disk object break; case FileSystem.TYPE_CDROM: //Do nothing with CD-ROMS and Removable Disks break; case FileSystem.TYPE_NETWORK: //Ignore Network Shares at this time. break; default: break; } }catch(SigarFileNotFoundException e) { log.debug(dev.getDirName() + "...\n " + e.getMessage()); } As this code shows, getting a FileSystem list of mapped drive letter devices available on the system is useful for accessing DiskUsage information, but has the a problem in that not all devices are accessible even though its mapped by NTFS to a drive letter. To correct this I moved the problematic code under a case statement where the FileSystem type is a local disk (this was the only type I cared about). I also added the try/catch to log the error and continue on with execution. @Doug - I think the documentation under Sigar.getDiskUsage( String name) should be clarified to provide better descriptions on when SigarFileNotFoundExceptions are thrown. There must be a better way to indicate when a mapped drive letter is accessible for statistic collections. Perhaps at least the documentation should specify an approach to testing for stats accessibility prior to making calls to stats collections. I just want to add a thank you for the hard work which has gone into developing SIGAR. It's a great utility tool and has made Windows performance monitoring accessible for developers. I've looked at the WindowsAPI and its a beast, but the dlls provided have made a great interface for Java program development. |