Provide error counters per worker for statsclient
[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         GetMemoryStats(*MemoryStats) error
25 }
26
27 // SystemStats represents global system statistics.
28 type SystemStats struct {
29         VectorRate          uint64
30         NumWorkerThreads    uint64
31         VectorRatePerWorker []uint64
32         InputRate           uint64
33         LastUpdate          uint64
34         LastStatsClear      uint64
35         Heartbeat           uint64
36 }
37
38 // NodeStats represents per node statistics.
39 type NodeStats struct {
40         Nodes []NodeCounters
41 }
42
43 // NodeCounters represents node counters.
44 type NodeCounters struct {
45         NodeIndex uint32
46         NodeName  string // requires VPP 19.04+
47
48         Clocks   uint64
49         Vectors  uint64
50         Calls    uint64
51         Suspends uint64
52 }
53
54 // InterfaceStats represents per interface statistics.
55 type InterfaceStats struct {
56         Interfaces []InterfaceCounters
57 }
58
59 // InterfaceCounters represents interface counters.
60 type InterfaceCounters struct {
61         InterfaceIndex uint32
62         InterfaceName  string // requires VPP 19.04+
63
64         Rx InterfaceCounterCombined
65         Tx InterfaceCounterCombined
66
67         RxErrors uint64
68         TxErrors uint64
69
70         RxUnicast   InterfaceCounterCombined
71         RxMulticast InterfaceCounterCombined
72         RxBroadcast InterfaceCounterCombined
73         TxUnicast   InterfaceCounterCombined
74         TxMulticast InterfaceCounterCombined
75         TxBroadcast InterfaceCounterCombined
76
77         Drops   uint64
78         Punts   uint64
79         IP4     uint64
80         IP6     uint64
81         RxNoBuf uint64
82         RxMiss  uint64
83         Mpls    uint64
84 }
85
86 // InterfaceCounterCombined defines combined counters for interfaces.
87 type InterfaceCounterCombined struct {
88         Packets uint64
89         Bytes   uint64
90 }
91
92 // ErrorStats represents statistics per error counter.
93 type ErrorStats struct {
94         Errors []ErrorCounter
95 }
96
97 // ErrorCounter represents error counter.
98 type ErrorCounter struct {
99         CounterName string
100
101         Values []uint64
102 }
103
104 // BufferStats represents statistics per buffer pool.
105 type BufferStats struct {
106         Buffer map[string]BufferPool
107 }
108
109 // BufferPool represents buffer pool.
110 type BufferPool struct {
111         PoolName string
112
113         Cached    float64
114         Used      float64
115         Available float64
116 }
117
118 // MemoryStats represents memory stats segment counters.
119 type MemoryStats struct {
120         Total float64
121         Used  float64
122 }