aboutsummaryrefslogtreecommitdiff
path: root/pkg/api/api0/serverlist.go
diff options
context:
space:
mode:
authorpg9182 <96569817+pg9182@users.noreply.github.com>2022-10-21 07:12:39 -0400
committerpg9182 <96569817+pg9182@users.noreply.github.com>2022-10-21 07:12:39 -0400
commitd2d0ee5e2755881de96963f29f21784d2f02fdb1 (patch)
tree63677c0c7fe49a183f7342cac8b269904c029d69 /pkg/api/api0/serverlist.go
parentb59edbe7bd52227089e949383f986f7e058dbb23 (diff)
downloadAtlas-d2d0ee5e2755881de96963f29f21784d2f02fdb1.tar.gz
Atlas-d2d0ee5e2755881de96963f29f21784d2f02fdb1.zip
pkg/api/api0: Add serverlist metric for servers with players
Diffstat (limited to 'pkg/api/api0/serverlist.go')
-rw-r--r--pkg/api/api0/serverlist.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/pkg/api/api0/serverlist.go b/pkg/api/api0/serverlist.go
index 67e6db0..fc9b019 100644
--- a/pkg/api/api0/serverlist.go
+++ b/pkg/api/api0/serverlist.go
@@ -395,7 +395,7 @@ func (s *ServerList) GetMetrics() []byte {
mpls = append(mpls, mpl{m, nstypes.Playlist("")})
}
- var players, maxPlayers, servers int
+ var players, maxPlayers, servers, serversWithPlayers int
mplPlayers := make(map[mpl]int, len(mpls))
mplMaxPlayers := make(map[mpl]int, len(mpls))
mplServers := make(map[mpl]int, len(mpls))
@@ -416,6 +416,9 @@ func (s *ServerList) GetMetrics() []byte {
players += srv.PlayerCount
maxPlayers += srv.MaxPlayers
servers++
+ if srv.PlayerCount > 0 {
+ serversWithPlayers++
+ }
mplPlayers[mplv] += srv.PlayerCount
mplMaxPlayers[mplv] += srv.MaxPlayers
mplServers[mplv]++
@@ -569,6 +572,9 @@ func (s *ServerList) GetMetrics() []byte {
b.WriteString(`atlas_api0sl_servers `)
b.WriteString(strconv.Itoa(servers))
b.WriteByte('\n')
+ b.WriteString(`atlas_api0sl_serverswithplayers `)
+ b.WriteString(strconv.Itoa(serversWithPlayers))
+ b.WriteByte('\n')
return b.Bytes()
}