use of org.opendaylight.infrautils.metrics.Counter in project genius by opendaylight.
the class PacketInCounterHandler method onPacketReceived.
@Override
public void onPacketReceived(PacketReceived notification) {
Counter counter;
LOG.debug("Ingress packet notification received");
if (notification.getIngress() == null) {
if (LOG.isWarnEnabled()) {
LOG.warn("invalid PacketReceived notification");
}
return;
}
String dpnId = getDpnId(notification.getIngress().getValue().toString());
counter = packetInCounter.label("OFSwitch").label(dpnId).label("packetin");
counter.increment();
}
use of org.opendaylight.infrautils.metrics.Counter in project netvirt by opendaylight.
the class BgpCounters method processRouteCount.
private int processRouteCount(String rd, int startIndex, List<String> inputStrs) {
int num = startIndex;
long routeCount = 0;
String bgpRdRouteCountKey = BgpConstants.BGP_COUNTER_RD_ROUTE_COUNT + rd;
Counter counter = getCounter(BgpConstants.BGP_COUNTER_RD_ROUTE_COUNT, null, null, null, null, rd);
for (String str = inputStrs.get(num); str != null && !str.trim().equals("") && num < inputStrs.size(); str = inputStrs.get(num)) {
if (str.contains("Route Distinguisher")) {
totalPfxMap.put(bgpRdRouteCountKey, Long.toString(routeCount));
updateCounter(counter, routeCount);
return num - 1;
}
routeCount++;
num++;
if (num == inputStrs.size()) {
break;
}
}
if (routeCount == 0) {
// by sending a big number back.
return Integer.MAX_VALUE;
}
updateCounter(counter, routeCount);
return num - 1;
}
use of org.opendaylight.infrautils.metrics.Counter in project netvirt by opendaylight.
the class BgpCounters method getCounter.
/**
* Returns the counter.
* This method returns counter and also creates counter if does not exist.
*
* @param counterName name of the counter.
* @param asValue as value.
* @param rxValue rx value.
* @param txValue tx value.
* @param neighborIp neighbor Ipaddress.
* @param rdValue rd value.
* @return counter object.
*/
private Counter getCounter(String counterName, String asValue, String rxValue, String txValue, String neighborIp, String rdValue) {
String counterTypeEntityCounter = "entitycounter";
String labelKeyEntityType = "entitytype";
String labelValEntityTypeBgpPeer = "bgp-peer";
String labelKeyAsId = "asid";
String labelKeyNeighborIp = "neighborip";
String labelValEntityTypeBgpRd = "bgp-rd";
String labelKeyRd = "rd";
String counterTypeAggregateCounter = "aggregatecounter";
String labelKeyCounterName = "name";
Counter counter = null;
if (rxValue != null) {
/*
* Following is the key pattern for Counter BgpNeighborPacketsReceived
* netvirt.bgpmanager.entitycounter{entitytype=bgp-peer, asid=value, neighborip=value, name=countername}
* */
Labeled<Labeled<Labeled<Labeled<Counter>>>> labeledCounter = metricProvider.newCounter(MetricDescriptor.builder().anchor(this).project("netvirt").module("bgpmanager").id(counterTypeEntityCounter).build(), labelKeyEntityType, labelKeyAsId, labelKeyNeighborIp, labelKeyCounterName);
counter = labeledCounter.label(labelValEntityTypeBgpPeer).label(asValue).label(neighborIp).label(counterName);
} else if (txValue != null) {
/*
* Following is the key pattern for Counter BgpNeighborPacketsSent
* netvirt.bgpmanager.entitycounter{entitytype=bgp-peer, asid=value, neighborip=value, name=countername}
* */
Labeled<Labeled<Labeled<Labeled<Counter>>>> labeledCounter = metricProvider.newCounter(MetricDescriptor.builder().anchor(this).project("netvirt").module("bgpmanager").id(counterTypeEntityCounter).build(), labelKeyEntityType, labelKeyAsId, labelKeyNeighborIp, labelKeyCounterName);
counter = labeledCounter.label(labelValEntityTypeBgpPeer).label(asValue).label(neighborIp).label(counterName);
} else if (rdValue != null) {
/*
* Following is the key pattern for Counter BgpRdRouteCount
* netvirt.bgpmanager.entitycounter{entitytype=bgp-rd, rd=value, name=countername}
* */
Labeled<Labeled<Labeled<Counter>>> labeledCounter = metricProvider.newCounter(MetricDescriptor.builder().anchor(this).project("netvirt").module("bgpmanager").id(counterTypeEntityCounter).build(), labelKeyEntityType, labelKeyRd, labelKeyCounterName);
counter = labeledCounter.label(labelValEntityTypeBgpRd).label(rdValue).label(counterName);
} else {
/*
* Following is the key pattern for Counter BgpTotalPrefixes:Bgp_Total_Prefixes
* netvirt.bgpmanager.aggregatecounter{name=countername}
* */
Labeled<Counter> labeledCounter = metricProvider.newCounter(MetricDescriptor.builder().anchor(this).project("netvirt").module("bgpmanager").id(counterTypeAggregateCounter).build(), labelKeyCounterName);
counter = labeledCounter.label(counterName);
}
return counter;
}
use of org.opendaylight.infrautils.metrics.Counter in project genius by opendaylight.
the class NodeUpdateCounter method nodeAddedNotification.
public void nodeAddedNotification(String node, String hostName) {
Counter counter;
dpnList.add(node);
counter = packetInCounter.label("OFSwitch").label(hostName).label("switchespernode");
counter.increment();
}
use of org.opendaylight.infrautils.metrics.Counter in project genius by opendaylight.
the class PacketInCounterHandler method nodeRemovedNotification.
public void nodeRemovedNotification(String dpnId) {
Counter counter;
if (dpnId != null) {
dpnId = dpnId.split(":")[1];
LOG.debug("Dpnvalue Id {}", dpnId);
counter = packetInCounter.label("OFSwitch").label(dpnId).label("packetin");
counter.close();
} else {
LOG.error("DpnId is null upon nodeRemovedNotification");
}
}
Aggregations