metrics: initial commit

This commit is contained in:
Matthew Penner
2021-03-09 08:45:54 -07:00
parent 08a7ccd175
commit dafbbab2ed
8 changed files with 171 additions and 3 deletions

View File

@@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"github.com/pterodactyl/wings/metrics"
"io"
"io/ioutil"
"os"
@@ -72,6 +73,9 @@ func (m *Manager) Add(s *Server) {
m.mu.Lock()
m.servers = append(m.servers, s)
m.mu.Unlock()
// Add the server to the metrics with a offline status.
metrics.ServerStatus.WithLabelValues(s.Id()).Set(0)
}
// Get returns a single server instance and a boolean value indicating if it was
@@ -117,6 +121,9 @@ func (m *Manager) Remove(filter func(match *Server) bool) {
for _, v := range m.servers {
if !filter(v) {
r = append(r, v)
} else {
// Delete the server from the metric.
metrics.DeleteServer(v.Id())
}
}
m.servers = r