Package org.rhq.core.system

Examples of org.rhq.core.system.SystemInfo


        long start = System.currentTimeMillis();
        if (log.isDebugEnabled()) {
            log.debug("About to execute the following process: [" + processExecution + "]");
        }
        SystemInfo systemInfo = serverComponent.getResourceContext().getSystemInformation();
        ProcessExecutionResults results = systemInfo.executeProcess(processExecution);
        logExecutionResults(results);

        if (results.getError() == null) {
            avail = waitForServerToStart(start);
        } else {
View Full Code Here


        processExecution.getEnvironmentVariables().put("NOPAUSE", "1");

        if (log.isDebugEnabled()) {
            log.debug("About to execute the following process: [" + processExecution + "]");
        }
        SystemInfo systemInfo = serverComponent.getResourceContext().getSystemInformation();
        ProcessExecutionResults results = systemInfo.executeProcess(processExecution);
        logExecutionResults(results);

        if (results.getError() != null || (results.getExitCode() != null && results.getExitCode() != 0)) {
            throw new ExecutionFailedException(
                "Error executing shutdown script while stopping AS instance. Shutdown script returned exit code ["
View Full Code Here

        } catch (Exception e) {
            LOG.warn("Failed to canonicalize catalina.base path [" + catalinaBase + "] - cause: " + e);
            // leave as is
        }

        SystemInfo systemInfo = discoveryContext.getSystemInformation();
        String hostname = systemInfo.getHostname();
        String version = UNKNOWN_VERSION;
        String port = UNKNOWN_PORT;
        String address = null;

        // TODO : Should we even allow this remote server stuff? I think we risk a resourceKey collision with a local
View Full Code Here

                    + Arrays.toString(commandLine));
            return null;
        }

        // Pull out data from the discovery call
        SystemInfo systemInfo = context.getSystemInformation();
        String hostname = systemInfo.getHostname();
        TomcatConfig tomcatConfig = parseTomcatConfig(catalinaBase);
        tomcatConfig = applySystemProperties(tomcatConfig, commandLine);

        // Create pieces necessary for the resource creation
        String resourceVersion = determineVersion(catalinaHome, catalinaBase, systemInfo);
View Full Code Here

            component.getResourceContext(), false, profileServiceConnection);

        if (ScriptComponent.TYPE_NAME.equals(resourceType.getName())) {
            String jbossHome = component.getResourceContext().getPluginConfiguration()
                .getSimpleValue(ApplicationServerPluginConfigurationProperties.HOME_DIR, null);
            SystemInfo systemInfo  = component.getResourceContext().getSystemInformation();
            return new ScriptDeployer(jbossHome, systemInfo, downloader);
        } else {
            return new ManagedComponentDeployer(profileServiceConnection, downloader, parentResourceContext);
        }
    }
View Full Code Here

            List<ApacheDirective> directives = tree.search("/ServerRoot");
            if (!directives.isEmpty())
                if (!directives.get(0).getValues().isEmpty())
                    serverRoot = directives.get(0).getValues().get(0);

            SystemInfo systemInfo = this.resourceContext.getSystemInformation();
            if (systemInfo.getOperatingSystemType() != OperatingSystemType.WINDOWS) // UNIX
            {
                // Try some combinations in turn
                executableFile = new File(serverRoot, "bin/httpd");
                if (!executableFile.exists()) {
                    executableFile = new File(serverRoot, "bin/apache2");
View Full Code Here

        if (!this.launcherScript.exists()) {
            throw new Exception("Launcher script [" + this.launcherScript + "] does not exist");
        }

        final File script = this.launcherScript;
        final SystemInfo sysInfo = this.resourceContext.getSystemInformation();

        Thread thread = new Thread(new Runnable() {
            public void run() {
                try {
                    Thread.sleep(10000L); // this should be enough to return our operation results back
                    ProcessExecution exe = new ProcessExecution(script.getAbsolutePath());
                    exe.setArguments(new String[] { arg });
                    exe.setWorkingDirectory(script.getParent());
                    ProcessExecutionResults results = sysInfo.executeProcess(exe);
                    if (results != null && results.getError() != null) {
                        throw results.getError();
                    }
                } catch (Throwable t) {
                    log.error("Failed to invoke [" + script + ' ' + arg + "] in a thread", t);
View Full Code Here

        properties.setProperty("JVM_OPTS", jvmOpts);

        propertiesUpdater.update(properties);

        File binDir = new File(deploymentOptions.getBasedir(), "bin");
        SystemInfo systemInfo = SystemInfoFactory.createSystemInfo();

        ProcessExecution processExecution = getProcessExecution(binDir);
        ProcessExecutionResults results = systemInfo.executeProcess(processExecution);

        assertEquals(results.getExitCode(), (Integer) 0, "Cassandra failed to start: " + results.getCapturedOutput());
    }
View Full Code Here

        if (!this.launcherScript.exists()) {
            throw new Exception("Launcher script [" + this.launcherScript + "] does not exist");
        }

        final File script = this.launcherScript;
        final SystemInfo sysInfo = this.resourceContext.getSystemInformation();

        Thread thread = new Thread(new Runnable() {
            public void run() {
                try {
                    Thread.sleep(10000L); // this should be enough to return our operation results back
                    ProcessExecution exe = new ProcessExecution(script.getAbsolutePath());
                    exe.setArguments(new String[] { arg });
                    exe.setWorkingDirectory(script.getParent());
                    ProcessExecutionResults results = sysInfo.executeProcess(exe);
                    if (results != null && results.getError() != null) {
                        throw results.getError();
                    }
                } catch (Throwable t) {
                    log.error("Failed to invoke [" + script + ' ' + arg + "] in a thread", t);
View Full Code Here

        report.setStatus(ConfigurationUpdateStatus.FAILURE);
        return;
    }

    public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> metrics) {
        SystemInfo info = this.resourceContext.getSystemInformation();
        boolean isNative = info.isNative();
        Mem platformMemoryInfo = null;
        Swap platformSwapInfo = null;
        CpuPerc cpuPerc = null;
        try {
            cpuPerc = SigarAccess.getSigar().getCpuPerc();
        } catch (Exception e) {
            // probably native api is unavailable, but getCpuPerc might also have a problem; in either case, nothing we can do
        }

        for (MeasurementScheduleRequest request : metrics) {
            String property = request.getName();

            if (property.startsWith(NATIVE_INDICATOR)) {
                // we cannot collect a native measurement without native support - go on to the next
                if (!isNative) {
                    continue;
                }
                property = property.substring(NATIVE_INDICATOR.length());
            }

            if (property.startsWith(TRAIT_INDICATOR)) {
                report.addData(getMeasurementDataTrait(request));
            } else if (property.startsWith("MemoryInfo.")) {
                if (platformMemoryInfo == null) {
                    platformMemoryInfo = info.getMemoryInfo();
                }

                property = property.substring(property.indexOf(".") + 1);
                double memoryValue = ((Number) getObjectProperty(platformMemoryInfo, property)).doubleValue();
                report.addData(new MeasurementDataNumeric(request, memoryValue));
            } else if (property.startsWith("SwapInfo.")) {
                if (platformSwapInfo == null) {
                    platformSwapInfo = info.getSwapInfo();
                }
                if (platformSwapInfo != null) {
                    property = property.substring(property.indexOf(".") + 1);
                    double swapValue = ((Number) getObjectProperty(platformSwapInfo, property)).doubleValue();
                    report.addData(new MeasurementDataNumeric(request, swapValue));
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.