mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-06-28 05:15:54 +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 {
|
type StatsData struct {
|
||||||
Version int
|
Version int
|
||||||
|
StartTime time.Time
|
||||||
|
Uptime time.Duration
|
||||||
CachedStatsLastUpdate time.Time
|
CachedStatsLastUpdate time.Time
|
||||||
|
|
||||||
CurrentClientCount uint64
|
CurrentClientCount uint64
|
||||||
|
@ -58,6 +60,7 @@ var cpuUsage struct {
|
||||||
|
|
||||||
func newStatsData() *StatsData {
|
func newStatsData() *StatsData {
|
||||||
return &StatsData{
|
return &StatsData{
|
||||||
|
StartTime: time.Now(),
|
||||||
CommandsIssuedMap: make(map[Command]uint64),
|
CommandsIssuedMap: make(map[Command]uint64),
|
||||||
DisconnectCodes: make(map[string]uint64),
|
DisconnectCodes: make(map[string]uint64),
|
||||||
DisconnectReasons: make(map[string]uint64),
|
DisconnectReasons: make(map[string]uint64),
|
||||||
|
@ -106,6 +109,10 @@ func updatePeriodicStats() {
|
||||||
Statistics.CurrentClientCount = uint64(len(GlobalSubscriptionInfo.Members))
|
Statistics.CurrentClientCount = uint64(len(GlobalSubscriptionInfo.Members))
|
||||||
GlobalSubscriptionInfo.RUnlock()
|
GlobalSubscriptionInfo.RUnlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
Statistics.Uptime = nowUpdate.Sub(Statistics.StartTime)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func HTTPShowStatistics(w http.ResponseWriter, r *http.Request) {
|
func HTTPShowStatistics(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue