public static final BigDecimal toMetricValue(Counter32 counter32){ if(counter32!=null) return new BigDecimal(counter32.getValue()); return BigDecimal.ZERO; }
/** * Return the value in the given 32-bit counter. * * @param c The 32-bit counter. * @return A double value configured in the given counter. * Node that zero is returned if {@code c} is invalid. */ public static double doubleValue(Counter32 c) { if (c != null) { Long v = c.getValue(); if (v != null) { return v.doubleValue(); } } return 0d; }
/** * Return the value in the given 32-bit counter. * * @param c The 32-bit counter. * @return A long value configured in the given counter. * Node that zero is returned if {@code c} is invalid. */ public static long longValue(Counter32 c) { if (c != null) { Long v = c.getValue(); if (v != null) { return v.longValue(); } } return 0; }
public StatisticsBuilder setInUnknownProtos(Counter32 value) { if (value != null) { checkInUnknownProtosRange(value.getValue()); } this._inUnknownProtos = value; return this; } /**
public StatisticsBuilder setOutErrors(Counter32 value) { if (value != null) { checkOutErrorsRange(value.getValue()); } this._outErrors = value; return this; } /**
public StatisticsBuilder setInDiscards(Counter32 value) { if (value != null) { checkInDiscardsRange(value.getValue()); } this._inDiscards = value; return this; } /**
public StatisticsBuilder setInErrors(Counter32 value) { if (value != null) { checkInErrorsRange(value.getValue()); } this._inErrors = value; return this; } /**
public WeeklyBuilder setEveryNWeeks(Counter32 value) { if (value != null) { checkEveryNWeeksRange(value.getValue()); } this._everyNWeeks = value; return this; } /**
public StatisticsBuilder setOutDiscards(Counter32 value) { if (value != null) { checkOutDiscardsRange(value.getValue()); } this._outDiscards = value; return this; } /**
/** * Method invoked when flowStatistics is updated and log statistics details. * @param changes */ private void createFlowStatistics( AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes) { //Data Store documents duration, packet counts and byte counts between the hosts. for (Entry<InstanceIdentifier<?>, DataObject> newFlow : changes.getCreatedData().entrySet()) { if (newFlow.getValue() instanceof FlowStatistics) { FlowStatistics flowStatistics = (FlowStatistics)newFlow.getValue(); LOG.info("Flow Statistics gathering for Byte Count:{}", flowStatistics.getByteCount()); LOG.info("Flow Statistics gathering for Packet Count:{}", flowStatistics.getPacketCount()); LOG.info("Flow Statistics gathering for Duration in seconds::{}", flowStatistics.getDuration().getSecond().getValue().intValue()); LOG.info("Flow Statistics gathering for Duration in Nano seconds::{}", flowStatistics.getDuration().getNanosecond().getValue().intValue()); } } } }
@Override public JsonObject objectToJsonMapper(DataObject ofTableStat) { JsonObject flowTableJsonObject = null; FlowTableStatistics flowTableStats = (FlowTableStatistics) ofTableStat; if (flowTableStats.getActiveFlows() != null && flowTableStats.getPacketsLookedUp() != null && flowTableStats.getPacketsMatched() != null) { flowTableJsonObject = factory.createObjectBuilder() .add(properties.getProperty("STAT_TYPE"), properties.getProperty("FLOW_TAB")) .add(properties.getProperty("TIMESTAMP"), System.currentTimeMillis()) .add(properties.getProperty("OFSTATS"), factory.createObjectBuilder() .add(properties.getProperty("ACT_FLOWS"), flowTableStats.getActiveFlows().getValue()).add( properties.getProperty("PACK_LOOK_UP"), flowTableStats.getPacketsLookedUp().getValue()) .add(properties.getProperty("PACK_MATCH"), flowTableStats.getPacketsMatched().getValue())) .build(); } return flowTableJsonObject; }
@Override public JsonObject objectToJsonMapper(DataObject ofStat) { JsonObject flowStatisticsJsonObject = null; FlowStatistics flowStat = (FlowStatistics) ofStat; if (flowStat.getByteCount() != null && flowStat.getDuration() != null && flowStat.getPacketCount() != null) { flowStatisticsJsonObject = factory.createObjectBuilder() .add(properties.getProperty("STAT_TYPE"), properties.getProperty("FLOW_STAT")) .add(properties.getProperty("TIMESTAMP"), System.currentTimeMillis()) .add(properties.getProperty("OFSTATS"), factory.createObjectBuilder() .add(properties.getProperty("BYTE_COUNT"), flowStat.getByteCount().getValue()).add( properties.getProperty("DURATION_SEC"), flowStat.getDuration().getSecond().getValue()) .add(properties.getProperty("DURATION_NANOSEC"), flowStat.getDuration().getNanosecond().getValue()) .add(properties.getProperty("PACK_COUNT"), flowStat.getPacketCount().getValue())) .build(); } return flowStatisticsJsonObject; }
@Override public JsonObject objectToJsonMapper(DataObject meterStats) { JsonObject flowStatisticsJsonObject = null; MeterStatistics meterStat = (MeterStatistics) meterStats; if (meterStat.getByteInCount() != null && meterStat.getDuration() != null && meterStat.getFlowCount() != null && meterStat.getMeterBandStats() != null && meterStat.getMeterId() != null && meterStat.getPacketInCount() != null) { List<BandStat> bandStats = meterStat.getMeterBandStats().getBandStat(); flowStatisticsJsonObject = factory.createObjectBuilder() .add(properties.getProperty("STAT_TYPE"), properties.getProperty("MTR_STAT")) .add(properties.getProperty("TIMESTAMP"), System.currentTimeMillis()) .add(properties.getProperty("OFSTATS"), factory.createObjectBuilder() .add(properties.getProperty("MET_ID"), meterStat.getMeterId().getValue()) .add(properties.getProperty("BYT_IN_COUNT"), meterStat.getByteInCount().getValue()) .add(properties.getProperty("FLOW_COUNT"), meterStat.getFlowCount().getValue()) .add(properties.getProperty("PACK_IN_COUNT"), meterStat.getPacketInCount().getValue()) .add(properties.getProperty("DURATION_SEC"), meterStat.getDuration().getSecond().getValue()) .add(properties.getProperty("DURATION_NANOSEC"), meterStat.getDuration().getNanosecond().getValue()) .add(properties.getProperty("BAND_STAT"), createBandStatsJsonArrayObject(bandStats))) .build(); } return flowStatisticsJsonObject; }
@Override public JsonObject objectToJsonMapper(DataObject ofStat) { JsonObject nodeGroupStatisticsJsonObject = null; GroupStatistics groupStat = (GroupStatistics) ofStat; if (groupStat.getByteCount() != null && groupStat.getDuration() != null && groupStat.getPacketCount() != null && groupStat.getBuckets() != null && groupStat.getGroupId() != null && groupStat.getRefCount() != null) { nodeGroupStatisticsJsonObject = factory.createObjectBuilder() .add(properties.getProperty("STAT_TYPE"), properties.getProperty("GRP_STAT")) .add(properties.getProperty("TIMESTAMP"), System.currentTimeMillis()) .add(properties.getProperty("OFSTATS"), factory.createObjectBuilder() .add(properties.getProperty("BYTE_COUNT"), groupStat.getByteCount().getValue()) .add(properties.getProperty("DURATION_SEC"), groupStat.getDuration().getSecond().getValue()) .add(properties.getProperty("DURATION_NANOSEC"), groupStat.getDuration().getNanosecond().getValue()) .add(properties.getProperty("PACK_COUNT"), groupStat.getPacketCount().getValue()) .add(properties.getProperty("REF_COUNT"), groupStat.getRefCount().getValue()) .add(properties.getProperty("GRP_ID"), groupStat.getGroupId().getValue()) .add(properties.getProperty("BUCK"), createBandStatsJsonArrayObject(groupStat.getBuckets().getBucketCounter()))) .build(); } return nodeGroupStatisticsJsonObject; }
.getDuration().getSecond().getValue() - ns.timestamp); ns.txSpeed = (bytes.getTransmitted().longValue() - ns.txHistory) / (statistic.getFlowCapableNodeConnectorStatistics() .getDuration().getSecond().getValue() - ns.timestamp); ns.rxHistory = bytes.getReceived().longValue(); ns.txHistory = bytes.getTransmitted().longValue(); ns.timestamp = statistic.getFlowCapableNodeConnectorStatistics() .getDuration().getSecond().getValue();
.getDuration().getSecond().getValue() - ns.timestamp); ns.txSpeed = (bytes.getTransmitted().longValue() - ns.txHistory) / (statistic.getFlowCapableNodeConnectorStatistics() .getDuration().getSecond().getValue() - ns.timestamp); ns.rxHistory = bytes.getReceived().longValue(); ns.txHistory = bytes.getTransmitted().longValue(); ns.timestamp = statistic.getFlowCapableNodeConnectorStatistics() .getDuration().getSecond().getValue();
b.setMetricValue(new BigDecimal(entry.getIfInNUcastPkts().getValue())); break; case IfInDiscards: b.setMetricValue(new BigDecimal(entry.getIfInDiscards().getValue())); break; case IfInErrors: b.setMetricValue(new BigDecimal(entry.getIfInErrors().getValue())); break; case IfInOctets: b.setMetricValue(new BigDecimal(entry.getIfInOctets().getValue())); break; case IfInUnknownProtos: b.setMetricValue(new BigDecimal(entry.getIfInUnknownProtos().getValue())); break; case IfInUcastPkts: b.setMetricValue(new BigDecimal(entry.getIfInUcastPkts().getValue())); break; case IfOutQLen: break; case IfOutNUcastPkts: b.setMetricValue(new BigDecimal(entry.getIfOutNUcastPkts().getValue())); break; case IfOutErrors: b.setMetricValue(new BigDecimal(entry.getIfOutErrors().getValue())); break; case IfOutDiscards: b.setMetricValue(new BigDecimal(entry.getIfOutDiscards().getValue())); break;
private static void statsForTlvs(final Tlvs tlvs, final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> builder) { if (tlvs.getRejectedPrefixesTlv() != null) { builder.withChild(ImmutableNodes.leafNode(STAT0_QNAME, tlvs.getRejectedPrefixesTlv().getCount().getValue())); builder.withChild(ImmutableNodes.leafNode(STAT1_QNAME, tlvs.getDuplicatePrefixAdvertisementsTlv().getCount().getValue())); builder.withChild(ImmutableNodes.leafNode(STAT2_QNAME, tlvs.getDuplicateWithdrawsTlv().getCount().getValue())); builder.withChild(ImmutableNodes.leafNode(STAT3_QNAME, tlvs.getInvalidatedClusterListLoopTlv().getCount().getValue())); builder.withChild(ImmutableNodes.leafNode(STAT4_QNAME, tlvs.getInvalidatedAsPathLoopTlv().getCount().getValue())); builder.withChild(ImmutableNodes.leafNode(STAT5_QNAME, tlvs.getInvalidatedOriginatorIdTlv().getCount().getValue())); builder.withChild(ImmutableNodes.leafNode(STAT6_QNAME, tlvs.getInvalidatedAsConfedLoopTlv().getCount().getValue())); builder.withChild(ImmutableNodes.leafNode(STAT11_QNAME, tlvs.getUpdatesTreatedAsWithdrawTlv().getCount().getValue())); builder.withChild(ImmutableNodes.leafNode(STAT11_QNAME, tlvs.getPrefixesTreatedAsWithdrawTlv().getCount().getValue())); builder.withChild(ImmutableNodes.leafNode(STAT13_QNAME, tlvs.getDuplicateUpdatesTlv().getCount().getValue()));