Package org.rhq.core.domain.measurement

Examples of org.rhq.core.domain.measurement.MeasurementDataNumeric


                report.addData(new MeasurementDataTrait(request, componentConfiguration.getAddress()
                    .getCanonicalHostName()));
            } else if (request.getName().equals("connectTime")) {
                long start = System.currentTimeMillis();
                if (portReachable()) {
                    report.addData(new MeasurementDataNumeric(request, (double) (System.currentTimeMillis() - start)));
                }
            }
        }
    }
View Full Code Here


                if (attribute != null) {
                    Object valueObject = attribute.refresh();
                    if (valueObject instanceof Number) {
                        Number value = (Number) valueObject;
                        if (percentageMeasurements.get(name)) {
                            report.addData(new MeasurementDataNumeric(request, value.doubleValue() / 100));
                        } else {
                            report.addData(new MeasurementDataNumeric(request, value.doubleValue()));
                        }

                    } else {
                        report.addData(new MeasurementDataTrait(request, valueObject.toString()));
                    }
View Full Code Here

                    attributes.add(m.group(2));
                    eBean.refreshAttributes(attributes);
                    EmsAttribute emsAtt = eBean.getAttribute(m.group(2));
                    Object value = emsAtt.getValue();
                    if ((request.getDataType() == DataType.MEASUREMENT) && (value instanceof Number)) {
                        report.addData(new MeasurementDataNumeric(request, ((Number) value).doubleValue()));
                    } else if (request.getDataType() == DataType.TRAIT) {
                        String displayValue = null;
                        if ((value != null) && value.getClass().isArray()) {
                            displayValue = Arrays.deepToString((Object[]) value);
                        } else {
View Full Code Here

    }

    private void addCpuMetric(String element, MeasurementReport report, MeasurementScheduleRequest request,
        CpuMetricGatherer cpuMetricGatherer) {
        if (element.equals("user")) {
            report.addData(new MeasurementDataNumeric(request, cpuMetricGatherer.getUser()));
        } else if (element.equals("sys")) {
            report.addData(new MeasurementDataNumeric(request, cpuMetricGatherer.getSys()));
        } else if (element.equals("percent")) {
            report.addData(new MeasurementDataNumeric(request, cpuMetricGatherer.getPercent()));
        }
    }
View Full Code Here

    }

    private void addMemoryMetric(String element, MeasurementReport report, MeasurementScheduleRequest request,
        MemoryMetricGatherer memoryMetricGatherer) {
        if (element.equals("resident")) {
            report.addData(new MeasurementDataNumeric(request, memoryMetricGatherer.getResident()));
        } else if (element.equals("size")) {
            report.addData(new MeasurementDataNumeric(request, memoryMetricGatherer.getSize()));
        }
    }
View Full Code Here

    }

    private void addFileDescriptorMetric(String element, MeasurementReport report, MeasurementScheduleRequest request,
        FileDescriptorMetricGatherer fileDescriptorMetricGatherer) {
        if (element.equals("total")) {
            report.addData(new MeasurementDataNumeric(request, fileDescriptorMetricGatherer.getTotal()));
        }
    }
View Full Code Here

                    Object val = lookupAttributeProperty(aggregateProcessInfo,
                        metricName.substring("Process.".length()));
                    if (val != null && val instanceof Number) {
                        //                        aggregateProcessInfo.getAggregateMemory().Cpu().getTotal()
                        report.addData(new MeasurementDataNumeric(request, ((Number) val).doubleValue()));
                    }
                }
            } else if (metricName.startsWith("Database")) {
                if (metricName.endsWith("startTime")) {
                    // db start time
                    Connection jdbcConnection = null;
                    Statement statement = null;
                    ResultSet resultSet = null;
                    try {
                        jdbcConnection = getPooledConnectionProvider().getPooledConnection();
                        statement = jdbcConnection.createStatement();
                        resultSet = statement.executeQuery("SELECT pg_postmaster_start_time()");
                        if (resultSet.next()) {
                            report.addData(new MeasurementDataTrait(request, resultSet.getTimestamp(1).toString()));
                        }
                    } catch (SQLException e) {
                        if (LOG.isDebugEnabled()) {
                            LOG.debug("Can not collect metric: " + metricName + ": " + e.getLocalizedMessage());
                        }
                    } finally {
                        DatabasePluginUtil.safeClose(jdbcConnection, statement, resultSet);
                    }
                } else if (metricName.endsWith("backends")) {
                    // number of connected backends
                    Connection jdbcConnection = null;
                    Statement statement = null;
                    ResultSet resultSet = null;
                    try {
                        jdbcConnection = getPooledConnectionProvider().getPooledConnection();
                        statement = jdbcConnection.createStatement();
                        resultSet = statement.executeQuery("select count(*) from pg_stat_activity");
                        if (resultSet.next()) {
                            report.addData(new MeasurementDataNumeric(request, (double) resultSet.getLong(1)));
                        }
                    } catch (SQLException e) {
                        if (LOG.isDebugEnabled()) {
                            LOG.debug("Can not collect metricName: " + metricName + ": " + e.getLocalizedMessage());
                        }
View Full Code Here

                    property = property.substring(property.indexOf(".") + 1);
                    Long longValue = (Long) ObjectUtil.lookupAttributeProperty(cpu, property);
                    // A value of -1 indicates SIGAR does not support the metric on the Agent platform type.
                    if (longValue != null && longValue != -1) {
                        report.addData(new MeasurementDataNumeric(request, longValue.doubleValue()));
                    }
                } else if (property.startsWith("CpuPerc.")) {

                    /*
                     * ! we no longer use the SIGAR CpuPerc object to report cpu percentage metrics. See
                     * ! RHQ-245 for an explanation.  We now calculate our own percentages using
                     * ! the current raw cpu info from Sigar and the previous cpu numbers, cached per metric.
                     * ! This allows us to avoid the problem in RHQ-245 while handling perCpu-perMetric schedule
                     * ! granularity.
                     */

                    // Grab the current cpu info from SIGAR, only once for this cpu for all processed schedules
                    if (null == cpu) {
                        cpu = cpuInformation.getCpu();
                    }
                    // Create a Cpu cacheEntry only once for this cpu for all processed schedules
                    if (null == currentCpu) {
                        currentCpu = new CpuEntry(cpu);
                    }

                    // Get the previous cpu numbers to be used for this metric and update the cache for the next go.
                    CpuEntry previousCpu = cpuCache.put(property, currentCpu);
                    previousCpu = (null == previousCpu) ? startCpuEntry : previousCpu;

                    // if for some reason the delta time is excessive then toss the metric, since it depends
                    // on a reasonable interval between prev and curr. This can happen due to avail down or a newly
                    // activated metric. Allow up to twice the metric interval. If the metric interval is
                    // 0 (for a live data request) then just use a 10 minute interval.
                    Number num = null;
                    long deltaTime = currentCpu.getTimestamp() - previousCpu.getTimestamp();
                    long metricInterval = (0 < request.getInterval()) ? request.getInterval() : 600000L;

                    if (deltaTime <= (2 * metricInterval)) {
                        // Use the same calculation that SIGAR uses to generate the percentages. The difference is that
                        // we use a safe "previous" cpu record.                     
                        num = getPercentage(previousCpu.getCpu(), cpu, property);
                    }

                    // Uncomment to see details about the calculations.
                    //System.out.println("\nCPU-" + cpuInformation.getCpuIndex() + " Interval="
                    //    + ((currentCpu.getTimestamp() - previousCpu.getTimestamp()) / 1000) + " " + property + "="
                    //    + num + "\n   Prev=" + previousCpu + "\n   Curr=" + currentCpu);

                    if (num != null) {
                        report.addData(new MeasurementDataNumeric(request, num.doubleValue()));
                    }
                } else if (property.startsWith("CpuInfo.")) {
                    if (cpuInfo == null) {
                        cpuInfo = cpuInformation.getCpuInfo();
                    }

                    property = property.substring(property.indexOf(".") + 1);
                    Number num = ((Number) ObjectUtil.lookupAttributeProperty(cpuInfo, property));
                    if (num != null) {
                        report.addData(new MeasurementDataNumeric(request, num.doubleValue()));
                    }
                } else if (property.startsWith("CpuTrait.")) {
                    if (cpuInfo == null) {
                        cpuInfo = cpuInformation.getCpuInfo();
                    }
View Full Code Here

           } else if (request.getName().equals("total")) {
               value = Double.valueOf(dirUsage.getTotal());
           }

           if (value!=null) {
               MeasurementDataNumeric result = new MeasurementDataNumeric(request, value);
               report.addData(result);
           }
       }
   }
View Full Code Here

    public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> metrics) throws Exception {
        Map<String, Double> values = getNumericQueryValues(this, SESSIONS, this.resourceContext.getResourceKey());
        for (MeasurementScheduleRequest request : metrics) {
            Double d = values.get(request.getName().toUpperCase(Locale.US));
            if (d != null) {
                report.addData(new MeasurementDataNumeric(request, d));
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.measurement.MeasurementDataNumeric

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.