Introduce higer-level API for retrieving statistics
[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         // TODO: node name is not currently retrievable via stats API (will be most likely added in 19.04)
21         //NodeName string
22
23         Clocks   uint64
24         Vectors  uint64
25         Calls    uint64
26         Suspends uint64
27 }
28
29 // InterfaceStats represents per interface statistics.
30 type InterfaceStats struct {
31         Interfaces []InterfaceCounters
32 }
33
34 // InterfaceCounters represents interface counters.
35 type InterfaceCounters struct {
36         InterfaceIndex uint32
37         // TODO: interface name is not currently retrievable via stats API (will be most likely added in 19.04)
38         //InterfaceName string
39
40         RxPackets uint64
41         RxBytes   uint64
42         RxErrors  uint64
43         TxPackets uint64
44         TxBytes   uint64
45         TxErrors  uint64
46
47         RxUnicast     [2]uint64 // packets[0], bytes[1]
48         RxMulticast   [2]uint64 // packets[0], bytes[1]
49         RxBroadcast   [2]uint64 // packets[0], bytes[1]
50         TxUnicastMiss [2]uint64 // packets[0], bytes[1]
51         TxMulticast   [2]uint64 // packets[0], bytes[1]
52         TxBroadcast   [2]uint64 // packets[0], bytes[1]
53
54         Drops   uint64
55         Punts   uint64
56         IP4     uint64
57         IP6     uint64
58         RxNoBuf uint64
59         RxMiss  uint64
60 }
61
62 // ErrorStats represents statistics per error counter.
63 type ErrorStats struct {
64         Errors []ErrorCounter
65 }
66
67 // ErrorCounter represents error counter.
68 type ErrorCounter struct {
69         CounterName string
70         Value       uint64
71 }
72
73 // StatsProvider provides the methods for getting statistics.
74 type StatsProvider interface {
75         GetSystemStats() (*SystemStats, error)
76         GetNodeStats() (*NodeStats, error)
77         GetInterfaceStats() (*InterfaceStats, error)
78         GetErrorStats(names ...string) (*ErrorStats, error)
79 }