Daniele Moro | 94660a0 | 2019-12-02 12:02:07 -0800 | [diff] [blame] | 1 | /* |
Joey Armstrong | 0964a2c | 2023-01-05 14:26:05 -0500 | [diff] [blame] | 2 | * Copyright 2019-2023 Open Networking Foundation (ONF) and the ONF Contributors |
Daniele Moro | 94660a0 | 2019-12-02 12:02:07 -0800 | [diff] [blame] | 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 | |
| 17 | package org.opencord.bng.cli; |
| 18 | |
| 19 | import org.apache.karaf.shell.api.action.Command; |
| 20 | import org.apache.karaf.shell.api.action.lifecycle.Service; |
| 21 | import org.onosproject.cli.AbstractShellCommand; |
| 22 | import org.onosproject.net.pi.runtime.PiCounterCellData; |
| 23 | import org.opencord.bng.BngStatsService; |
| 24 | |
| 25 | @Service |
| 26 | @Command(scope = "bng", name = "control-stats", |
| 27 | description = "Retrieve statistics of control plane packets of un-registered attachments") |
| 28 | public class ControlPacketsStats extends AbstractShellCommand { |
| 29 | |
| 30 | @Override |
| 31 | protected void doExecute() throws Exception { |
| 32 | BngStatsService bngStatsService = AbstractShellCommand.get(BngStatsService.class); |
| 33 | PiCounterCellData stats = bngStatsService.getControlStats(); |
| 34 | if (stats != null) { |
| 35 | print("Packets: " + stats.packets()); |
| 36 | print("Bytes:\t" + stats.bytes()); |
| 37 | } else { |
| 38 | print("No BNG user plane device configured"); |
| 39 | } |
| 40 | } |
| 41 | } |