| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | |
| 3 | package geth |
| 4 | |
| 5 | import ( |
| 6 | "github.com/netdata/netdata/go/plugins/pkg/prometheus" |
| 7 | "github.com/netdata/netdata/go/plugins/pkg/stm" |
| 8 | ) |
| 9 | |
| 10 | func (c *Collector) collect() (map[string]int64, error) { |
| 11 | pms, err := c.prom.ScrapeSeries() |
| 12 | if err != nil { |
| 13 | return nil, err |
| 14 | } |
| 15 | mx := c.collectGeth(pms) |
| 16 | |
| 17 | return stm.ToMap(mx), nil |
| 18 | } |
| 19 | |
| 20 | func (c *Collector) collectGeth(pms prometheus.Series) map[string]float64 { |
| 21 | mx := make(map[string]float64) |
| 22 | c.collectChainData(mx, pms) |
| 23 | c.collectP2P(mx, pms) |
| 24 | c.collectTxPool(mx, pms) |
| 25 | c.collectRpc(mx, pms) |
| 26 | return mx |
| 27 | } |
| 28 | |
| 29 | func (c *Collector) collectChainData(mx map[string]float64, pms prometheus.Series) { |
| 30 | pms = pms.FindByNames( |
| 31 | chainValidation, |
| 32 | chainWrite, |
| 33 | ethDbChainDataAncientRead, |
| 34 | ethDbChainDataAncientWrite, |
| 35 | ethDbChaindataDiskRead, |
| 36 | ethDbChainDataDiskWrite, |
| 37 | chainHeadBlock, |
| 38 | chainHeadHeader, |
| 39 | chainHeadReceipt, |
| 40 | ethDbChainDataAncientSize, |
| 41 | ethDbChainDataDiskSize, |
| 42 | reorgsAdd, |
| 43 | reorgsDropped, |
| 44 | reorgsExecuted, |
| 45 | goRoutines, |
| 46 | ) |
| 47 | c.collectEth(mx, pms) |
| 48 | |
| 49 | } |
| 50 | |
| 51 | func (c *Collector) collectRpc(mx map[string]float64, pms prometheus.Series) { |
| 52 | pms = pms.FindByNames( |
| 53 | rpcRequests, |
| 54 | rpcSuccess, |
| 55 | rpcFailure, |
| 56 | ) |
| 57 | c.collectEth(mx, pms) |
| 58 | } |
| 59 | |
| 60 | func (c *Collector) collectTxPool(mx map[string]float64, pms prometheus.Series) { |
| 61 | pms = pms.FindByNames( |
| 62 | txPoolInvalid, |
| 63 | txPoolPending, |
| 64 | txPoolLocal, |
| 65 | txPoolPendingDiscard, |
| 66 | txPoolNofunds, |
| 67 | txPoolPendingRatelimit, |
| 68 | txPoolPendingReplace, |
| 69 | txPoolQueuedDiscard, |
| 70 | txPoolQueuedEviction, |
| 71 | txPoolQueuedEviction, |
| 72 | txPoolQueuedRatelimit, |
| 73 | ) |
| 74 | c.collectEth(mx, pms) |
| 75 | } |
| 76 | |
| 77 | func (c *Collector) collectP2P(mx map[string]float64, pms prometheus.Series) { |
| 78 | pms = pms.FindByNames( |
| 79 | p2pDials, |
| 80 | p2pEgress, |
| 81 | p2pIngress, |
| 82 | p2pPeers, |
| 83 | p2pServes, |
| 84 | ) |
| 85 | c.collectEth(mx, pms) |
| 86 | } |
| 87 | |
| 88 | func (c *Collector) collectEth(mx map[string]float64, pms prometheus.Series) { |
| 89 | for _, pm := range pms { |
| 90 | mx[pm.Name()] += pm.Value |
| 91 | } |
| 92 | } |