Add support for names vector and fill name in interface/node stats
[govpp.git] / api / stats.go
1 package api
2
3 // SystemStats represents global system statistics.
4 type SystemStats struct {
5         VectorRate     float64
6         InputRate      float64
7         LastUpdate     float64
8         LastStatsClear float64
9         Heartbeat      float64
10 }
11
12 // NodeStats represents per node statistics.
13 type NodeStats struct {
14         Nodes []NodeCounters
15 }
16
17 // NodeCounters represents node counters.
18 type NodeCounters struct {
19         NodeIndex uint32
20         NodeName  string // requires VPP 19.04+
21
22         Clocks   uint64
23         Vectors  uint64
24         Calls    uint64
25         Suspends uint64
26 }
27
28 // InterfaceStats represents per interface statistics.
29 type InterfaceStats struct {
30         Interfaces []InterfaceCounters
31 }
32
33 // InterfaceCounters represents interface counters.
34 type InterfaceCounters struct {
35         InterfaceIndex uint32
36         InterfaceName  string // requires VPP 19.04+
37
38         RxPackets uint64
39         RxBytes   uint64
40         RxErrors  uint64
41         TxPackets uint64
42         TxBytes   uint64
43         TxErrors  uint64
44
45         RxUnicast     [2]uint64 // packets[0], bytes[1]
46         RxMulticast   [2]uint64 // packets[0], bytes[1]
47         RxBroadcast   [2]uint64 // packets[0], bytes[1]
48         TxUnicastMiss [2]uint64 // packets[0], bytes[1]
49         TxMulticast   [2]uint64 // packets[0], bytes[1]
50         TxBroadcast   [2]uint64 // packets[0], bytes[1]
51
52         Drops   uint64
53         Punts   uint64
54         IP4     uint64
55         IP6     uint64
56         RxNoBuf uint64
57         RxMiss  uint64
58 }
59
60 // ErrorStats represents statistics per error counter.
61 type ErrorStats struct {
62         Errors []ErrorCounter
63 }
64
65 // ErrorCounter represents error counter.
66 type ErrorCounter struct {
67         CounterName string
68         Value       uint64
69 }
70
71 // StatsProvider provides the methods for getting statistics.
72 type StatsProvider interface {
73         GetSystemStats() (*SystemStats, error)
74         GetNodeStats() (*NodeStats, error)
75         GetInterfaceStats() (*InterfaceStats, error)
76         GetErrorStats(names ...string) (*ErrorStats, error)
77 }