mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-08-06 22:30:57 +00:00
more /stats updates
This commit is contained in:
parent
cc98c05472
commit
13b3f0f68a
2 changed files with 32 additions and 8 deletions
|
@ -285,6 +285,8 @@ func C2SEmoticonUses(conn *websocket.Conn, client *ClientInfo, msg ClientMessage
|
||||||
aggregateEmoteUsageLock.Lock()
|
aggregateEmoteUsageLock.Lock()
|
||||||
defer aggregateEmoteUsageLock.Unlock()
|
defer aggregateEmoteUsageLock.Unlock()
|
||||||
|
|
||||||
|
var total int
|
||||||
|
|
||||||
for strEmote, val1 := range mapRoot {
|
for strEmote, val1 := range mapRoot {
|
||||||
var emoteID int
|
var emoteID int
|
||||||
emoteID, err = strconv.Atoi(strEmote)
|
emoteID, err = strconv.Atoi(strEmote)
|
||||||
|
@ -305,9 +307,12 @@ func C2SEmoticonUses(conn *websocket.Conn, client *ClientInfo, msg ClientMessage
|
||||||
count = 200
|
count = 200
|
||||||
}
|
}
|
||||||
destMapInner[roomName] += count
|
destMapInner[roomName] += count
|
||||||
|
total += count
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Statistics.EmotesReportedTotal += uint64(total)
|
||||||
|
|
||||||
return ResponseSuccess, nil
|
return ResponseSuccess, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,9 +12,19 @@ import (
|
||||||
|
|
||||||
type StatsData struct {
|
type StatsData struct {
|
||||||
Version int
|
Version int
|
||||||
|
CachedStatsLastUpdate time.Time
|
||||||
|
|
||||||
CurrentClientCount uint64
|
CurrentClientCount uint64
|
||||||
|
|
||||||
|
PubSubChannelCount int
|
||||||
|
|
||||||
|
MemoryInUse uint64
|
||||||
|
MemoryRSS uint64
|
||||||
|
|
||||||
|
MemoryPerClient uint64
|
||||||
|
|
||||||
|
CpuUsagePct float64
|
||||||
|
|
||||||
ClientConnectsTotal uint64
|
ClientConnectsTotal uint64
|
||||||
ClientDisconnectsTotal uint64
|
ClientDisconnectsTotal uint64
|
||||||
|
|
||||||
|
@ -25,12 +35,7 @@ type StatsData struct {
|
||||||
|
|
||||||
MessagesSent uint64
|
MessagesSent uint64
|
||||||
|
|
||||||
CachedStatsLastUpdate time.Time
|
EmotesReportedTotal uint64
|
||||||
|
|
||||||
MemoryInUse uint64
|
|
||||||
MemoryRSS int64
|
|
||||||
|
|
||||||
CpuUsagePct float64
|
|
||||||
|
|
||||||
// DisconnectReasons is at the bottom because it has indeterminate size
|
// DisconnectReasons is at the bottom because it has indeterminate size
|
||||||
DisconnectReasons map[string]uint64
|
DisconnectReasons map[string]uint64
|
||||||
|
@ -38,9 +43,12 @@ type StatsData struct {
|
||||||
|
|
||||||
// Statistics is several variables that get incremented during normal operation of the server.
|
// Statistics is several variables that get incremented during normal operation of the server.
|
||||||
// Its structure should be versioned as it is exposed via JSON.
|
// Its structure should be versioned as it is exposed via JSON.
|
||||||
|
//
|
||||||
|
// Note as to threaded access - this is soft/fun data and not critical to data integrity.
|
||||||
|
// I don't really care.
|
||||||
var Statistics = newStatsData()
|
var Statistics = newStatsData()
|
||||||
|
|
||||||
const StatsDataVersion = 2
|
const StatsDataVersion = 3
|
||||||
const pageSize = 4096
|
const pageSize = 4096
|
||||||
|
|
||||||
var cpuUsage struct {
|
var cpuUsage struct {
|
||||||
|
@ -84,9 +92,20 @@ func updatePeriodicStats() {
|
||||||
cpuUsage.SysTime = pstat.Stime
|
cpuUsage.SysTime = pstat.Stime
|
||||||
|
|
||||||
Statistics.CpuUsagePct = 100 * float64(userTicks + sysTicks) / (timeDiff.Seconds() * float64(ticksPerSecond))
|
Statistics.CpuUsagePct = 100 * float64(userTicks + sysTicks) / (timeDiff.Seconds() * float64(ticksPerSecond))
|
||||||
Statistics.MemoryRSS = pstat.Rss * pageSize
|
Statistics.MemoryRSS = uint64(pstat.Rss * pageSize)
|
||||||
|
Statistics.MemoryPerClient = Statistics.MemoryRSS / Statistics.CurrentClientCount
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
ChatSubscriptionLock.RLock()
|
||||||
|
Statistics.PubSubChannelCount = len(ChatSubscriptionInfo)
|
||||||
|
ChatSubscriptionLock.RUnlock()
|
||||||
|
|
||||||
|
GlobalSubscriptionInfo.RLock()
|
||||||
|
Statistics.CurrentClientCount = uint64(len(GlobalSubscriptionInfo.Members))
|
||||||
|
GlobalSubscriptionInfo.RUnlock()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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