Print info for users to stderr when socket files are missing
[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 // SystemStats represents global system statistics.
18 type SystemStats struct {
19         VectorRate     float64
20         InputRate      float64
21         LastUpdate     float64
22         LastStatsClear float64
23         Heartbeat      float64
24 }
25
26 // NodeStats represents per node statistics.
27 type NodeStats struct {
28         Nodes []NodeCounters
29 }
30
31 // NodeCounters represents node counters.
32 type NodeCounters struct {
33         NodeIndex uint32
34         NodeName  string // requires VPP 19.04+
35
36         Clocks   uint64
37         Vectors  uint64
38         Calls    uint64
39         Suspends uint64
40 }
41
42 // InterfaceStats represents per interface statistics.
43 type InterfaceStats struct {
44         Interfaces []InterfaceCounters
45 }
46
47 // InterfaceCounters represents interface counters.
48 type InterfaceCounters struct {
49         InterfaceIndex uint32
50         InterfaceName  string // requires VPP 19.04+
51
52         RxPackets uint64
53         RxBytes   uint64
54         RxErrors  uint64
55         TxPackets uint64
56         TxBytes   uint64
57         TxErrors  uint64
58
59         RxUnicast     [2]uint64 // packets[0], bytes[1]
60         RxMulticast   [2]uint64 // packets[0], bytes[1]
61         RxBroadcast   [2]uint64 // packets[0], bytes[1]
62         TxUnicastMiss [2]uint64 // packets[0], bytes[1]
63         TxMulticast   [2]uint64 // packets[0], bytes[1]
64         TxBroadcast   [2]uint64 // packets[0], bytes[1]
65
66         Drops   uint64
67         Punts   uint64
68         IP4     uint64
69         IP6     uint64
70         RxNoBuf uint64
71         RxMiss  uint64
72 }
73
74 // ErrorStats represents statistics per error counter.
75 type ErrorStats struct {
76         Errors []ErrorCounter
77 }
78
79 // ErrorCounter represents error counter.
80 type ErrorCounter struct {
81         CounterName string
82         Value       uint64
83 }
84
85 // BufferStats represents statistics per buffer pool.
86 type BufferStats struct {
87         Buffer map[string]BufferPool
88 }
89
90 // BufferPool represents buffer pool.
91 type BufferPool struct {
92         PoolName  string
93         Cached    float64
94         Used      float64
95         Available float64
96 }
97
98 // StatsProvider provides the methods for getting statistics.
99 type StatsProvider interface {
100         GetSystemStats() (*SystemStats, error)
101         GetNodeStats() (*NodeStats, error)
102         GetInterfaceStats() (*InterfaceStats, error)
103         GetErrorStats(names ...string) (*ErrorStats, error)
104         GetBufferStats() (*BufferStats, error)
105 }