Package org.rhq.core.system

Examples of org.rhq.core.system.SystemInfo


    }

    @Test
    @OperateOnDeployment("with-native")
    public void testNativeSystemInfoAvailable() {
        SystemInfo info = SystemInfoFactory.createSystemInfo();
        Assert.assertNotEquals(info.getClass(), JavaSystemInfo.class);
    }
View Full Code Here


    }

    @Test
    @OperateOnDeployment("without-native")
    public void testJavaSystemInfoUsed() {
        SystemInfo info = SystemInfoFactory.createSystemInfo();
        Assert.assertEquals(info.getClass(), JavaSystemInfo.class);
    }
View Full Code Here

     * @see    ResourceType#getProcessScans()
     */
    public List<ProcessScanResult> getNativeProcessesForType() {
        // perform auto-discovery PIQL queries now to see if we can auto-detect resources that are running now of this type
        List<ProcessScanResult> scanResults = new ArrayList<ProcessScanResult>();
        SystemInfo systemInfo = SystemInfoFactory.createSystemInfo();

        try {
            Set<ProcessScan> processScans = this.resource.getResourceType().getProcessScans();
            if (processScans != null && !processScans.isEmpty()) {
                ProcessInfoQuery piq = new ProcessInfoQuery(systemInfo.getAllProcesses());
                for (ProcessScan processScan : processScans) {
                    List<ProcessInfo> queryResults = piq.query(processScan.getQuery());
                    if ((queryResults != null) && (queryResults.size() > 0)) {
                        for (ProcessInfo autoDiscoveredProcess : queryResults) {
                            scanResults.add(new ProcessScanResult(processScan, autoDiscoveredProcess));
View Full Code Here

        if (log.isDebugEnabled()) {
            log.debug("Starting node at " + basedir);
        }
        File binDir = new File(basedir, "bin");
        File startScript;
        SystemInfo systemInfo = SystemInfoFactory.createSystemInfo();
        ProcessExecution startScriptExe;

        if (systemInfo.getOperatingSystemType() == OperatingSystemType.WINDOWS) {
            startScript = new File(binDir, "cassandra.bat");
            startScriptExe = ProcessExecutionUtility.createProcessExecution(startScript);
        } else {
            startScript = new File(binDir, "cassandra");
            startScriptExe = ProcessExecutionUtility.createProcessExecution(startScript);
            startScriptExe.addArguments(Arrays.asList("-p", "cassandra.pid"));
        }

        startScriptExe.setWaitForCompletion(0);

        ProcessExecutionResults results = systemInfo.executeProcess(startScriptExe);
        if (log.isDebugEnabled()) {
            log.debug(startScript + " returned with exit code [" + results.getExitCode() + "]");
        }

        return results;
View Full Code Here

                out.println(MSG.getMsg(AgentI18NResourceKeys.NATIVE_ENABLE_DONE));
                break;
            }

            case 'o': {
                SystemInfo sysInfo = SystemInfoFactory.createSystemInfo();

                // careful - I chose to only output things that I know the non-native Java sysinfo can support
                out.println(MSG.getMsg(AgentI18NResourceKeys.NATIVE_OS_OUTPUT, sysInfo.getOperatingSystemName(),
                    sysInfo.getOperatingSystemVersion(), sysInfo.getHostname()));

                break;
            }

            case 'p': {
                SystemInfo sysInfo = SystemInfoFactory.createSystemInfo();
                String verboseOpt = getopt.getOptarg();
                boolean verbose = (verboseOpt != null)
                    && verboseOpt.equals(MSG.getMsg(AgentI18NResourceKeys.NATIVE_VERBOSE));

                try {
                    List<ProcessInfo> processes = sysInfo.getAllProcesses();
                    if (verbose) {
                        out.println(MSG.getMsg(AgentI18NResourceKeys.NATIVE_PS_OUTPUT_VERBOSE_HEADER));
                    } else {
                        out.println(MSG.getMsg(AgentI18NResourceKeys.NATIVE_PS_OUTPUT_SHORT_HEADER));
                    }
View Full Code Here

            out.println(MSG.getMsg(AgentI18NResourceKeys.HELP_SYNTAX_LABEL, getSyntax()));
            return true;
        }

        try {
            SystemInfo info = SystemInfoFactory.createSystemInfo();
            List<ProcessInfo> processes = info.getAllProcesses();
            ProcessInfoQuery query = new ProcessInfoQuery(processes);
            List<ProcessInfo> results = query.query(piql);

            out.println(MSG.getMsg(AgentI18NResourceKeys.PIQL_RESULTS_HEADER, piql));
View Full Code Here

        }

        out.println(MSG.getMsg(AgentI18NResourceKeys.EXECUTE_WILL_WAIT, Long.valueOf(waitTime)));

        // now execute the process
        SystemInfo systemInfo = SystemInfoFactory.createSystemInfo();
        ProcessExecution processExecution = new ProcessExecution(executable);
        processExecution.setArguments(procArgArray);
        processExecution.setEnvironmentVariables(environmentVars);
        processExecution.setWorkingDirectory(workingDir);
        processExecution.setWaitForCompletion(waitTime);
        processExecution.setCaptureOutput(capture);
        processExecution.setKillOnTimeout(killOnTimeout);

        ProcessExecutionResults results = systemInfo.executeProcess(processExecution);

        Integer exitCode = results.getExitCode();
        Throwable error = results.getError();
        String output = results.getCapturedOutput();
View Full Code Here

                args.add("-jar");
                args.add(aud.getAgentUpdateBinaryFile().getAbsolutePath());
                args.add("--pause=" + ((numThreadsStillAlive > 0) ? alivePause : pause));
                args.add("--update=" + this.agent.getAgentHomeDirectory());

                SystemInfo sysInfo = SystemInfoFactory.createSystemInfo();
                ProcessExecution processExecution = new ProcessExecution(javaExe);
                processExecution.setArguments(args);
                //processExecution.setEnvironmentVariables(envvars);
                processExecution.setWorkingDirectory(new File(this.agent.getAgentHomeDirectory()).getParent());
                processExecution.setCaptureOutput(false);
                processExecution.setWaitForCompletion(0);
                showMessage(AgentI18NResourceKeys.UPDATE_THREAD_EXECUTING_UPDATE_PROCESS, processExecution);
                ProcessExecutionResults results = sysInfo.executeProcess(processExecution);
                if (results.getError() != null) {
                    throw results.getError();
                }

                // update has started! if this agent is running in non-daemon mode, kill
View Full Code Here

    @Override
    public String readLine() throws IOException {
        String input;

        SystemInfo systemInfo = SystemInfoFactory.createSystemInfo();
        if ((systemInfo == null) || !systemInfo.isNative() || !isConsole()) {
            input = super.readLine();
        } else {
            input = systemInfo.readLineFromConsole(false);
        }

        return input;
    }
View Full Code Here

    @Override
    public String readLineNoEcho() throws IOException {
        String input = null;

        SystemInfo systemInfo = SystemInfoFactory.createSystemInfo();
        if ((systemInfo == null) || !systemInfo.isNative() || !isConsole()) {
            input = super.readLine();
        } else {
            while (true) {
                // get the answer the first time
                input = systemInfo.readLineFromConsole(true);

                // get the answer a second time
                systemInfo.writeLineToConsole(agent.getI18NMsg().getMsg(AgentI18NResourceKeys.PROMPT_CONFIRM));
                String confirmation = systemInfo.readLineFromConsole(true);
                systemInfo.writeLineToConsole("\n");

                // make sure the first and second answers match; otherwise, ask again
                if (input.equals(confirmation)) {
                    break;
                }

                systemInfo.writeLineToConsole(agent.getI18NMsg().getMsg(AgentI18NResourceKeys.PROMPT_CONFIRM_FAILED));
            }
        }

        return input;
    }
View Full Code Here

TOP

Related Classes of org.rhq.core.system.SystemInfo

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.