mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-08-03 00:18:31 +00:00
add build stamp to /stats
This commit is contained in:
parent
6cadcffd5c
commit
976a2593eb
2 changed files with 16 additions and 3 deletions
|
@ -11,9 +11,13 @@ import (
|
|||
)
|
||||
|
||||
type StatsData struct {
|
||||
Version int
|
||||
StatsDataVersion int
|
||||
|
||||
StartTime time.Time
|
||||
Uptime time.Duration
|
||||
BuildTime string
|
||||
BuildHash string
|
||||
|
||||
CachedStatsLastUpdate time.Time
|
||||
|
||||
CurrentClientCount uint64
|
||||
|
@ -50,7 +54,7 @@ type StatsData struct {
|
|||
// I don't really care.
|
||||
var Statistics = newStatsData()
|
||||
|
||||
const StatsDataVersion = 3
|
||||
const StatsDataVersion = 4
|
||||
const pageSize = 4096
|
||||
|
||||
var cpuUsage struct {
|
||||
|
@ -64,10 +68,15 @@ func newStatsData() *StatsData {
|
|||
CommandsIssuedMap: make(map[Command]uint64),
|
||||
DisconnectCodes: make(map[string]uint64),
|
||||
DisconnectReasons: make(map[string]uint64),
|
||||
Version: StatsDataVersion,
|
||||
StatsDataVersion: StatsDataVersion,
|
||||
}
|
||||
}
|
||||
|
||||
func SetBuildStamp(buildTime, buildHash string) {
|
||||
Statistics.BuildTime = buildTime
|
||||
Statistics.BuildHash = buildHash
|
||||
}
|
||||
|
||||
func updateStatsIfNeeded() {
|
||||
if time.Now().Add(-2 * time.Second).After(Statistics.CachedStatsLastUpdate) {
|
||||
updatePeriodicStats()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue