FileDocCategorySizeDatePackage
WindowsSystemInfoCollector.javaAPI DocGlassfish v2 API3941Fri May 04 22:34:44 BST 2007com.sun.enterprise.diagnostics.collect

WindowsSystemInfoCollector

public class WindowsSystemInfoCollector extends Object implements Collector
Class to collect System Information for Windows OS

Fields Summary
private static Logger
logger
private static final String
MEMORY_INFO_CMD
private static final String
IP_ADDRESS_INFO_CMD
private static final String
HOST_NAME_CMD
private static final String
OS_INFO_CMD
private String
destFolder
Constructors Summary
public WindowsSystemInfoCollector(String destFolder)



      
        this.destFolder = destFolder;
    
Methods Summary
public com.sun.enterprise.diagnostics.Datacapture()
To capture the system information for Windows OS

return
Data representing System Information


        FileData data = null;

        String outputFileName = destFolder + File.separator + Defaults.SYSTEM_INFO_FILE;

        final String ALL_CMDS =

                "(echo HOSTNAME & "+HOST_NAME_CMD+" & " +
                        "echo OS INFO & "+ OS_INFO_CMD +" & " +
                        "echo MEMORY INFO & " + MEMORY_INFO_CMD  + " & " +
        "echo IP ADDRESS & " + IP_ADDRESS_INFO_CMD + ") >> " + outputFileName ;


        String[] cmd = {"cmd.exe", "/C", ALL_CMDS};

        ProcessExecutor executor = new ProcessExecutor(cmd, 0);
        try{
        executor.execute();

        File outputFile = new File(outputFileName);

        data = new FileData(outputFile.getName(),DataType.SYSTEM_INFO);

        }
        catch(ProcessExecutorException pee){
            logger.log(Level.WARNING, "Exception while capturing system info" +
                     " : " + pee.getMessage());
        }
        
        return data;