Shubham Sharma | 544ffa2 | 2020-02-13 06:41:02 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016-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.opencord.aaa.cli; |
| 17 | |
| 18 | import org.apache.karaf.shell.api.action.lifecycle.Service; |
| 19 | |
| 20 | import org.apache.karaf.shell.api.action.Argument; |
| 21 | import org.onosproject.cli.AbstractShellCommand; |
| 22 | import org.apache.karaf.shell.api.action.Command; |
| 23 | import org.opencord.aaa.AaaMachineStatisticsService; |
| 24 | import org.opencord.aaa.AaaSupplicantMachineStats; |
| 25 | import org.opencord.aaa.AuthenticationService; |
| 26 | |
| 27 | /** |
| 28 | * CLI command for displaying all the AaaMachine Counters. |
| 29 | */ |
| 30 | @Service |
| 31 | @Command(scope = "onos", name = "show-aaa-machine-counters", |
| 32 | description = "Display current value of all aaa statistics counters") |
| 33 | public class AaaShowPerMachineCountersCommand extends AbstractShellCommand { |
| 34 | |
| 35 | @Argument(index = 0, name = "deviceId", |
| 36 | description = "DeviceId of device from which packet is received", |
| 37 | required = true, multiValued = false) |
| 38 | private String deviceId; |
| 39 | |
| 40 | @Argument(index = 1, name = "portNumber", |
| 41 | description = "Port no of device from which packet is received", |
| 42 | required = true, multiValued = false) |
| 43 | private String portNumber; |
| 44 | |
| 45 | @Override |
| 46 | protected void doExecute() { |
| 47 | |
| 48 | String sessionId = deviceId + portNumber; |
| 49 | AaaMachineStatisticsService aaaMachineStatsManager = get(AaaMachineStatisticsService.class); |
| 50 | AuthenticationService aaaManager = get(AuthenticationService.class); |
| 51 | AaaSupplicantMachineStats aaaSupplicantMachineStats = aaaManager.getSupplicantMachineStats(sessionId); |
| 52 | if (aaaSupplicantMachineStats != null) { |
| 53 | print("%30s %10d\n", "SessionDuration", aaaSupplicantMachineStats.getSessionDuration()); |
| 54 | print("%30s %10d\n", "TotalOctetRecieved", aaaSupplicantMachineStats.getTotalOctetRecieved()); |
| 55 | print("%30s %10d\n", "TotalFramesReceived", aaaSupplicantMachineStats.getTotalFramesReceived()); |
| 56 | print("%30s %10d\n", "TotalFramesSent", aaaSupplicantMachineStats.getTotalFramesSent()); |
| 57 | print("%30s %10d\n", "TotalOctetSent", aaaSupplicantMachineStats.getTotalOctetSent()); |
| 58 | print("%30s %10d\n", "TotalPacketsRecieved", aaaSupplicantMachineStats.getTotalPacketsRecieved()); |
| 59 | print("%30s %10d\n", "TotalPacketsSent", aaaSupplicantMachineStats.getTotalPacketsSent()); |
| 60 | } else { |
| 61 | print("No such Device Found"); |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | } |