Package org.rhq.core.system

Examples of org.rhq.core.system.ProcessInfo


            long now = new Date().getTime();

            if (now - lastManagementInterfaceReply > MAX_TIMEOUT_FAILURE_WAIT) {
                availabilityType = DOWN;
            } else {
                ProcessInfo processInfo = context.getNativeProcess();
                if (processInfo != null && processInfo.priorSnaphot().isRunning()) {
                    availabilityType = previousAvailabilityType;
                } else {
                    availabilityType = DOWN;
                }
            }
View Full Code Here


    public DiscoveredResourceDetails discoverResource(Configuration pluginConfig, ResourceDiscoveryContext context)
        throws InvalidPluginConfigurationException {

        ProcessComponentConfig processComponentConfig = createProcessComponentConfig(pluginConfig);

        ProcessInfo processInfo;
        try {
            processInfo = findProcess(processComponentConfig, context.getSystemInformation());
        } catch (Exception e) {
            throw new RuntimeException("Failed to manually add process Resource based on plugin config: "
                + pluginConfig.toString(true), e);
        }

        String resourceKey, resourceDescription;
        switch (processComponentConfig.getType()) {
        case pidFile:
            resourceKey = processComponentConfig.getPidFile();
            resourceDescription = processInfo.getBaseName() + " process with PID file [" + resourceKey + "]";
            break;
        case piql:
            resourceKey = processComponentConfig.getPiql();
            resourceDescription = processInfo.getBaseName() + " process with PIQL expression [" + resourceKey + "]";
            break;
        default:
            throw new InvalidPluginConfigurationException("Unknown type: " + processComponentConfig.getType());
        }

        return new DiscoveredResourceDetails(context.getResourceType(), resourceKey, processInfo.getBaseName(),
            null /*version*/, resourceDescription, pluginConfig, processInfo);
    }
View Full Code Here

     * Return availability of this resource
     *  @see org.rhq.core.pluginapi.inventory.ResourceComponent#getAvailability()
     */
    @Override
    public AvailabilityType getAvailability() {
        ProcessInfo process = getResourceContext().getNativeProcess();

        // It is safe to read prior snapshot as getNativeProcess always return a fresh instance
        AvailabilityType ret = process == null ? AvailabilityType.DOWN
            : (process.priorSnaphot().isRunning() ? AvailabilityType.UP : AvailabilityType.DOWN);

        EventContext events = getResourceContext().getEventContext();
        if (events != null) {
            if (ret == AvailabilityType.UP) {
                if (!eventsRegistered) {
View Full Code Here

        }

        if (processComponentConfig.isFullProcessTree()) {
            return new AggregateProcessInfo(pid);
        } else {
            return new ProcessInfo(pid);
        }
    }
View Full Code Here

                    throw new InvalidPluginConfigurationException("Invalid password");
                }
            }
            throw new InvalidPluginConfigurationException("Cannot open database connection", e);
        }
        ProcessInfo processInfo = resourceContext.getNativeProcess();
        if (processInfo != null) {
            aggregateProcessInfo = processInfo.getAggregateProcessTree();
        } else {
            findProcessInfo();
        }
        File configFile = getConfigurationFileObject();
        if (!configFile.exists()) {
View Full Code Here

            JBossConnectionTypeDescriptor.class.getName()));

        // Set default values on any props that are not set.
        setPluginConfigurationDefaults(pluginConfiguration);

        ProcessInfo processInfo = null;
        String jbossHomeDir = pluginConfiguration.getSimpleValue(JBossASServerComponent.JBOSS_HOME_DIR_CONFIG_PROP,
            null);// this will never be null
        JBossInstallationInfo installInfo;
        try {
            installInfo = new JBossInstallationInfo(new File(jbossHomeDir));
View Full Code Here

    private void processAutoDiscoveredProcesses(ResourceDiscoveryContext context,
        Set<DiscoveredResourceDetails> resources, DiscoveredResourceDetails jbossPcIsEmbeddedIn) {
        List<ProcessScanResult> autoDiscoveryResults = context.getAutoDiscoveredProcesses();
        for (ProcessScanResult autoDiscoveryResult : autoDiscoveryResults) {
            ProcessInfo processInfo = autoDiscoveryResult.getProcessInfo();
            if (log.isDebugEnabled())
                log.debug("Discovered JBoss AS process: " + processInfo);

            JBossInstanceInfo cmdLine;
            try {
                cmdLine = new JBossInstanceInfo(processInfo);
            } catch (Exception e) {
                log.error("Failed to process JBoss AS command line: " + Arrays.asList(processInfo.getCommandLine()), e);
                continue;
            }

            // See if we have an AS 5 or AS 6 - if so, skip it.
            JBossInstallationInfo installInfo = cmdLine.getInstallInfo();
            String version = installInfo.getVersion();
            if (version.startsWith("5") || version.startsWith("6")) {
                if (log.isDebugEnabled())
                    log.debug("Found JBoss AS 5.0 or later, which is not supported by this plugin - skipping...");
                continue;
            }

            File installHome = new File(cmdLine.getSystemProperties().getProperty(JBossProperties.HOME_DIR));
            File configDir = new File(cmdLine.getSystemProperties().getProperty(JBossProperties.SERVER_HOME_DIR));

            if ((jbossPcIsEmbeddedIn != null)
                && jbossPcIsEmbeddedIn.getPluginConfiguration()
                    .getSimple(JBossASServerComponent.CONFIGURATION_PATH_CONFIG_PROP).getStringValue()
                    .equals(configDir.getAbsolutePath())) {
                // We're running embedded, and the JBossAS server we're embedded in has already been found.
                continue;
            }

            // The config dir might be a symlink - call getCanonicalFile() to resolve it if so, before
            // calling isDirectory() (isDirectory() returns false for a symlink, even if it points at
            // a directory).
            try {
                if (!configDir.getCanonicalFile().isDirectory()) {
                    log.warn("Skipping discovery for JBoss AS process " + processInfo + ", because configuration dir '"
                        + configDir + "' does not exist or is not a directory.");
                    continue;
                }
            } catch (IOException e) {
                log.error("Skipping discovery for JBoss AS process " + processInfo + ", because configuration dir '"
                    + configDir + "' could not be canonicalized.", e);
                continue;
            }

            Configuration pluginConfiguration = context.getDefaultPluginConfiguration();

            String jnpURL = getJnpURL(cmdLine, installHome, configDir);

            // Set the connection type (used by JMX plugin to connect to the MBean server).
            pluginConfiguration.put(new PropertySimple(JMXDiscoveryComponent.CONNECTION_TYPE,
                JBossConnectionTypeDescriptor.class.getName()));

            // Set the required props...
            pluginConfiguration.put(new PropertySimple(JBossASServerComponent.NAMING_URL_CONFIG_PROP, jnpURL));
            pluginConfiguration.put(new PropertySimple(JBossASServerComponent.JBOSS_HOME_DIR_CONFIG_PROP, installHome
                .getAbsolutePath()));
            pluginConfiguration
                .put(new PropertySimple(JBossASServerComponent.CONFIGURATION_PATH_CONFIG_PROP, configDir));

            // Set the optional props...
            pluginConfiguration.put(new PropertySimple(JBossASServerComponent.CONFIGURATION_SET_CONFIG_PROP, cmdLine
                .getSystemProperties().getProperty(JBossProperties.SERVER_NAME)));
            pluginConfiguration.put(new PropertySimple(JBossASServerComponent.BINDING_ADDRESS_CONFIG_PROP, cmdLine
                .getSystemProperties().getProperty(JBossProperties.BIND_ADDRESS)));

            JBossASDiscoveryUtils.UserInfo userInfo = JBossASDiscoveryUtils.getJmxInvokerUserInfo(configDir);
            if (userInfo != null) {
                pluginConfiguration.put(new PropertySimple(JBossASServerComponent.PRINCIPAL_CONFIG_PROP, userInfo
                    .getUsername()));
                pluginConfiguration.put(new PropertySimple(JBossASServerComponent.CREDENTIALS_CONFIG_PROP, userInfo
                    .getPassword()));
            }

            String javaHome = processInfo.getEnvironmentVariable(JAVA_HOME_ENV_VAR);
            if (javaHome == null && log.isDebugEnabled()) {
                log.debug("JAVA_HOME environment variable not set in JBoss AS process - defaulting "
                    + JBossASServerComponent.JAVA_HOME_PATH_CONFIG_PROP
                    + " connection property to the plugin container JRE dir.");
            }
View Full Code Here

        @SuppressWarnings("unchecked")
        List<ProcessScanResult> autoDiscoveryResults = context.getAutoDiscoveredProcesses();
        for (ProcessScanResult result : autoDiscoveryResults) {
            LOG.info("Discovered a postgres process: " + result);

            ProcessInfo procInfo = result.getProcessInfo();

            String pgDataPath = getDataDirPath(procInfo);
            if (pgDataPath == null) {
                LOG.error("Unable to obtain data directory for postgres process with pid " + procInfo.getPid()
                    + " (tried checking both -D command line argument, as well as " + PGDATA_ENV_VAR
                    + " environment variable).");
                continue;
            }
View Full Code Here

            String serverName = (pre42) ? "Tomcat" : "JBossWeb";
            String version = getVersion(jbossWebDir);
            String description = "JBossAS-Embedded " + serverName + " Web Server (" + jbossWebDir.getName()
                + File.separator + ")";
            Configuration pluginConfig = null;
            ProcessInfo processInfo = null;
            DiscoveredResourceDetails resource = new DiscoveredResourceDetails(context.getResourceType(), key,
                getResourceName(pre42), version, description, pluginConfig, processInfo);
            set.add(resource);
        }
View Full Code Here

        avail = getAvailability(getServerResource());
        assertEquals(avail, AvailabilityType.UP);

        List<ProcessInfo> processes = getServerProcesses();
        //Assert.assertEquals(processes.size(), 1, getCommandLines(processes).toString());
        ProcessInfo serverProcess = processes.get(0);
        Map<String, String> processEnv = serverProcess.getEnvironmentVariables();
        assertEquals(processEnv.get("FOO"), "bar", processEnv.toString());

        List<String> processArgs = Arrays.asList(serverProcess.getCommandLine());
        assertTrue(processArgs.contains("-Dfoo=bar"), processArgs.toString());
    }
View Full Code Here

TOP

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

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.