2018-01-30 11:51:48 +00:00
|
|
|
// +build metrics,!prometheus
|
|
|
|
|
|
|
|
package node
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"expvar"
|
|
|
|
|
2018-03-20 18:35:28 +00:00
|
|
|
"github.com/ethereum/go-ethereum/log"
|
2018-01-30 11:51:48 +00:00
|
|
|
"github.com/ethereum/go-ethereum/node"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
nodeInfo = expvar.NewString("node_info")
|
|
|
|
nodePeers = expvar.NewString("node_peers")
|
|
|
|
)
|
|
|
|
|
|
|
|
func updateNodeInfo(node *node.Node) {
|
|
|
|
server := node.Server()
|
|
|
|
if server == nil {
|
|
|
|
log.Warn("Failed to get a server")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
nodeInfo.Set(server.NodeInfo().ID)
|
|
|
|
}
|
|
|
|
|
|
|
|
func updateNodePeers(node *node.Node) {
|
|
|
|
server := node.Server()
|
|
|
|
if server == nil {
|
2018-03-20 18:35:28 +00:00
|
|
|
logger.Warn("Failed to get a server")
|
2018-01-30 11:51:48 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
val, _ := json.Marshal(getNodePeerRemoteAddresses(server))
|
|
|
|
nodePeers.Set(string(val))
|
|
|
|
}
|