mirror of
https://github.com/octoleo/syncthing.git
synced 2025-02-08 14:58:26 +00:00
Show counters for total data transferred (fixes #265)
This commit is contained in:
parent
5454ca1cf7
commit
c2f75d3689
File diff suppressed because one or more lines are too long
@ -86,9 +86,6 @@ syncthing.controller('SyncthingCtrl', function ($scope, $http) {
|
|||||||
id;
|
id;
|
||||||
|
|
||||||
prevDate = now;
|
prevDate = now;
|
||||||
$scope.inbps = 0;
|
|
||||||
$scope.outbps = 0;
|
|
||||||
|
|
||||||
for (id in data) {
|
for (id in data) {
|
||||||
if (!data.hasOwnProperty(id)) {
|
if (!data.hasOwnProperty(id)) {
|
||||||
continue;
|
continue;
|
||||||
@ -100,8 +97,6 @@ syncthing.controller('SyncthingCtrl', function ($scope, $http) {
|
|||||||
data[id].inbps = 0;
|
data[id].inbps = 0;
|
||||||
data[id].outbps = 0;
|
data[id].outbps = 0;
|
||||||
}
|
}
|
||||||
$scope.inbps += data[id].inbps;
|
|
||||||
$scope.outbps += data[id].outbps;
|
|
||||||
}
|
}
|
||||||
$scope.connections = data;
|
$scope.connections = data;
|
||||||
});
|
});
|
||||||
|
@ -212,11 +212,11 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th><span class="glyphicon glyphicon-cloud-download"></span> Download Rate</th>
|
<th><span class="glyphicon glyphicon-cloud-download"></span> Download Rate</th>
|
||||||
<td class="text-right">{{inbps | metric}}bps</td>
|
<td class="text-right">{{connections['total'].inbps | metric}}bps ({{connections['total'].InBytesTotal | binary}}B)</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th><span class="glyphicon glyphicon-cloud-upload"></span> Upload Rate</th>
|
<th><span class="glyphicon glyphicon-cloud-upload"></span> Upload Rate</th>
|
||||||
<td class="text-right">{{outbps | metric}}bps </td>
|
<td class="text-right">{{connections['total'].outbps | metric}}bps ({{connections['total'].OutBytesTotal | binary}}B)</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr ng-if="system.extAnnounceOK != undefined">
|
<tr ng-if="system.extAnnounceOK != undefined">
|
||||||
<th><span class="glyphicon glyphicon-bullhorn"></span> Announce Server</th>
|
<th><span class="glyphicon glyphicon-bullhorn"></span> Announce Server</th>
|
||||||
@ -262,11 +262,11 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th><span class="glyphicon glyphicon-cloud-download"></span> Download Rate</th>
|
<th><span class="glyphicon glyphicon-cloud-download"></span> Download Rate</th>
|
||||||
<td class="text-right">{{connections[nodeCfg.NodeID].inbps | metric}}bps</td>
|
<td class="text-right">{{connections[nodeCfg.NodeID].inbps | metric}}bps ({{connections[nodeCfg.NodeID].InBytesTotal | binary}}B)</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th><span class="glyphicon glyphicon-cloud-upload"></span> Upload Rate</th>
|
<th><span class="glyphicon glyphicon-cloud-upload"></span> Upload Rate</th>
|
||||||
<td class="text-right">{{connections[nodeCfg.NodeID].outbps | metric}}bps </td>
|
<td class="text-right">{{connections[nodeCfg.NodeID].outbps | metric}}bps ({{connections[nodeCfg.NodeID].OutBytesTotal | binary}}B)</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th><span class="glyphicon glyphicon-tag"></span> Version</th>
|
<th><span class="glyphicon glyphicon-tag"></span> Version</th>
|
||||||
|
@ -181,6 +181,15 @@ func (m *Model) ConnectionStats() map[string]ConnectionInfo {
|
|||||||
m.rmut.RUnlock()
|
m.rmut.RUnlock()
|
||||||
m.pmut.RUnlock()
|
m.pmut.RUnlock()
|
||||||
|
|
||||||
|
in, out := protocol.TotalInOut()
|
||||||
|
res["total"] = ConnectionInfo{
|
||||||
|
Statistics: protocol.Statistics{
|
||||||
|
At: time.Now(),
|
||||||
|
InBytesTotal: int(in),
|
||||||
|
OutBytesTotal: int(out),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,9 +10,15 @@ type countingReader struct {
|
|||||||
tot uint64
|
tot uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
totalIncoming uint64
|
||||||
|
totalOutgoing uint64
|
||||||
|
)
|
||||||
|
|
||||||
func (c *countingReader) Read(bs []byte) (int, error) {
|
func (c *countingReader) Read(bs []byte) (int, error) {
|
||||||
n, err := c.Reader.Read(bs)
|
n, err := c.Reader.Read(bs)
|
||||||
atomic.AddUint64(&c.tot, uint64(n))
|
atomic.AddUint64(&c.tot, uint64(n))
|
||||||
|
atomic.AddUint64(&totalIncoming, uint64(n))
|
||||||
return n, err
|
return n, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,9 +34,14 @@ type countingWriter struct {
|
|||||||
func (c *countingWriter) Write(bs []byte) (int, error) {
|
func (c *countingWriter) Write(bs []byte) (int, error) {
|
||||||
n, err := c.Writer.Write(bs)
|
n, err := c.Writer.Write(bs)
|
||||||
atomic.AddUint64(&c.tot, uint64(n))
|
atomic.AddUint64(&c.tot, uint64(n))
|
||||||
|
atomic.AddUint64(&totalOutgoing, uint64(n))
|
||||||
return n, err
|
return n, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *countingWriter) Tot() uint64 {
|
func (c *countingWriter) Tot() uint64 {
|
||||||
return atomic.LoadUint64(&c.tot)
|
return atomic.LoadUint64(&c.tot)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TotalInOut() (uint64, uint64) {
|
||||||
|
return atomic.LoadUint64(&totalIncoming), atomic.LoadUint64(&totalOutgoing)
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user