mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-06-27 21:05:53 +00:00
Add uptime to /stats
This commit is contained in:
parent
532cd0e2ce
commit
6cadcffd5c
1 changed files with 7 additions and 0 deletions
|
@ -12,6 +12,8 @@ import (
|
|||
|
||||
type StatsData struct {
|
||||
Version int
|
||||
StartTime time.Time
|
||||
Uptime time.Duration
|
||||
CachedStatsLastUpdate time.Time
|
||||
|
||||
CurrentClientCount uint64
|
||||
|
@ -58,6 +60,7 @@ var cpuUsage struct {
|
|||
|
||||
func newStatsData() *StatsData {
|
||||
return &StatsData{
|
||||
StartTime: time.Now(),
|
||||
CommandsIssuedMap: make(map[Command]uint64),
|
||||
DisconnectCodes: make(map[string]uint64),
|
||||
DisconnectReasons: make(map[string]uint64),
|
||||
|
@ -106,6 +109,10 @@ func updatePeriodicStats() {
|
|||
Statistics.CurrentClientCount = uint64(len(GlobalSubscriptionInfo.Members))
|
||||
GlobalSubscriptionInfo.RUnlock()
|
||||
}
|
||||
|
||||
{
|
||||
Statistics.Uptime = nowUpdate.Sub(Statistics.StartTime)
|
||||
}
|
||||
}
|
||||
|
||||
func HTTPShowStatistics(w http.ResponseWriter, r *http.Request) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue