Harshada Chaundkar | dcd1b14 | 2019-03-25 17:27:44 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2019-present Open Networking Foundation |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | package org.onosproject.packetthrottle.cli; |
| 17 | |
| 18 | import org.apache.karaf.shell.api.action.Command; |
| 19 | import org.onosproject.cli.AbstractShellCommand; |
| 20 | import org.apache.karaf.shell.api.action.lifecycle.Service; |
| 21 | import org.onosproject.net.packet.PacketInFilter; |
| 22 | import org.onosproject.packetthrottle.api.PacketThrottleService; |
| 23 | import java.util.Map; |
| 24 | |
| 25 | |
| 26 | /** |
| 27 | * Displays the statistics of the packets dropped due to throttle. |
| 28 | */ |
| 29 | @Service |
| 30 | @Command(scope = "onos", name = "pkt-stats-overflow-show", |
| 31 | description = "Displays the packet overflow statistics values") |
| 32 | public class PacketOverFlowStatsShowCommand extends AbstractShellCommand { |
| 33 | |
| 34 | private static final String FORMAT = "PacketType = %s, Count = %s"; |
| 35 | |
| 36 | |
| 37 | |
| 38 | @Override |
| 39 | protected void doExecute() { |
| 40 | PacketInFilter filter; |
| 41 | PacketThrottleService packetThrottleService = get(PacketThrottleService.class); |
| 42 | Map<String, PacketInFilter> filterMap = packetThrottleService.filterMap(); |
| 43 | for (Map.Entry<String, PacketInFilter> entry: filterMap.entrySet()) { |
| 44 | filter = entry.getValue(); |
| 45 | print(FORMAT, filter.name(), filter.droppedPackets()); |
| 46 | } |
| 47 | } |
| 48 | } |