status-go/_assets/patches/geth-xgo/0002-remove-dashboard-colle...

154 lines
4.9 KiB
Diff

diff --git a/vendor/github.com/ethereum/go-ethereum/dashboard/dashboard.go b/vendor/github.com/ethereum/go-ethereum/dashboard/dashboard.go
index 3ba92ac7..d89a1e94 100644
--- a/vendor/github.com/ethereum/go-ethereum/dashboard/dashboard.go
+++ b/vendor/github.com/ethereum/go-ethereum/dashboard/dashboard.go
@@ -27,20 +27,17 @@ import (
"fmt"
"net"
"net/http"
- "runtime"
"sync"
"sync/atomic"
"time"
"io"
- "github.com/elastic/gosigar"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/metrics"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rpc"
- "github.com/mohae/deepcopy"
"golang.org/x/net/websocket"
)
@@ -235,7 +232,7 @@ func (db *Dashboard) apiHandler(conn *websocket.Conn) {
db.lock.Lock()
// Send the past data.
- client.msg <- deepcopy.Copy(db.history).(*Message)
+ client.msg <- db.history
// Start tracking the connection and drop at connection loss.
db.conns[id] = client
db.lock.Unlock()
@@ -275,118 +272,6 @@ func meterCollector(name string) func() int64 {
// collectData collects the required data to plot on the dashboard.
func (db *Dashboard) collectData() {
defer db.wg.Done()
-
- systemCPUUsage := gosigar.Cpu{}
- systemCPUUsage.Get()
- var (
- mem runtime.MemStats
-
- collectNetworkIngress = meterCollector("p2p/InboundTraffic")
- collectNetworkEgress = meterCollector("p2p/OutboundTraffic")
- collectDiskRead = meterCollector("eth/db/chaindata/disk/read")
- collectDiskWrite = meterCollector("eth/db/chaindata/disk/write")
-
- prevNetworkIngress = collectNetworkIngress()
- prevNetworkEgress = collectNetworkEgress()
- prevProcessCPUTime = getProcessCPUTime()
- prevSystemCPUUsage = systemCPUUsage
- prevDiskRead = collectDiskRead()
- prevDiskWrite = collectDiskWrite()
-
- frequency = float64(db.config.Refresh / time.Second)
- numCPU = float64(runtime.NumCPU())
- )
-
- for {
- select {
- case errc := <-db.quit:
- errc <- nil
- return
- case <-time.After(db.config.Refresh):
- systemCPUUsage.Get()
- var (
- curNetworkIngress = collectNetworkIngress()
- curNetworkEgress = collectNetworkEgress()
- curProcessCPUTime = getProcessCPUTime()
- curSystemCPUUsage = systemCPUUsage
- curDiskRead = collectDiskRead()
- curDiskWrite = collectDiskWrite()
-
- deltaNetworkIngress = float64(curNetworkIngress - prevNetworkIngress)
- deltaNetworkEgress = float64(curNetworkEgress - prevNetworkEgress)
- deltaProcessCPUTime = curProcessCPUTime - prevProcessCPUTime
- deltaSystemCPUUsage = curSystemCPUUsage.Delta(prevSystemCPUUsage)
- deltaDiskRead = curDiskRead - prevDiskRead
- deltaDiskWrite = curDiskWrite - prevDiskWrite
- )
- prevNetworkIngress = curNetworkIngress
- prevNetworkEgress = curNetworkEgress
- prevProcessCPUTime = curProcessCPUTime
- prevSystemCPUUsage = curSystemCPUUsage
- prevDiskRead = curDiskRead
- prevDiskWrite = curDiskWrite
-
- now := time.Now()
-
- runtime.ReadMemStats(&mem)
- activeMemory := &ChartEntry{
- Time: now,
- Value: float64(mem.Alloc) / frequency,
- }
- virtualMemory := &ChartEntry{
- Time: now,
- Value: float64(mem.Sys) / frequency,
- }
- networkIngress := &ChartEntry{
- Time: now,
- Value: deltaNetworkIngress / frequency,
- }
- networkEgress := &ChartEntry{
- Time: now,
- Value: deltaNetworkEgress / frequency,
- }
- processCPU := &ChartEntry{
- Time: now,
- Value: deltaProcessCPUTime / frequency / numCPU * 100,
- }
- systemCPU := &ChartEntry{
- Time: now,
- Value: float64(deltaSystemCPUUsage.Sys+deltaSystemCPUUsage.User) / frequency / numCPU,
- }
- diskRead := &ChartEntry{
- Time: now,
- Value: float64(deltaDiskRead) / frequency,
- }
- diskWrite := &ChartEntry{
- Time: now,
- Value: float64(deltaDiskWrite) / frequency,
- }
- sys := db.history.System
- db.lock.Lock()
- sys.ActiveMemory = append(sys.ActiveMemory[1:], activeMemory)
- sys.VirtualMemory = append(sys.VirtualMemory[1:], virtualMemory)
- sys.NetworkIngress = append(sys.NetworkIngress[1:], networkIngress)
- sys.NetworkEgress = append(sys.NetworkEgress[1:], networkEgress)
- sys.ProcessCPU = append(sys.ProcessCPU[1:], processCPU)
- sys.SystemCPU = append(sys.SystemCPU[1:], systemCPU)
- sys.DiskRead = append(sys.DiskRead[1:], diskRead)
- sys.DiskWrite = append(sys.DiskWrite[1:], diskWrite)
- db.lock.Unlock()
-
- db.sendToAll(&Message{
- System: &SystemMessage{
- ActiveMemory: ChartEntries{activeMemory},
- VirtualMemory: ChartEntries{virtualMemory},
- NetworkIngress: ChartEntries{networkIngress},
- NetworkEgress: ChartEntries{networkEgress},
- ProcessCPU: ChartEntries{processCPU},
- SystemCPU: ChartEntries{systemCPU},
- DiskRead: ChartEntries{diskRead},
- DiskWrite: ChartEntries{diskWrite},
- },
- })
- }
- }
}
// sendToAll sends the given message to the active dashboards.