diff --git a/nodestat.go b/nodestat.go index bf44080..633823b 100755 --- a/nodestat.go +++ b/nodestat.go @@ -21,12 +21,12 @@ import ( // Peer data. type Peer struct { PublicKey *key.Public - State admin.PeerState + State string IsIncoming bool - BytesIn int64 - BytesOut int64 + BytesIn int + BytesOut int Last time.Time - SwitchLabel admin.Path + SwitchLabel *admin.Path IPv6 net.IP RateIn float64 @@ -42,7 +42,7 @@ var Data struct { // Data on this specific node. Node struct { - Memory int64 + Memory int Angel struct { Uptime Duration PercentCPU float64 @@ -59,8 +59,8 @@ var Data struct { RateOut float64 // The difference of all bytes received and sent - BytesIn int64 - BytesOut int64 + BytesIn int + BytesOut int angelPID []byte corePID []byte diff --git a/peerStats.go b/peerStats.go index 6ffeb5b..c795cee 100755 --- a/peerStats.go +++ b/peerStats.go @@ -18,7 +18,7 @@ func peerStatLoop() { } Data.Node.RateIn, Data.Node.RateOut = 0, 0 - Data.Node.BytesIn, Data.Node.BytesOut = int64(0), int64(0) + Data.Node.BytesIn, Data.Node.BytesOut = 0, 0 peerUpdate := make(map[string]Peer) // loop through the results and update peer statistics while checking // for any peers that are no longer there. @@ -39,12 +39,15 @@ func peerStatLoop() { newRateIn := float64(peer.BytesIn-Data.Peers[peer.PublicKey.String()].BytesIn) / (time.Since(Data.Peers[peer.PublicKey.String()].LastUpdate).Seconds()) newRateOut := float64(peer.BytesOut-Data.Peers[peer.PublicKey.String()].BytesOut) / (time.Since(Data.Peers[peer.PublicKey.String()].LastUpdate).Seconds()) + // Convert the last packet received timestamp to a time.Time + last := time.Unix(0, peer.Last*1000000) + // Update the peer statistics peerUpdate[peer.PublicKey.String()] = Peer{ PublicKey: peer.PublicKey, IPv6: Data.Peers[peer.PublicKey.String()].IPv6, // save the same IP LastUpdate: time.Now(), - Last: peer.Last, + Last: last, SwitchLabel: peer.SwitchLabel, IsIncoming: peer.IsIncoming, State: peer.State,