blob: 2fd919246b99e3f7d3149e52a6d6010da4dd3613 [file] [log] [blame]
Harshada Chaundkardcd1b142019-03-25 17:27:44 -04001/*
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 */
16package org.onosproject.packetthrottle.cli;
17
18import org.apache.karaf.shell.api.action.Command;
19import org.onosproject.cli.AbstractShellCommand;
20import org.apache.karaf.shell.api.action.lifecycle.Service;
21import org.onosproject.net.packet.PacketInFilter;
22import org.onosproject.packetthrottle.api.PacketThrottleService;
23import 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")
32public 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}