mirror of
https://github.com/octoleo/syncthing.git
synced 2025-04-11 03:51:51 +00:00
commit
d47d82d8e1
@ -25,6 +25,8 @@ func getStatus(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
sessionMut.Lock()
|
sessionMut.Lock()
|
||||||
// This can potentially be double the number of pending sessions, as each session has two keys, one for each side.
|
// This can potentially be double the number of pending sessions, as each session has two keys, one for each side.
|
||||||
|
status["startTime"] = rc.startTime
|
||||||
|
status["uptime"] = time.Since(rc.startTime)
|
||||||
status["numPendingSessionKeys"] = len(pendingSessions)
|
status["numPendingSessionKeys"] = len(pendingSessions)
|
||||||
status["numActiveSessions"] = len(activeSessions)
|
status["numActiveSessions"] = len(activeSessions)
|
||||||
sessionMut.Unlock()
|
sessionMut.Unlock()
|
||||||
@ -43,6 +45,14 @@ func getStatus(w http.ResponseWriter, r *http.Request) {
|
|||||||
rc.rate(30*60/10) * 8 / 1000,
|
rc.rate(30*60/10) * 8 / 1000,
|
||||||
rc.rate(60*60/10) * 8 / 1000,
|
rc.rate(60*60/10) * 8 / 1000,
|
||||||
}
|
}
|
||||||
|
status["options"] = map[string]interface{}{
|
||||||
|
"network-timeout": networkTimeout,
|
||||||
|
"ping-interval": pingInterval,
|
||||||
|
"message-timeout": messageTimeout,
|
||||||
|
"per-session-rate": sessionLimitBps,
|
||||||
|
"global-rate": globalLimitBps,
|
||||||
|
"pools": defaultPoolAddrs,
|
||||||
|
}
|
||||||
|
|
||||||
bs, err := json.MarshalIndent(status, "", " ")
|
bs, err := json.MarshalIndent(status, "", " ")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -58,12 +68,14 @@ type rateCalculator struct {
|
|||||||
rates []int64
|
rates []int64
|
||||||
prev int64
|
prev int64
|
||||||
counter *int64
|
counter *int64
|
||||||
|
startTime time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
func newRateCalculator(keepIntervals int, interval time.Duration, counter *int64) *rateCalculator {
|
func newRateCalculator(keepIntervals int, interval time.Duration, counter *int64) *rateCalculator {
|
||||||
r := &rateCalculator{
|
r := &rateCalculator{
|
||||||
rates: make([]int64, keepIntervals),
|
rates: make([]int64, keepIntervals),
|
||||||
counter: counter,
|
counter: counter,
|
||||||
|
startTime: time.Now(),
|
||||||
}
|
}
|
||||||
|
|
||||||
go r.updateRates(interval)
|
go r.updateRates(interval)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user