2850b5fb5740ec46d20f2c9be19f0215c7e44847
[govpp.git] / api / stats.go
1 //  Copyright (c) 2019 Cisco and/or its affiliates.
2 //
3 //  Licensed under the Apache License, Version 2.0 (the "License");
4 //  you may not use this file except in compliance with the License.
5 //  You may obtain a copy of the License at:
6 //
7 //      http://www.apache.org/licenses/LICENSE-2.0
8 //
9 //  Unless required by applicable law or agreed to in writing, software
10 //  distributed under the License is distributed on an "AS IS" BASIS,
11 //  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 //  See the License for the specific language governing permissions and
13 //  limitations under the License.
14
15 package api
16
17 // StatsProvider provides methods for retrieving statistics.
18 type StatsProvider interface {
19         GetSystemStats(*SystemStats) error
20         GetNodeStats(*NodeStats) error
21         GetInterfaceStats(*InterfaceStats) error
22         GetErrorStats(*ErrorStats) error
23         GetBufferStats(*BufferStats) error
24 }
25
26 // SystemStats represents global system statistics.
27 type SystemStats struct {
28         VectorRate          uint64
29         NumWorkerThreads    uint64
30         VectorRatePerWorker []uint64
31         InputRate           uint64
32         LastUpdate          uint64
33         LastStatsClear      uint64
34         Heartbeat           uint64
35 }
36
37 // NodeStats represents per node statistics.
38 type NodeStats struct {
39         Nodes []NodeCounters
40 }
41
42 // NodeCounters represents node counters.
43 type NodeCounters struct {
44         NodeIndex uint32
45         NodeName  string // requires VPP 19.04+
46
47         Clocks   uint64
48         Vectors  uint64
49         Calls    uint64
50         Suspends uint64
51 }
52
53 // InterfaceStats represents per interface statistics.
54 type InterfaceStats struct {
55         Interfaces []InterfaceCounters
56 }
57
58 // InterfaceCounters represents interface counters.
59 type InterfaceCounters struct {
60         InterfaceIndex uint32
61         InterfaceName  string // requires VPP 19.04+
62
63         Rx InterfaceCounterCombined
64         Tx InterfaceCounterCombined
65
66         RxErrors uint64
67         TxErrors uint64
68
69         RxUnicast   InterfaceCounterCombined
70         RxMulticast InterfaceCounterCombined
71         RxBroadcast InterfaceCounterCombined
72         TxUnicast   InterfaceCounterCombined
73         TxMulticast InterfaceCounterCombined
74         TxBroadcast InterfaceCounterCombined
75
76         Drops   uint64
77         Punts   uint64
78         IP4     uint64
79         IP6     uint64
80         RxNoBuf uint64
81         RxMiss  uint64
82         Mpls    uint64
83 }
84
85 // InterfaceCounterCombined defines combined counters for interfaces.
86 type InterfaceCounterCombined struct {
87         Packets uint64
88         Bytes   uint64
89 }
90
91 // ErrorStats represents statistics per error counter.
92 type ErrorStats struct {
93         Errors []ErrorCounter
94 }
95
96 // ErrorCounter represents error counter.
97 type ErrorCounter struct {
98         CounterName string
99
100         Value uint64
101 }
102
103 // BufferStats represents statistics per buffer pool.
104 type BufferStats struct {
105         Buffer map[string]BufferPool
106 }
107
108 // BufferPool represents buffer pool.
109 type BufferPool struct {
110         PoolName string
111
112         Cached    float64
113         Used      float64
114         Available float64
115 }