blob: 1a4d89f749f42845d740cf8f3316e8e254bfa282 [file] [log] [blame]
Shubham Sharma544ffa22020-02-13 06:41:02 +00001/*
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 */
16package org.opencord.aaa.cli;
17
18import org.apache.karaf.shell.api.action.lifecycle.Service;
19
20import org.apache.karaf.shell.api.action.Argument;
21import org.onosproject.cli.AbstractShellCommand;
22import org.apache.karaf.shell.api.action.Command;
23import org.opencord.aaa.AaaMachineStatisticsService;
24import org.opencord.aaa.AaaSupplicantMachineStats;
25import 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",
32description = "Display current value of all aaa statistics counters")
33public 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}