Package org.rhq.plugins.www.snmp

Examples of org.rhq.plugins.www.snmp.SNMPSession


        boolean configured = false;

        try {

            SNMPSession snmpSession = getSNMPSession();
            if (!snmpSession.ping()) {
                LOG.warn("Failed to connect to SNMP agent at "
                    + snmpSession
                    + "\n"
                    + ". Make sure\n1) the managed Apache server has been instrumented with the JON SNMP module,\n"
                    + "2) the Apache server is running, and\n"
View Full Code Here


            getBMXValues(report, schedules);
        else
            getSNMPValues(report, schedules);
    }
    private void getSNMPValues(MeasurementReport report, Set<MeasurementScheduleRequest> schedules) throws Exception {
        SNMPSession snmpSession = getSNMPSession();
        boolean snmpPresent = snmpSession.ping();

        for (MeasurementScheduleRequest schedule : schedules) {
            String metricName = schedule.getName();
            if (metricName.equals(SERVER_BUILT_TRAIT)) {
                MeasurementDataTrait trait = new MeasurementDataTrait(schedule, this.binaryInfo.getBuilt());
                report.addData(trait);
            } else if (metricName.equals("rhq_avail_ping_time")) {
                if (availPingTime == -1)
                    continue; // Skip if we have no data
                MeasurementDataNumeric num = new MeasurementDataNumeric(schedule, (double) availPingTime);
                report.addData(num);
            } else {
                // Assume anything else is an SNMP metric.
                if (!snmpPresent)
                    continue; // Skip this metric if no SNMP present

                try {
                    //noinspection UnnecessaryLocalVariable
                    String mibName = metricName;
                    List<SNMPValue> snmpValues = snmpSession.getColumn(mibName);
                    if (snmpValues.isEmpty()) {
                        LOG.error("No values found for MIB name [" + mibName + "].");
                        continue;
                    }
View Full Code Here

        return ApacheServerComponent.getSNMPSession(this.snmpClient, this.resourceContext.getPluginConfiguration());
    }

    @NotNull
    public static SNMPSession getSNMPSession(SNMPClient snmpClient, Configuration pluginConfig) throws Exception {
        SNMPSession snmpSession;
        try {
            String host = pluginConfig.getSimple(PLUGIN_CONFIG_PROP_SNMP_AGENT_HOST).getStringValue();
            String portString = pluginConfig.getSimple(PLUGIN_CONFIG_PROP_SNMP_AGENT_PORT).getStringValue();
            int port = Integer.valueOf(portString);
            String community = pluginConfig.getSimple(PLUGIN_CONFIG_PROP_SNMP_AGENT_COMMUNITY).getStringValue();
View Full Code Here

                    return DOWN;
                }

                //ok, so the vhost is present. Now let's just ping the SNMP module to see
                //if it is reachable and base our availability on that...
                SNMPSession snmpSession = resourceContext.getParentResourceComponent().getSNMPSession();

                return snmpSession.ping() ? UP : DOWN;
            } catch (Exception e) {
                LOG.debug("Determining the availability of the vhost [" + resourceContext.getResourceKey()
                    + "] using SNMP failed.", e);
                return DOWN;
            }
View Full Code Here

            getBMXValues(report, schedules);
        else
            getSNMPValues(report, schedules);
    }
    private void getSNMPValues(MeasurementReport report, Set<MeasurementScheduleRequest> schedules) throws Exception {
        SNMPSession snmpSession = this.resourceContext.getParentResourceComponent().getSNMPSession();
        int primaryIndex = getWwwServiceIndex();
        boolean ping = snmpSession.ping();
        boolean snmpMetricsSupported = primaryIndex >= 0 && ping;

        if (LOG.isDebugEnabled()) {
            if (snmpMetricsSupported) {
                LOG.debug("SNMP metrics collection supported for VirtualHost service #" + primaryIndex);
View Full Code Here

TOP

Related Classes of org.rhq.plugins.www.snmp.SNMPSession

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.